-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Validate lang #5186
Comments
Language codes are based on ISO-639-1 standard. HTML and CSS recognize these codes. However When I wrote the read-time plugin for hexo (https://github.com/AsemAlhaidary/hexo-generator-readtime/), I did find codes for I don't see the need to change the lang-code until the specification for ISO-639 is changed and recognized by all major browsers. |
ISO-639-1 indeed defines languages, but what is needed on the Web is more nuanced. W3 describes it well here:
(emphasis mine) |
You are correct that BCP 47 can be used. And technically, there's nothing stopping us from using that in our Hexo projects. When I wrote the read-time plugin, I used the ISO standard as I didn't see it mentioned in the MDN docs. W3 promotes BCP, but not everyone recognizes that. I know that Google translate supports the BCP-47 specifications. And, there is some overlap between ISO-639 and BCP-47. I've added aliases in my read-time plugin for support of other lang codes. And, it's trivial to add such support into Hexo (for your own theme). I'm in the process of building a Hexo theme that supports at least 28 languages. It's designed for professional bloggers that want to give their audiences a custom experience similar to Twitter or Mastodon. I've spent the past 18 months building it and I don't feel it's complete. But feel free to visit the dev version of my theme: https://2022.blog.richiebartlett.com . |
I noticed https://www.ihcblog.com/http-framework-design-axum-as-an-example/ and even the examples shown in this repository uses
zh-CN
andzh-TW
as seen inhexo/lib/plugins/helper/date.js
Line 73 in 7edbf25
This is not the first time I noticed this mistake in websites so I guess it is quite common, not using a valid lang recognized by the browser will cause the browser to render it in a different language other than the specified language, in my case it will cause the browser to use the incorrect font configured by the system (I configured arch linux to use a different chinese font for readability as in https://wiki.archlinuxcn.org/wiki/%E5%AD%97%E4%BD%93%E9%85%8D%E7%BD%AE/%E4%B8%AD%E6%96%87).
In the case of broken lang as mentioned in the above link.
When it is correct, it looks like this. (which wikemedia like what wikimedia/wikipedia has done)
Can refer to https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang and https://datatracker.ietf.org/doc/html/rfc5646.
zh-CN
should be eitherzh-Hans-CN
orzh-CN
andzh-TW
should bezh-Hant-TW
orzh-Hant
. If validation is done, ideally these suggestions should be given for users that used the old incorrect values to the new correct values.I did the same for japanese but I don't think it is an issue with
ja
since it does not have distinction between simplifiedzh-Hans
and traditional languagezh-Hant
which chinese have.Check List
Please check followings before submitting a new issue.
hexo version
to check)Expected behavior
hexo should prevent users from setting the invalid values.
Actual behavior
hexo just accepts whatever the user enters (most likely) since
zh-CN
works.How to reproduce?
zh-CN
(or evennani
) forlang
Is the problem still there under "Safe mode"?
Not sure but I did not try.
Environment & Settings
I am not a hexo user.
Hexo and Plugin version(
npm ls --depth 0
)Your package.json
package.json
Others
The text was updated successfully, but these errors were encountered: