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?)
[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
NSUserDefaultsfor the key ‘AppleLanguages’ and getting the first value from the returned array. This value is the user’s chosen language.