-
-
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
Language codes are silently lowercased from config #7344
Comments
@bep The change mentioned here seems pretty straightforward. We have 2 options if we do want to do code change.
To support standard localisation (en-GB etc.) I would tend towards the second approach, but it could potentially break existing projects. So I think the documentation option proposed by @sergioisidoro seems to be the way to go considering everything. |
It there is something worth doing, it's worth overdoing. :D Here's the IETF guidelines.
And So it seems that the "correct" way of doing this is to not lowercase the languages. |
@hasitpbhatt Added some very rudimentary docs here: gohugoio/hugoDocs#1139 |
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. |
@hasitpbhatt What is the way forward here? I can try to draft some PR. |
@bep can you please help us out here!!! Thanks |
This is indeed a problem as it's not using the ISO standard definition. Language code should be lowercase, but country code has to be upper case. Facebook sharing for example is expecting https://developers.facebook.com/docs/internationalization#locales
|
Related with this Hugo issue: gohugoio/hugo#7344
Just an additional information. As per W3C, the casing of language codes does not matter as far as HTML and XML are concerned. See: Language tags in HTML and XML
(my emphases) The aforementioned W3C page was last updated on: 2014-03-03 13:55. I searched archive.org and found that it has always been that way. See: archive.org: 2005-02-25 13:36:05 I used to understand that language codes should follow the IANA subtag registry casing as well, even though I've read the aforementioned W3C document countless of times--but for some reason it did not register. It also doesn't appear that they silently added it recently since archive.org shows it has always been there. Since the W3C is the authority on HTML and XML markup, and they said the casing does not matter for those, I'm withdrawing my request for this feature. Also, minifiers lowercase it (at least by default) and browsers does are fine with it. Unless, as W3C said, |
This was resolved in v0.76.4. No problems with this configuration: defaultContentLanguage = "en-GB"
[languages.en-GB]
weight = 1
[languages.pt-PT]
weight = 2 For those concerned about the inability to use upper case or mixed case in the published URL, see #9404. For those concerned about upper case and mixed case in the built-in templates (rss, sitemap, and alias), specify a language code in your site configuration. For example: [languages.en]
languageCode = 'en-US'
weight = 1
[languages.de]
languageCode = 'de-DE'
weight = 2 Use the value in your templates with If you populate the |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
What version of Hugo are you using (
hugo version
)?Does this issue reproduce with the latest release?
Yes. Upgraded and tested with latest :
Hugo Static Site Generator v0.72.0/extended darwin/amd64 BuildDate: unknown
Issue
This is a fairly simple thing I found that should be fixable in 5 minutes for people who know the codebase. I was trying to setup localisation with language codes including the regional variations (
en-GB
,pt-PT
, etc) and was hitting an error.After a couple of trials and errors i found that if I had everything in lowercase it worked. Apparently the
[languages]
keys are lowercased, but thedefaultContentLanguage
is not.Additional thing that might be usefull: Add an example with these regional languages to documentation
Code:
Fails with
But if I change things to:
Things work. Since Hugo is silently downcasing the language codes, it makes sense to automatically lowercase the
defaultContentLanguage
param.The text was updated successfully, but these errors were encountered: