Repository navigation
Let zh-HK and zh-MO use the same translation as zh-TW - #9059
Open
YDX-2147483647 wants to merge 2 commits into
Open
YDX-2147483647 wants to merge 2 commits into
YDX-2147483647 wants to merge 2 commits into
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Both zh-HK and zh-MO use traditional characters. However at present, their translations use simplified characters.
This PR fixes that by letting them fall back to zh-TW.
Resolves #8756
Code for the diagram
Additional considerations
Relationship between Traditional Chinese and zh-{TW,HK,MO}
Styling using language attributes | W3C Internationalization:
Roughly speaking, zh-{TW,HK,MO} can be considered as dialects1 of Traditional Chinese.
In our case, only a few nouns are translated, so the difference among zh-{TW,HK,MO} is negligible.
In fact when the strings in today's
zh-TW.txtwere initially added in #1000, they were meant to be Chinese (Traditional), and not specific to zh-TW.I once considered to rename the translation file for Traditional Chinese from
zh-TW.txttozh-Hant.txt. However,now I think it's better to keep the original file name, because future strings might require different translations for zh-TW and zh-{HK,MO}.Update: After seeing how CLDR organizes locales, I'm hesitating again... Perhaps it's better we rename it to
zh-Hant.txt. We can addzh-Hant-{HK,MO}.txtin the future if necessary.Why not
set text(lang: "zh", region: "TW")for all use case of Traditional Chinese?text.regionalso controls the OpenTypelocl(Localized Forms) feature.For some characters, there are stylistic differences between zh-HK and zh-TW glyphs. The following is an example for Source Han Sans.
As a result, when zh-HK glyphs are preferred,
set text(lang: "zh", region: "TW")cannot be used. Onlyset text(lang: "zh", region: "HK")can produce the correct glyphs.Why the new test case disables the paged target?
The paged target will display the specific glyphs. However, the current Noto Serif CJK fonts in typst-dev-assets do not support selecting the correct glyphs automatically based on
text.regionvia the OpenTypeloclfeature. As a result, I have to manually switch fonts to select the correct glyphs, which is cumbersome. (See also #8991 and typst/typst-dev-assets#18)For simplicity, I only tested the HTML target, which does not involve glyphs and fonts.
Why not just copy
zh-TW.txtas #8765 does?That would require keeping three files
zh-{TW,HK,MO}.txtsynchronized, which is not very convenient...Reference implementations
Wikipedia
We can take the Simplified 🡘 Traditional Chinese conversion rules of zh.wikipedia.org / MediaWiki as a reference.
It supports six converters: zh-{CN,HK,MO,MY,SG,TW}. (not counting internal converters)
Code for the diagram
Details about zhwiki / MediaWiki converters
As shown below, when an article is displayed on zh.wikipedia.org, the reader can select one of the six converters: 大陆简体 (zh-CN), 香港繁體 (zh-HK), 澳門繁體 (zh-MO), 大马简体 (zh-MY), 新加坡简体 (zh-SG), and 臺灣正體 (zh-TW).
According to zhwiki's help page, the hierarchy of these converters and three other internal converters is as the diagram above.
Specifically, zh-{CN,SG,MY} are based on zh-Hans, where zh-MY was split from zh-SG in 2018. And zh-{TW,HK,MO} are based on zh-Hant, where zh-MO was split from 2013.
The converters are implemented in MediaWiki's
ZhConverter.php, and the concrete rules are saved inZhConversion.php(~20k lines2).In short,
ZhConversion.phpmaintains 2+3 tables (ZH_TO_HAN{T,S}andZH_TO_{TW,HK,CN}), andZhConverter.phpdeclares a fallback chain for each converter:The fallback chains are interwoven together, because the converters have to support ad-hoc overrides in wikitext.
Code for the diagram
For the above wikitext, choosing any of zh-{CN,SG,MY} shows:
And choosing any of zh-{TW,HK,MO} shows:
LaTeX babel
The babel package supports 3 + 2×2 + 1 = 8 locales: zh, zh-Hans, zh-Hant, zh-Han{s,t}-{HK,MO}, and zh-Hans-SG. (not counting their aliases)
Most notably, babel does not support specifying zh-CN or zh-TW. Its manual implies that zh-Hans and zh-Hant should be used.
The localization files live in https://github.com/latex3/babel/tree/main/locale/zh.
Code for the diagram
Details about babel locales
zh, 中文 (
babel-zh.iniwithbabel-chinese.tex)zh-Hans, 简体中文 (
babel-zh-Hans.iniwithbabel-chinese-{hans,simplified}.tex)zh-Hans-HK, 中国香港特别行政区 (
babel-zh-Hans-HK.iniwithbabel-chinese-{hans-hk,simplified-hongkongsarchina}.tex)zh-Hans-MO, 中国澳门特别行政区(
babel-zh-Hans-MO.iniwithbabel-chinese-{hans-mo,simplified-macausarchina}.tex)zh-Hans-SG, 新加坡 (
babel-zh-Hans-SG.iniwithbabel-chinese-{hans-sg,simplified-singapore}.tex)zh-Hant, 繁體中文 (
babel-zh-Hant.iniwithbabel-chinese-{hant,traditional}.tex)zh-Hant-MO, 中國澳門特別行政區 (
babel-zh-Hant-MO.iniwithbabel-chinese-{hant-mo,traditional-macausarchina}.tex)zh-Hant-HK, 中國香港特別行政區 (
babel-zh-Hant-HK.iniwithbabel-chinese-{hant-hk,traditional-hongkongsarchina}.tex)zh-Latn-pinyin, Hànyǔ Pīnyīn (
babel-zh-Latn-pinyin.iniwithbabel-chinese-pinyin.tex)CLDR
Locale Data Summaries:
See also these sections in the CLDR core spec:
Code for the diagram
Footnotes
The word dialect is usually used to refer to spoken languages, but here we are more focused on written languages. ↩
This file is too large, so I'm linking to its history page. Click Code to view the actual file. ↩