theNewDynamic / gohugo-theme-ananke

Ananke: A theme for Hugo Sites
https://gohugo-ananke-theme-demo.netlify.app/
MIT License
1.14k stars 1.16k forks source link

i18n problem #611

Open Pathsis opened 1 year ago

Pathsis commented 1 year ago

After switching the site language, the header information shows that the site language is still the main language.

截屏2023-01-29 21 55 48
regisphilibert commented 1 year ago

Yes we're using site.LanguageCode here which is expecting the language to hold a languageCode key. Not sure how your language settings are set but from a regular config file you should have:

languages:
  en: 
    name: English
    languageCode: en
  fr:
    name: Français
    languageCode: fr-fr

I opened a ticket so that site.LanguageCode defaults on the language key when languageCode is not set for a given language.

Also, I think we can improve the theme to defaults on site.Language.Lang itself.

Pathsis commented 1 year ago

Yes we're using site.LanguageCode here which is expecting the language to hold a languageCode key. Not sure how your language settings are set but from a regular config file you should have:

languages:
  en: 
    name: English
    languageCode: en
  fr:
    name: Français
    languageCode: fr-fr

I opened a ticket so that site.LanguageCode defaults on the language key when languageCode is not set for a given language.

Also, I think we can improve the theme to defaults on site.Language.Lang itself.

The image above is a screenshot of the official demo, not my own website.

My parameters are set as follows.

截屏2023-02-04 00 52 55

When I don't set languageCode, the language will always be en; when I set languageCode = "zh", the language will always be zh.

regisphilibert commented 1 year ago

when I set languageCode = "zh", the language will always be zh. What do you mean by always? When navigating a language site, if that language as a languageCode set you should see as a html[lang] attribute this language's languageCode

We'll be fixing this on the theme pending soon (https://github.com/theNewDynamic/gohugo-theme-ananke/issues/615), but in the mean time, adding a languageCode key should work.

Thanks for pointing the configuration issue of the demo site, we'll fix this as well.

Pathsis commented 1 year ago

Yes, I mean, when switching the language menu of the navigation, the head always shows one language.