This topic is too old and there were other, more recent, with some solutions. Unfortunately I haven’t found a complete and fully automatic solution to this in the current MM v4, if I use localized paths. I just use the frontmatter data i18n_source
for storing the original source-url of the file. The langs switcher then is simple, in the layout.haml
I have a DIV for this partial:
= insert_langs_menu_item(current_page.data.i18n_source, :pl, "PL", "Przełącz na polski")
= insert_langs_menu_item(current_page.data.i18n_source, :en, "EN", "Switch to English")
= insert_langs_menu_item(current_page.data.i18n_source, :de, "DE", "Auf Deutsch umschalten")
In the helpers/custom_helpers.rb
I have:
# insert active link language-menu-item <A>, or <SPAN> if it’s for current locale
# MM4 version
def insert_langs_menu_item(page_url, new_locale, menu_text, title_attr=nil)
if I18n.locale == new_locale
return content_tag :span do menu_text end
else
return link_to menu_text, page_url, locale: new_locale, title: (title_attr || menu_text)
end
end
I assume that ALL pages have localized versions of the content. If your layout/header/footer/overall structure is localized then you can just think that all pages are kind-of localized.