Fixed ⚠️Wrong Chinese locale tags for modern browsers.

ShikiSuen

Well-known member
Affected version
2.1.9
XenForo till 2.1.9 still uses deprecated HTML language tags for Chinese locales like "zh-CN", "zh-TW", "zh-HK".
At least, this hinders Safari from picking up correct Chinese fallback fonts.
(in vBulletin 3.8 this is user-editable, but in XenForo it is only a dropdown menu, hence the necessity of filing this bug report.)

Since these are locale markers, not language markers, hence my omission of tags of minor sinolanguages like Cantonese, Shanghainese, etc.

Here are correct tags for both language and locale (including currency format):
Code:
zh-Hans-CN [Chinese Simplified, Mainland China]
zh-Hans-SG [Chinese Simplified, Singapore]
zh-Hant-HK [Chinese Traiditional, Hongkong]
zh-Hant-MO [Chinese Traiditional, Macau]
zh-Hant-TW [Chinese Traiditional, Taiwan & Penghu & Jinmen & Mazu]

For reference purposes, here are all correct tags usable in the HTML header:
Code:
zh-Hans [Simplified Chinese]
zh-Hans-CN [Used in Mainland China] [Simplified Chinese]
zh-Hans-HK [Used in HK] [Simplified Chinese]
zh-Hans-MO [Used in Macau] [Simplified Chinese]
zh-Hans-SG [Used in Singapore] [Simplified Chinese]
zh-Hans-TW [Used in Taiwan, Penghu, Jinmen, Mazu] [Simplified Chinese]
zh-Hant [Traiditional Chinese]
zh-Hant-CN [Used in Mainland China] [Traiditional Chinese]
zh-Hant-HK [Used in HK] [Traiditional Chinese]
zh-Hant-MO [Used in Macau] [Traiditional Chinese]
zh-Hant-SG [Used in Singapore] [Traiditional Chinese]
zh-Hant-TW [Used in Taiwan, Penghu, Jinmen, Mazu] [Traiditional Chinese]
 
Last edited:
My temporary fix:
(Use the following code block to replace lang="{$xf.language.language_code}" at the beginning of the PAGE_CONTAINER.)
HTML:
<xf:if is="$xf.language.language_code == 'zh-CN'">
            lang="zh-Hans-CN"
<xf:elseif is="$xf.language.language_code == 'zh-TW'" />
            lang="zh-Hans-TW"
<xf:elseif is="$xf.language.language_code == 'zh-HK'" />
            lang="zh-Hans-HK"
<xf:else />
            lang="{$xf.language.language_code}"
</xf:if>
 
Last edited:
My temporary fix:
(Use the following code block to replace lang="{$xf.language.language_code}" at the beginning of the PAGE_CONTAINER.)
HTML:
<xf:if is="$xf.language.language_code == 'zh-CN'">
            lang="zh-Hans-CN"
<xf:elseif is="$xf.language.language_code == 'zh-TW'" />
            lang="zh-Hans-TW"
<xf:elseif is="$xf.language.language_code == 'zh-HK'" />
            lang="zh-Hans-HK"
<xf:else />
            lang="{$xf.language.language_code}"
</xf:if>
I made some mistakes here. Here's the fixed version.

HTML:
<xf:if is="$xf.language.language_code == 'zh-CN'">
            lang="zh-Hans-CN"
<xf:elseif is="$xf.language.language_code == 'zh-TW'" />
            lang="zh-Hant-TW"
<xf:elseif is="$xf.language.language_code == 'zh-HK'" />
            lang="zh-Hant-HK"
<xf:else />
            lang="{$xf.language.language_code}"
</xf:if>
 
It does so because you're using a tag inside a tag, which is technically invalid syntax. For correct formatting, you want to switch to inline statements with ternary operator.
Thanks for your suggestion.
I know nothing about JavaScript, will try it when I mastered it.

My approaches at this moment is to use hot template modification in lieu of manual modification of PAGE_CONTAINER.
 
I wonder whether this issue has been fixed in XF 2.2 Beta 1.

(I failed to have a time to check this at this moment, hence a short reply here.)
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.0 Beta 6).

Change log:
Include the updated `zh-Han*` language codes and invisibly output the updated versions when we encounter the old `zh-CN` etc. versions
There may be a delay before changes are rolled out to the XenForo Community.
 
We've actually tackled this within the language system itself, outputting updated codes when we encounter the old ones.
 
We've actually tackled this within the language system itself, outputting updated codes when we encounter the old ones.
Thanks for the following-up.

Note that any issue caused by this fix on Linux (for any web browser) is supposed to be considered a bug on either Linux distro or the browser's behavior on Linux. // I found that system-wide language tags on Linux terminal and desktop environments are still following the old standard.
 
Last edited:
Back
Top Bottom