游戏开发时,iOS会返回当前语言为 "en"、"zh"、“zh-Hans"、"zh-Hant"等等
Unity对应的语言列表;
private static function CheckAndSetUserLanguage() : boolean {
switch(Application.systemLanguage) {
case SystemLanguage.Afrikaans: SetLang("af"); break;
case SystemLanguage.Arabic: SetLang("ar"); break;
case SystemLanguage.Basque: SetLang("eu"); break;
case SystemLanguage.Belarusian: SetLang("be"); break;
case SystemLanguage.Bulgarian: SetLang("bg"); break;
case SystemLanguage.Catalan: SetLang("ca"); break;
case SystemLanguage.Chinese: SetLang("zh"); break;
case SystemLanguage.Czech: SetLang("cs"); break;
case SystemLanguage.Danish: SetLang("da"); break;
case SystemLanguage.Dutch: SetLang("nl"); break;
case SystemLanguage.English: SetLang("en"); break;
case SystemLanguage.Estonian: SetLang("et"); break;
case SystemLanguage.Faroese: SetLang("fo"); break;
case SystemLanguage.Finnish: SetLang("fu"); break;
case SystemLanguage.French: SetLang("fr"); break;
case SystemLanguage.German: SetLang("de"); break;
case SystemLanguage.Greek: SetLang("el"); break;
case SystemLanguage.Hebrew: SetLang("he"); break;
case SystemLanguage.Icelandic: SetLang("is"); break;
case SystemLanguage.Indonesian: SetLang("id"); break;
case SystemLanguage.Italian: SetLang("it"); break;
case SystemLanguage.Japanese: SetLang("ja"); break;
case SystemLanguage.Korean: SetLang("ko"); break;
case SystemLanguage.Latvian: SetLang("lv"); break;
case SystemLanguage.Lithuanian: SetLang("lt"); break;
case SystemLanguage.Norwegian: SetLang("nn"); break; // TODO: Check
case SystemLanguage.Polish: SetLang("pl"); break;
case SystemLanguage.Portuguese: SetLang("pt"); break;
case SystemLanguage.Romanian: SetLang("ro"); break;
case SystemLanguage.Russian: SetLang("ru"); break;
case SystemLanguage.SerboCroatian: SetLang("sr"); break; // TODO: Check
case SystemLanguage.Slovak: SetLang("sk"); break;
case SystemLanguage.Slovenian: SetLang("sl"); break;
case SystemLanguage.Spanish: SetLang("es"); break;
case SystemLanguage.Swedish: SetLang("sv"); break;
case SystemLanguage.Thai: SetLang("th"); break;
case SystemLanguage.Turkish: SetLang("tr"); break;
case SystemLanguage.Ukrainian: SetLang("uk"); break;
case SystemLanguage.Vietnamese: SetLang("vi"); break;
case SystemLanguage.ChineseSimplified: SetLang("zh_Hans"); break;
case SystemLanguage.ChineseTraditional: SetLang("zh_Hant"); break;
case SystemLanguage.Unknown: SetLang(defaultLang); break; // Unknow Fallback to defaultLang
case SystemLanguage.Hungarian: SetLang("hu"); break;
};
if(gameLang.length > 0) {
return true;
}
return false;
}
所有语言的缩写对应表:
var LANGUAGE_BY_LOCALE = {
af_NA: "Afrikaans (Namibia)",
af_ZA: "Afrikaans (South Africa)",
af: "Afrikaans",
ak_GH: "Akan (Ghana)",
ak: "Akan",
sq_AL: "Albanian (Albania)",
sq: "Albanian",
am_ET: "Amharic (Ethiopia)",
am: "Amharic",
ar_DZ: "Arabic (Algeria)",
ar_BH: "Arabic (Bahrain)",
ar_EG: "Arabic (Egypt)",
ar_IQ: "Arabic (Iraq)",
ar_JO: "Arabic (Jordan)",
ar_KW: