[docs-gitlab-com] Language selector and behavior on docs homepage

image

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:

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