innersourcecommons.org
innersourcecommons.org copied to clipboard
Chinese set as language by default
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
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
Sorry for the late response, let me address the issue
Thanks for taking a look, @yuhattor ❗
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...
That is odd!
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
Please review the PR!
Great that you found something! Will take a look sometime this week.
@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/
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.
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
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.
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!
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.