Description
For a multilingual website supporting the Chinese language, it is best to cater to both Simplified Chinese "zh-Hans" (zh-CN, zh-SG) and Traditional Chinese "zh-Hant" (zh-TW, zh-HK) audiences. It would be great if Hugo could automatically generate both zh-Hans and zh-Hant pages from a single .zh.md file, with the possibility of manual override if necessary. Some noteworthy examples are:
- Chinese Wikipedia: https://zh.wikipedia.org/
** See https://en.wikipedia.org/wiki/Chinese_Wikipedia for details
** https://meta.wikimedia.org/wiki/Automatic_conversion_between_simplified_and_traditional_Chinese - Debian's website is multilingual too: https://www.debian.org/
- The feature could be enabled globally, and enabled/disabled in the front matter of individual pages.
- When enabled, filename.zh.md would generate the corresponding filename.zh.html, filename.zh-Hans.html, filename.zh-Hant.html, as well as filename.zh-CN.html, filename.zh-TW.html and filename.zh-HK.html if the user desires (configurable), unless, for example, filename.zh-Hant.md already exists.
- Provide automatic conversion with Go port of OpenCC or similar.
- Allow manual override to prevent certain text from being converted.
- Allow custom conversion list for certain phrase-level/variant conversion.
Automatic conversion
OpenCC, written by @BYVoid and hosted at https://github.com/BYVoid/OpenCC, is currently one of the most popular and likely the best open-source Chinese conversion tool:
Open Chinese Convert (OpenCC, 開放中文轉換) is an opensource project for conversion between Traditional Chinese and Simplified Chinese, supporting character-level conversion, phrase-level conversion, variant conversion and regional idioms among Mainland China, Taiwan and Hong kong.
And a good news! @liuzl, a Hugo user himself, recently ported OpenCC to a pure Go implementation called GoCC, see https://github.com/liuzl/gocc
Manual override / Custom conversion list
Yes, Chinese Wikipedia has these features. I am not sure which syntax we should use for Hugo, or perhaps existing syntax and/or github.com/nicksnyder/go-i18n already handle some of these cases?
Need further investigation and thinking.
See also gohugoio/hugoDocs#461