-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hugo cannot identity correct translation string when multiple variants of a language code is used #7982
Comments
I believe I am also experiencing this issue, and it still exists in Hugo 0.86.0. |
@bep: Did you happen to have any pointers / ideas on where the problem may lie? (Or is this more likely an issue with a dependency? I'd be happy to test out fixes, but have not had a chance to dig into the codebase yet.) |
I think you can fix the problem by remove either What's the difference between this language file? I thought there same? |
@smailzhu That doesn't "fix" the problem. These files could certainly be different. Using another example to illustrate the point: maybe the site owner wants to have |
About this question I think it may have some problem with i18n in hugo |
@shaform I cannot reproduce the warning with |
That's interesting. I wonder what's so special about |
I have seen this issue with |
This was resolved in v0.112.0. Minimal example:
|
There's something strange going on here. I've taken your example, added a similar
...and the error reappeared
If I change |
I've update the test conditions per your remarks and can reproduce the problem.
Expected result in console:
Actual result in console:
I suspect this is an upstream problem, but it will take some effort to dig into. |
Lines 118 to 120 in 9dd6870
We're throwing the warning even when the error is nil. That block should be wrapped with As for why it's choosing the wrong i18n file, I am suspicious of how the files are ordered. I'm guessing the logic is something like, "Yeah, zh-CN looks good, let's use that. No need to look any further." |
What version of Hugo are you using (
hugo version
)?Does this issue reproduce with the latest release?
Yes.
Steps to Reproduce
The problem can be reproduced by following the steps below:
Copy the current multilingual example to local directory: https://github.com/gohugoio/hugo/tree/b8758de19ec75b4565075314f9578270a092bc6f/examples/multilingual
cd
into the local directory and createzh
files by executing the commands:Modify
i18n/zh.toml
, setother
=Correct title
Modify
i18n/zh-cn.toml
, setother
=Wrong title
Add the following content into
config.toml
hugo server
.When
hugo server
is executed, a warning message is displayed, indicating something is wrong:HUGO_URL/zh/home
. We should expect that the page title isCorrect title
. However,Wrong title
is displayed as the page title.Comments
This is probably related to #7838.
The text was updated successfully, but these errors were encountered: