Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于系统语言的获取 #4

Open
jeson251 opened this issue Jun 8, 2017 · 0 comments
Open

关于系统语言的获取 #4

jeson251 opened this issue Jun 8, 2017 · 0 comments

Comments

@jeson251
Copy link

jeson251 commented Jun 8, 2017

你好, 我觉得系统语言的获取不应该使用[[NSBundle mainBundle] preferredLocalizations],
而应该取[NSLocale preferredLanguages]中第0个, 再判断, 我只想到了用这种不严谨的判断方法:
NSString *firstLanguage = [NSLocale preferredLanguages].firstObject;
if ([firstLanguage hasPrefix:@"en"]) {
return 英语;
}
if ([firstLanguage hasPrefix:@"zh-Hans"] || //简体
[firstLanguage hasPrefix:@"yue-Hans"] //粤语简体
) {
return 中文简体;
}
if ([firstLanguage hasPrefix:@"zh-Hant"] || //繁体
[firstLanguage hasPrefix:@"zh-TW"] || //台湾
[firstLanguage hasPrefix:@"zh-HK"] || //香港
[firstLanguage hasPrefix:@"yue-Hant"] //粤语繁体
) {
return 中文繁体;
}
if ([firstLanguage hasPrefix:@"ja"]) {
return 日语;
}
if ([firstLanguage hasPrefix:@"ko"]) {
return 韩语;
}

return 其他;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant