innersourcecommons.org icon indicating copy to clipboard operation
innersourcecommons.org copied to clipboard

Chinese set as language by default

Open gruetter opened this issue 1 year ago • 14 comments

Describe the bug When opening pages on innersourcecommons.org, the chinese language is chose as the default language regardless of the browser language. This behaviour was confirmed by multiple users using different browsers. Example to reproduce: https://innersourcecommons.org/learn

Expected behavior The language should be chosen based on the browser language with English being the default, if the browser language doesn't match any of the languages supported by the site.

/FYI @rrrutledge , @dellagustin

gruetter avatar Apr 24 '23 15:04 gruetter

For me I see that happen when first visiting a page that doesn't exist - e.g. https://innersourcecommons.org/learning-path/ Thereafter I am always on Chinese pages. Here is a video:

https://user-images.githubusercontent.com/9609562/234694370-0049ae49-87f3-46ce-949c-aef4f5d634a1.mp4

rrrutledge avatar Apr 26 '23 20:04 rrrutledge

Sorry for the late response, let me address the issue

yuhattor avatar Jun 19 '23 07:06 yuhattor

Thanks for taking a look, @yuhattor ❗

rrrutledge avatar Jun 19 '23 09:06 rrrutledge

I'm still investigating, but have found this to be the case once the 404 is displayed. Looking at the built artifacts, it seems unlikely that zh would default otherwise. This seems to be a common error with hugo, so I guess the key is how 404.html is created.

I tried deleting the Chinese language in the first place, and the default language for 404 is now Russian. I think it's because the locale IDs are referenced in descending order, zh -> ru. I don't know why it doesn't have a default language set for it, and why language priority isn't applied, but maybe something weird is going on in the build process...

image

yuhattor avatar Jun 19 '23 09:06 yuhattor

That is odd!

rrrutledge avatar Jun 19 '23 12:06 rrrutledge

In conclusion, hugo does not support multilingual 404 pages, so I found that a hack is necessary in the current situation.

I created the PR #567 here. I added a little processing at build worklow

yuhattor avatar Jun 19 '23 13:06 yuhattor

Please review the PR!

yuhattor avatar Jun 19 '23 13:06 yuhattor

Great that you found something! Will take a look sometime this week.

rrrutledge avatar Jun 19 '23 16:06 rrrutledge

@yuhattor are you sure that this issue is caused by the 404 pages?

Here is one other example that I found today that seems unrelated to 404 pages:

Steps:

  • open this URL in the browser: https://innersourcecommons.org/about/announcements/2023-06-new-board-and-officers/
  • expected: redirect to https://innersourcecommons.org/about/announcements/2023-06-new-members/ (as that is set as an alias for the page above)
  • actual: redirects to the Chinese version https://innersourcecommons.org/zh/about/announcements/2023-06-new-members/

spier avatar Jun 20 '23 12:06 spier

Thank you

The redirection is suspicious. The reason why it is in China seems to be that hugo is not finding the English file properly. Also, need to check the version. The current version of hugo is 0.80.0, which is far from the latest 0.113.0.

yuhattor avatar Jun 20 '23 14:06 yuhattor

hugo is obviously behaving strangely.

The base language set is created by hugo --minify like normal en/ en/ fr/

On the other hand, a file like 404.html is created in root, which for some reason is overwritten with the language file generated by loop, without reference to the defaultLanguage setting. So the generated files have 'zh' embedded at the top in descending order of locale.

This seems like a bug in hugo.

https://github.com/InnerSourceCommons/innersourcecommons.org/assets/15963767/e5a1da5e-561d-4cde-8204-4b4c182209c7

image

yuhattor avatar Jun 20 '23 16:06 yuhattor

I think this is a pretty deep-rooted problem, and I'm looking at hugo's source code, but I don't know much about it yet, including the fact that I'm not a go pro. Might need more time.

yuhattor avatar Jun 20 '23 16:06 yuhattor

That's interesting - it feels like there should be some way to get this, but I don't know how our localization was set up and if it conflicts with any assumptions from Hugo. Thanks for checking this out!

rrrutledge avatar Jun 23 '23 19:06 rrrutledge

Within the announcement files it seems to only be occurring with files that use aliases. Ex: https://innersourcecommons.org/about/announcements/2023-08-new-executive-director/

and the example @spier gave.

andrea-kyurchiev avatar Aug 06 '23 10:08 andrea-kyurchiev