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

When building for zh_TW, zh_CN is incorrectly used as fallback language #9634

Closed
alvinhochun opened this issue Sep 15, 2021 · 0 comments · Fixed by #9635
Closed

When building for zh_TW, zh_CN is incorrectly used as fallback language #9634

alvinhochun opened this issue Sep 15, 2021 · 0 comments · Fixed by #9635

Comments

@alvinhochun
Copy link
Contributor

Describe the bug

In sphinx/locale/__init__.py:26 it uses the language part of the locale code as a fallback, so using zh_TW means [ 'zh_TW', 'zh' ] will be passed to gettext.translation.

In CPython, gettext.translation uses gettext.find, which finds the .mo file for each language specified. For zh_TW it finds the .mo file for zh_TW normally. However, when it gets to zh it first normalizes the locale code to zh_CN, which means it ends up finding the .mo file for zh_CN and adding that as a fallback.

gettext.translation already includes the language-without-country-code fallback. The "fallback" that Sphinx adds is unneeded and incorrect.

How to Reproduce

$ https://invent.kde.org/documentation/docs-krita-org.git -b krita/5.0
$ cd docs-krita-org
$ pip install sphinx
$ sphinx-intl build
$ make html SPHINXOPTS="-D language=zh_TW"
$ # open _build/html/user_manual/getting_started.html and see Simplified Chinese mixed in the text

Expected behavior

Untranslated text shall use the original English text and not "fall back" to Simplified Chinese.

Your project

https://invent.kde.org/documentation/docs-krita-org

Screenshots

Expected:

圖片

Incorrect:

圖片

OS

Linux

Python version

Python 3.9

Sphinx version

4.2

Sphinx extensions

No response

Extra tools

No response

Additional context

No response

@AA-Turner AA-Turner added this to the some future version milestone Sep 29, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants