My Tianium application uses i18n. I have four folders under i18n.
en/ ja/ zh-CN/ zh-TW/
zh-CN is Chinese used in Mainland china.
zh-TW is Chinese used in Taiwan.
it works well for i18n.
Now I want to get this name, in app.js. However, as for Ti.Locale.getCurrentLanguage()
, both Taiwan and Mainland china returns 'zh'
.
How can I tell zh-CN or zh-TW ???
----Solution---- Thanks to @DC Jmz
use Ti.Locale.getCurrentLocale()
if ( Ti.Locale.getCurrentLocale().match(/zh-Hant/)) {
Ti.App.global.lang = 'zh-TW'; // taiwan letters
}
if ( Ti.Locale.getCurrentLocale().match(/zh-Hans/)) {
Ti.App.global.lang = 'zh-CN'; // mainland china letters
}
Try using Ti.Platform.getLocale()
System's default language.
Locale, as a combination of ISO 2-letter language and country codes. For example, en-US or en-GB. See the ISO 639-1 and ISO 3166-1 alpha-2 sections of wikipedia for reference.