-
-
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
i18n: Silent failure when using ISO 639-3 language tags that have ISO 639-1 equivalents #9260
Comments
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. |
This is false. It only fails with some ISO 639-3 tags, and the failure is, sort of, correct. The problem is that the failure is silent. We might handle this with documentation; not sure yet. To borrow a phrase from Douglas Adams, BCP 47 (specifically RFC 5646) will be "first against the wall when the revolution comes." RFC 5646The ABNF syntax for the language tag defined in RFC 5646 is:
So, even though "eng" for English is valid per IS0 639-3, RFC 5646 requires "en" because English is also defined in IS0 639-1. Why is it important?Hugo, either directly or indirectly, uses the language tag for:
Each of these features relies on the Unicode Common Locale Data Repository (CLDR), which conforms to BCP 47, which includes RFC 5646. Parsing the language tagHugo, nicksnyder/go-i18n, and golang.org/x/text/collate use Go's language.Parse function. This function (a) validates the language tag, and (b) returns a language tag that conforms to RFC 5646 (see playground example).
Translation failureWith this site configuration:
Neither of these files are read:
Solution options1) Improve existing documentation. Currently this (a) is buried deep in a long page and (b) lacks a simple explanation of what it means to conform to RFC 5646. 2) Validate the language tags in the site configuration. We could test equivalence between the language tag and the value returned by language.Parse, which seems like it would work as the |
Reference: https://discourse.gohugo.io/t/35938
This behavior was introduced with v0.76.0 where we upgraded nicksnyder/go-i18n from v1 to v2.
eng
nld
es
zzz
mylang
MRE
git clone --single-branch -b hugo-forum-topic-35938 https://github.com/jmooring/hugo-testing hugo-forum-topic-35938 cd hugo-forum-topic-35938 hugo server
Notes
en
andnl
, but not foreng
andnld
.The text was updated successfully, but these errors were encountered: