仅在某些区域提示输入性别
我正在使用本地化字符串设计一个 iOS 应用程序。我的一些字符串包含某些语言中包含性别后缀的单词。
我想提示我的用户指定他们是男性还是女性,但前提是设备使用需要性别代词的语言。
我该如何处理这个问题?我应该尝试检测设备的区域设置吗?我应该尝试检测 iOS 选择了哪个本地化包吗? (我该怎么做?)
I'm designing an iOS app using localized strings. Some of my strings include words that include gender suffixes in some languages.
I would like to prompt my users to specify whether they are male or female, but only when the device is using a language that requires gender pronouns.
How do I approach this? Should I attempt to detect the device's locale? Should I attempt to detect which localization bundle iOS selected? (How do I do that?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
[NSLocale systemLocale]
毫不奇怪地返回系统设置的区域设置。但是,您可能最好查询用户正在使用的语言。您可以通过查询 NSUserDefaults 中的键“AppleLanguages”并从返回的数组中获取第一个值来完成此操作。该值是用户选择的语言。
[NSLocale systemLocale]
not surprisingly returns the locale that the system is set to.You might however, be better querying the language that the user is using. You can do this by querying
NSUserDefaults
for the key 'AppleLanguages' and getting the first value from the returned array. This value is the user's chosen language.[NSLocale PreferredLanguages]
在位置 0 返回用户在“设置”应用中选择的语言。[NSLocale preferredLanguages]
returns at position 0 the language as chosen by the user in the Settings App.