Grav documents Multilanguage with regional variations. But there are several issues I have found when working on a site for Hong Kong. The mandate is for the site to have a choice between English, Traditional Chinese and Simplified Chinese. Grav documentation indicates that multilanguage with regional variations would be appropriate.
a) Grav documentation states the naming should be homogeneous, eg. default-en.md and default-zh.md, or default-en-GB.md, default-zh-HK, default-zh-CN.md, but not a heterogeneous system like: default-en.md, default-zh-cn.md, default-zh-hk.md
The issue here is whether a hetereogeneous naming system will cause problems in Grav.
It would be more natural to have one English file and two Chinese variations.
A related issue is the fall-back. If a browser gives a preference of ‘zh’ and not ‘zh-HK’, which of the variants is the fall-back? Am I right in thinking that it would be the first in the language list, that is if the languages are specified as en-GB, zh-CN, zh-HK, then a ‘zh’ preference would be delegated to the ‘zh-CN’ files. Or does a bare ‘zh’ default to the first language, which would be ‘en-GB’? (also see (d) below).
b) In Hong Kong (and Taiwan), Chinese is written with Traditional script, but in China with Simplified script. The script does not specify the language/dialect. So Cantonese (which is the dominant form in Hong Kong) is a different dialect/language from Mandarin (which is the form of Chinese taught in all mainland schools, and is used in Taiwan). In Hong Kong, Cantonese is written with Traditional characters, and In Taiwan Mandarin is written with Traditional script. In mainland China, Mandarin is written with simplified script. In some places in Hong Kong, Simplified script is being used to write local Cantonese!
The current convention is to add a script code (ISO 15924, hans for Simplified Chinese and hant for Traditional Chinese). So Simplified Chinese in China is zh-hans-CN and Traditional Chinese in Hong Kong is zh-hant-HK.
Can Grav handle this three-part naming system?
c) I loaded the LangSwitcher plugin and tried incorporating the twig script. The problem is that the twig script does not provide the correct response for zh-CN and zh-HK as it gives the simplified characters in Chinese and (cn) / (hk) in Latin characters. What I need is Simplified characters in one case and traditional in the other. The LangSwitcher twig code calls a twig function native-name (though I can’t work out where it comes from).
Basically, how do I over-ride the natural language names for the two codes I am interested in (zh-CN and zh-HK)?
d) Finally, a browser may provide a language preference (eg. zh-HK), but internally the files may be named differently, eg., default-zh-hant-HK). How can I direct Grav to map zh-HK to xxx-zh-hant-HK, ‘zh-CN’ and ‘zh’ to zh-hans-CN, or eg., ‘en’ and ‘en-GB’ to ‘xxx-en-GB’?