Skip to content
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

Zola is validating language incorrectly #2169

Open
pickfire opened this issue Apr 5, 2023 · 6 comments
Open

Zola is validating language incorrectly #2169

pickfire opened this issue Apr 5, 2023 · 6 comments

Comments

@pickfire
Copy link

pickfire commented Apr 5, 2023

Bug Report

Environment

Zola version: 0.17.2

Expected Behavior

zh-CN should not be valid language and should be suggested to use zh-Hans-CN or zh-Hans instead. I have seen zh-CN quite often in quite a few sites since it renders differently if it is done incorrectly and less readable.

Current Behavior

zh-CN passed language validation check since it uses unic-langid but is not recognized by browser, it should instead use zh-Hans which is specified by https://datatracker.ietf.org/doc/html/rfc5646#appendix-A and https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang.

I filled an issue to hexo too hexojs/hexo#5186.

Step to reproduce

  1. Install a theme (I didn't expect to have to install a theme just to test this out, and the first that I installed even broke, I almost want to ignore writing this issue)
  2. Set default_language = "zh-CN" in config.toml.
@Keats
Copy link
Collaborator

Keats commented Apr 5, 2023

Do you know a crate that validates language code for the browser?

@pyfisch
Copy link

pyfisch commented Apr 7, 2023

Both tags are valid, for a static site generator it might be useful to suggest adding a script to certain language codes.

@pickfire
Copy link
Author

pickfire commented Apr 8, 2023

Let me investigate on this, I think I need to check what needs to be done and if needed probably a separate crate will be done.

@jonassmedegaard
Copy link

Looks like the crate language-tags does exactly what is needed here.

@jonassmedegaard
Copy link

jonassmedegaard commented Aug 12, 2023

Another crate seemingly doing exactly what is needed here is fluent-langneg, also given that zola might use Fluent in future.

@Keats
Copy link
Collaborator

Keats commented Aug 13, 2023

fluent-langneg sounds like a good solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants