I'm new to developing the iOS app, so I've recently encountered a problem in localizing my app. I want to take some actions in response to language change in system settings. To get the language ID I use
[[NSLocale preferredLanguages] objectAtIndex: 0]; In the applicationDidFinishLaunchingWithOptions method method. For the first time, it returns the language id (like "n" for english). Again, I close my application (or send it in the background) and change the language to German. After that, I restart my app, but instead of "de", it still gives "n" I think my app probably can store the old settings anywhere ... but where really ? How to get a valid current price?
Take a look at this old answer:
Edit: NSString * testLang = [[NSLocale preferred language] objectAtIndex: 0]; NSString * testLang1 = [[NSLokel preferred languages] ObjectAutindex: 1]; NSString * testLang2 = [[NSLokel preferred language] ObjectAutindex: 2]; NSString * testLang3 = [[NSLokel preferred languages] ObjectTitx: 3]; NSString * testLang4 = [[NSLokel preferred languages] ObjectAutindex: 4]; NSLog (@ "Lingua SIS:% @:% @:% @:% @:% @", test language, test length 1, test length 2, test long 3, test long 4); : In the debugger console, Lingua SYS: en: it: fr: de: ja
or:
Lingua SYS: es: en: it: fr: de
or:
Lingua SYS: pt-PT: en: es: it: fr
such The code you posted is correct, the error should be elsewhere ...
Comments
Post a Comment