Frontend: Ensure proper handling of language tag variations for zh

Created on 27 Oct 2017  路  17Comments  路  Source: home-assistant/frontend

our translations guidelines are still wip but we want to have a generic zh.json as fallback for zh-Hans.json and zh-Hant.json. Also zh-Hans.json and zh-Hant.json should only include strings that differ from zh.json (and en.json).

@cxlwill can you do this, please? :-)

Most helpful comment

That's nice. Thanks~~ I'm ready for state translation.

All 17 comments

I'm delighted to help. 馃槃 But I'm not a programmer actually only with basic skill. If there is any framework to refer would be nice. Since the differences between English and Chinese is quite big, I think almost every string is different from English. 馃槥 But it is OK.

hehe. Of course in your case you can ignore en.json cause all strings differ. I suggest you to rename one of your translations to zh.json (and also change the native language name to [Chinese]) and in the other one you only add strings that differ from zh.json

The problem is that unlike en-US vs. en-GB, the characters in Simplified Chinese and Traditional Chinese are different. As you can see in my translation, every strings are different between two translation. When you say rename to zh, do you suggest zh-Hans for default Chinese using?

hmm... good question. If there is no common base that also can be used for zh-CN, zh-TW, zh-SG, zh-HK and zh-MO we should keep the current structure. Sorry to bother you.

zh-SG users will see the English version and can select zh-Hans or zh-Hant in settings

//e:
maybe those browsers send a language tag like zh-Hans-SG and still get the correct version, I don't know

Actually all these things are generated with arguable language code system. Normally, zh-CN and zh-SG people use zh-Hans, others use zh-Hant. But the truth is that even zh-Hant is slightly different between zh-TW and zh-HK.

Anyway, there is no generic language for Chinese users. My zh-Hant approach is tend to fit zh-TW custom. For other zh-Hant used locale, there is no functionality differences.

Ok thanks for your input.
If anyone submits a zh-HK version in the future we should make sure that it's named zh-Hant-HK and is based on your zh-Hant if possible :)

@cxlwill
can you tell what language code you see here, please?

Detected 5 languages in your web browser:
zh-CN
zh
en-US
en
zh-TW

Let's keep this open for now, since it sounds like we still have to address how to handle what browsers are reporting. From what I can tell, it seems like a lot of sites will implicitly interpret zh-CN as zh-Hans-CN, or zh-TW as zh-Hant-TW. Our resolution might be to add some special cases to our matching function to support this, since it sounds like it's become a defacto standard, even if it isn't fully compliant.

https://github.com/home-assistant/home-assistant-polymer/blob/3e86ba122228115e6e59942f8083eac6302696c3/src/util/hass-translation.html#L14-L25

That's why I suggest this issue at the first stage, since I came across this through some project's translation experience. I recommend use old locale protocol like zh and zh-CN for Simplified Chinese and zh-TW & zh-HK for Traditional Chinese, because new protocol just doesn't fit reality. As far as I know, only Facebook use zh-hanX and Microsoft&Twitter&Google&Major Chinese websites still use locale.

If we use script subtag for Chinese would we also add support for other languages? https://www.quora.com/What-are-some-languages-that-are-written-in-more-than-one-script

A short summary about the language tag system:

2 formats:

  1. BCP47: \
  2. LOCALE: \ [] = optional

The advantage of BCP47 is that we also have a commom base for tags with same language-Script which is also used as fallback. zh-Hant-TW, zh-Hant-HK and zh-Hant-MO use zh-Hant.

Currently webbrowsers use LOCALE as default, but you could add the BCP47 style to your languages list (zh-Hant or zh-Hant-TW). For BCP47 this means we have to handle zh-TW as zh-Hant-TW.

I think until this issue is solved, updating my translation is not recommended?

You can keep working on the translation. For now this issue only affects auto detecting of the appropriate language, but it's still possible to select it manually in the configuration panel. It's something we want to solve, but there's a decent workaround for the time being.

561 adds detection for Chinese users

@cxlwill we granted you proofreader status for Japanese, Chinese Traditional and Chinese Simplified.
Also I removed the other languages for you so you have a better overview.

You can't vote anymore but you can proofread your prefered translations now :+1:

That's nice. Thanks~~ I'm ready for state translation.

Was this page helpful?
0 / 5 - 0 ratings