How to set default localization for iOS app
In my case I have only Russian localization with hard-coded strings in my app, but I use libraries with localization bundles. Strings from libraries were in English by default. Because NSBundle.mainBundle.preferredLanguages
were [ "en" ]
.
They became Russian after I specified app localization language in Info.plist with CFBundleLocalizations
key:
CFBundleLocalizations (Array - iOS, OS X) identifies the localizations handled manually by your app. If your executable is unbundled or does not use the existing bundle localization mechanism, you can include this key to specify the localizations your app does handle.
Each entry in this property’s array is a string identifying the language name or ISO language designator of the supported localization. See “Language and Locale Designations” in Internationalization and Localization Guide in Internationalization Documentation for information on how to specify language designators.
I think you need to use the Localization native development region
key in your info.plist file.
You probably need to set Russian as a value of CFBundleDevelopmentRegion
in the Info.plist.
CFBundleDevelopmentRegion (String - iOS, OS X) specifies the native region for the bundle. This key contains a string value that usually corresponds to the native language of the person who wrote the bundle. The language specified by this value is used as the default language if a resource cannot be located for the user’s preferred region or language.
Update
If you really want and need to override the language priority of the OS, you could use AppleLanguages
user defaults key (although, as you know, it is not recommended):
[[NSUserDefaults standardUserDefaults] setObject:@[@“ru”, @“en”] forKey:@“AppleLanguages”];