Add language selector for multi-language support
What does this MR do and why?
This MR implements a language selector component that allows users to switch between available language translations on the GitLab documentation site.
Why was this MR needed?
Currently, users have no easy way to switch between language versions when multiple translations are available. With Japanese (ja-JP) and English (en-US) languages now configured, we need a user-friendly interface for language switching.
How
- Conditional Display: Language selector only appears when 2 or more translations exist for a page
- Hugo Template Integration: Uses
.AllTranslationsto detect available translations - Vue Component: Implements
language_selector.vuecomponent that usesGlCollapsibleListboxfrom "@gitlab/ui"
Related Issues
- Closes gitlab-com/localization/docs-site-localization#253 (closed)
- Related gitlab-com/localization/docs-site-localization#39 (closed)
Screen_Recording_2025-06-02_at_10.17.41_AM
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
- Configure a local GitLab Docs environment.
- Check out this branch.
- In
config/_default/hugo.yamlsetlanguages.ja-jp.disabledtofalseusing the functionality added in !767 (merged). This will enable the japanese site to be built. - Run
make view - Any page that has translations available, will display the language selector component in the header
4. For example
/api/4 If no translations are available, the language selector does not display.- For example
/user/gitlab_duo/
- For example
- Toggle between english and japanese versions if a page
- Close server, change
languages.ja-jp.disabledtotrue - Verify the language selector never displays
Note - This feature allows the user to switch between available language variants of the current page using the language selector.
Merge request acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this merge request.