Similar to how class="current"
is added after the nav list is generated, we may be able to check $i18n->url_includes_lang
and inject the language prefixes in the same way. If we setup a menu structure like the following, this seems to work correctly for both top-level and section navigation:
- English (en)
- About (about)
- Products (products)
- Français (fr)
- A propos (a-propos)
- Produits (produits)
The navigation/top
output then becomes:
- English (/en)
- Français (/fr)
And the navigation/section?section=[i18n.language]
output becomes:
- About (/en/about)
- Products (/en/products)
And in French:
- A propos (/fr/a-propos)
- Produits (/fr/produits)
The second part of this is to setup a redirect in /index
to go to the default language page (e.g., /en
or /fr
) so that that page becomes the new homepage.
Note that {! navigation/section?section=[i18n.language] !}
becomes the equivalent of {! navigation/top !}
on multilingual sites, and {! navigation/top !}
becomes a list of available languages. This means that the default themes won't work out-of-the-box with setting navigation_method = url
, since that would just show the languages as the top-level nav, but the change is small and can be documented in the multilingual setup info accordingly.
Some other points to consider:
- The language pages at the top-level essentially become a list of active languages, since only the languages with pages for them would appear on the site.
- Links like
/fr/about
or/en/a-propos
will pull up the specified language instead of the intended one from the site structure, but since they're never linked to nobody would ever reach them anyway. - This ought to work correctly with both
page_url_style = flat
andpage_url_style = nested
once that change is merged into master.
Probably missed other details, but that's about all I can think of for now.