Hi all,
I’m a new user of Hugo and I would like to create a multilingual site using 3 languages: fr, en, nl.
The variable DefaultContentLanguage is set to; en
I would like this language selector to be translated in the current language too upon switching.
So, if the current language is english, the language displayed must be: English, French, Dutch
If the current language is french: Français, Anglais, Néerlandais.
And so on.
In order to translate those, I’ve created 3 files:
- /i18n/fr.yaml
- /i18n/nl.yaml
- /i18n/en.yaml
The content fr.yaml:
English:
other: Anglais
French:
other: Français
Dutch:
other: Néerlandais
The content of nl.yaml and en.yaml is the same but only with the language names translated.
During the development of the language switcher, I noticed a weird behavior with it. I don’t know if it’s a bug yet or a wrong way of doing on my side.
I’m using a theme based on the Bootstrap framework and here is what I’m using for a simple language switcher in the navbar.
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ .Lang }}</a>
<ul class="dropdown-menu">
{{ range .Translations }}
<li class="dropdown menu-item">
<a href="{{ .Permalink }}">{{ i18n (default .Lang .Site.Language.LanguageName) }}</a>
</li>
{{ end}}
</ul>
</li>
When I select english, I see ‘EN’ in the navbar and there is no links in the language switcher links.
When I select french, I see FR in the navbar and I see ‘Anglais’ and ‘Néerlandais’ in the language switcher.
When I select dutch, I see NL in the navbar and I see ‘Engels’ and ‘Frans’.
The language selector is working fine only for languages that are not the default one.
I’m unable to push the website sources online yet but I can share some codes upon request of course.
Let me know what I can do to help find a solution to this.
Thanks in advance.