[docs-gitlab-com] Language selector and behavior on docs homepage
Notes taken from this section on the GitLab Localization Platform document from the Spartan team.
Language selector implementation:
- The language selector allows users to switch between English and Japanese on any page.
- Upon selecting a language, the user is redirected to the same page in the chosen language.
- The content language is determined by the URL path, meaning the language selector will link to the same URL but with the current language replaced by the selected language
Functionality details:
- The list of available languages for the language selector is dynamically generated by iterating over the list of active languages specified in the Hugo configuration file (
hugo.yaml). - No language options will be hardcoded in the HTML; they will all be dynamically populated based on the configuration.
Handling missing translations:
-
If a user visits a Japanese URL that does not have a JA version but an English version exists, the page will automatically redirect to the English version. == This is fallback. Out of scope of language selector. To be developed in MVC of English locale fallback for Japanese tec... (#200 - closed) If neither an English nor Japanese version of the page is available, a 404 error page will be displayed.Related issue: https://gitlab.com/gitlab-com/localization/docs-site-localization/-/issues/27
In the event that a Japanese URL is visited that doesn’t have a Japanese version, but an English version exists, the page will redirect automatically. If there is no version available in either language, it will be 404.
Edited by Oleksandr Pysaryuk
