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

Use "zh-CN" instead of "zh_CN" as the HTML lang tag for simplified Chinese pages #10214

Closed
ChaiByte opened this issue Feb 23, 2022 · 3 comments
Closed

Comments

@ChaiByte
Copy link

ChaiByte commented Feb 23, 2022

Is your feature request related to a problem? Please describe.
In Sphinx language configuration: Simplified Chinese is presented as "zh_CN". But it is not the standard HTML tag (see BCP 47 - Tags for Identifying Languages). So the auto-generated HTML lang tag will not be helpful for search engines.

<html{% if not html5_doctype %} xmlns="http://www.w3.org/1999/xhtml"{% endif %}{% if language is not none %} lang="{{ language }}"{% endif %}>

Describe the solution you'd like
When the language is set to "zh_CN" or "zh-CN", the HTML lang tag should be "zh-CN".

Describe alternatives you've considered
Only support "zh_CN" in language configuration, but it would be treated as "zh-CN" while generating HTML lang tags.

image

@ChaiByte ChaiByte added the type:enhancement enhance or introduce a new feature label Feb 23, 2022
@wendad
Copy link

wendad commented Mar 30, 2022

Hello, I can't search Chinese in the search box on my computer, but I can search English。
I can search Chinese when I deploy it in ReadThedocs, do you know why ?

@tk0miya tk0miya added type:bug builder:html and removed type:enhancement enhance or introduce a new feature labels Mar 30, 2022
@tk0miya tk0miya added this to the 5.0.0 milestone Mar 30, 2022
tk0miya added a commit to tk0miya/sphinx that referenced this issue Mar 30, 2022
So far, HTML builder output the `language` configuration as a language
tag for HTML.  But it takes locale string in ANSI C, not IETF language
code.

This converts locale string to language tag to generate valid language
tag for HTML.
@tk0miya
Copy link
Member

tk0miya commented Mar 30, 2022

Thank you for reporting. I just posted #10311 to fix this bug.

@wendad I'm not sure. Please ask to the RtD team. We don't know at all how it works.

FYI: I'm not good at Chinese search. But it seems the Chinese search module requires "jieba" library. How about install it?

@wendad
Copy link

wendad commented Mar 30, 2022 via email

tk0miya added a commit to tk0miya/sphinx that referenced this issue Apr 2, 2022
So far, HTML builder output the `language` configuration as a language
tag for HTML.  But it takes locale string in ANSI C, not IETF language
code.

This converts locale string to language tag to generate valid language
tag for HTML.
@tk0miya tk0miya closed this as completed in 11a1dbe Apr 2, 2022
tk0miya added a commit that referenced this issue Apr 2, 2022
Fix #10214: html: invalid language tag was generated for zh_CN
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants