Our Customer got reports on the App-Store that something is wrong with the language selection of the app.
I've tried to find a solution for this myself but I just couldn't read out the settings that the user has set on the settings page correctly.
Information:
- We can't solve it with NSBundle because it would exceed the budget of the customer...
- App supports 3 base languages (German, French and English) (Swiss German, Swiss French, English UK English US etc are all transformed into de, fr or en)
- App contains 3 language files (de.lproj, fr.lproj and en.lproj)
- App defines supported languages in a constant array + fallback language (en) is at first position
- Language has to be set because otherwise iOS would decide to show english for swiss german or english for swiss french for example
Problem:
- We select English in the settings and then start the app --> App is in English --> OK
- We then change language in the settings to German and then start the app --> App is in English --> Not OK
- Reinstalling the app puts us to point 1. again (with selected language)
What does the App do?
- Read
[[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"]
(preferred languages)
- Read
- Read
[[NSLocale autoupdatingCurrentLocale] objectForKey:NSLocaleLanguageCode]
(to get the regional format)
- Read
- Transform de-CH fr-CH en-US en-UK etc. to de/fr/en
- If SupportedLanguages contains autoupdatingCurrentLocale
[[NSUserDefaults standardUserDefaults] setObject:languages forKey:@"AppleLanguages"];
with autoupdatingCurrentLocale at first position- ELSE:
[[NSUserDefaults standardUserDefaults] setObject:languages forKey:@"AppleLanguages"];
with fallback language (en) at first position
- If SupportedLanguages contains autoupdatingCurrentLocale
[[NSUserDefaults standardUserDefaults] synchronize];
[[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"]
doesn't change anymore when the user changes the language in the settings.
How do I solve this correctly? Any ideas?