if let Some(lang) = parts.next() {
let available_codes = translation::available_codes();
if available_codes.contains(&lang) {
- let mut rest: String = String::from("");
+ let mut rest = String::from("");
for part in parts {
rest.push('/');
rest.push_str(part);
{% macro recipe_item(id, title, is_current) %}
<li>
- <a href="/recipe/view/{{ id }}" class="recipe-item
+ <a href="/{{ tr.current_lang_code() }}/recipe/view/{{ id }}" class="recipe-item
{%~ if is_current %}
current
{% endif %}" id="recipe-{{ id }}"
-<a class="title" href="/"><img class="logo" src="/static/logo.svg" alt="logo">{{ tr.t(Sentence::MainTitle) }}</a>
\ No newline at end of file
+<a class="title" href="/{{ tr.current_lang_code() }}/"><img class="logo" src="/static/logo.svg" alt="logo">{{ tr.t(Sentence::MainTitle) }}</a>
\ No newline at end of file
calendar,
recipe_scheduler::RecipeScheduler,
shopping_list::ShoppingList,
- utils::{SelectorExt, by_id, get_locale, selector},
+ utils::{SelectorExt, by_id, get_current_lang, get_locale, selector},
};
pub fn setup_page(is_user_logged: bool) {
let shopping_list = ShoppingList::new(!is_user_logged);
spawn_local(async move {
+ let lang = get_current_lang();
+ let local = get_locale();
let item_template: Element = selector("#hidden-templates .shopping-item");
let container: Element = by_id("shopping-list");
let container_checked: Element = by_id("shopping-list-checked");
recipe_element.set_inner_html(&format!(
"{} @ {}",
recipe_title,
- date.format_localized(&date_format, get_locale()),
+ date.format_localized(&date_format, local),
));
recipe_element
- .set_attribute("href", &format!("/recipe/view/{}", recipe_id))
+ .set_attribute("href", &format!("/{}/recipe/view/{}", lang, recipe_id))
.unwrap();
}