[ios] how to findout the language you use on ios devices.
来源:互联网 发布:淘宝客软文 编辑:程序博客网 时间:2024/06/04 19:42
需要在程序中判断当前的多语言环境是中文还是英文,在书上看到可以用下面的代码判断
NSLocale *locale = [NSLocale currentLocale];
NSString *localName = [locale localeIdentifier];
结果是localName = en_US
这个en_US是"多语言环境"设置里的 "区域格式"对应的值,并不是"语言"项对应的值。
我现在的现象就是虽然"语言"项设置成"简体中文",但是"区域格式"项设置的是美国印度什么的话,上
面的代码取得的是en_US,en_IN,而不是我想要的zh_XXX , 请高手指点!
问个问题真费劲!自己找到了。
NSArray *languages = [NSLocale preferredLanguages];
NSString *currentLanguage = [languages objectAtIndex:0];
preferredLanguages : (
zh-Hans,
en,
ja,
fr,
zh-Hant,
de,
nl,
it,
es,
pt-PT,
da,
fi,
nb,
sv,
ko,
ru,
pl,
pt,
tr,
uk
)
NSLocale *locale = [NSLocale currentLocale];
NSString *localName = [locale localeIdentifier];
结果是localName = en_US
这个en_US是"多语言环境"设置里的 "区域格式"对应的值,并不是"语言"项对应的值。
我现在的现象就是虽然"语言"项设置成"简体中文",但是"区域格式"项设置的是美国印度什么的话,上
面的代码取得的是en_US,en_IN,而不是我想要的zh_XXX , 请高手指点!
问个问题真费劲!自己找到了。
NSArray *languages = [NSLocale preferredLanguages];
NSString *currentLanguage = [languages objectAtIndex:0];
preferredLanguages : (
zh-Hans,
en,
ja,
fr,
zh-Hant,
de,
nl,
it,
es,
pt-PT,
da,
fi,
nb,
sv,
ko,
ru,
pl,
pt,
tr,
uk
)
- [ios] how to findout the language you use on ios devices.
- How to use Facebook iOS SDK on iOS 10
- How to Use Custom TTF Font on iOS
- How to force NSLocalizedString to use a specific language iOS APP内国际化
- iOS: How to use "Block"
- (iPhone/iPad开发)how to browse the document directory of iOS Devices
- How to use NSNotification in iOS?
- How to use Blocks with iOS
- Stack Overflow:iOS how to use UIAlertView
- How To: Compile and Use Tesseract (3.01) on iOS (SDK 5)
- How to share text to Message in the app you are building(iOS platform)
- how to debug the gpu on you target
- How to Use JSONKit for iOS and the Rotten Tomatoes API
- Example Source Code: Using Face Detection To Create The Illusion Of Real 3D On iOS Devices
- C Language Study - how to use '#'
- How to use the tools provided to train Tesseract for a new language.
- How to Customize UITabBar on iOS 5
- How to Parse HTML on iOS
- 运行类不支持自动化或不支持期望的接口 的解决方法
- 选择,冒泡,插入,快速四种排序实现(字符串)
- STL容器 vector,list,deque 性能比较
- actionSupport fielderror
- js常用正则表达式
- [ios] how to findout the language you use on ios devices.
- 【CXY】JAVA基础 之 Collections
- VS2005,VS2008,VS2010工程文件和解决方案的区别
- 不能将参数 2 从“const char [11]”转换为“LPCTSTR
- Project Euler Problem 27小结
- 精美的后台管理界面模板和布局
- python 函数返回多个值
- CDialogSK---一个支持皮肤化的对话框类
- VMware下Ubuntu与宿主机简单共享文件夹