How to set default localization for iOS app
ios, iphone, objective-c, xcode
Solution
I have not found the right solution. Only one way that is suitable for my issue is to use `NSLocalizedStringFromTableInBundle` instead `NSLocalizedString`. This way doesn't allow to localize images or nibs but with strings it works great.
Firstly you need to define the current device language:
NSString *lang = (NSString *)[[NSLocale preferredLanguages] objectAtIndex:0];
Next find the bundle for this language:
NSBundle *myLangBundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:lang ofType:@"lproj"]];
If bundle is found then use it in `NSLocalizedStringFromTableInBundle`:
_label.text = NSLocalizedStringFromTableInBundle(@"LabelText",nil,myLangBundle,nil);
Otherwise find and use default bundle.
Problem
I'm developing app for Russian-speaking people. A lot of countries near Russia have the second language - Russian. My app has two localizations: Russian and English. And I need to set Russian localization like default. English should be only for people who use English like device's language. I know that Apple recommends to use localization in priority of preferred languages in settings but I have an important reason to don't follow this recommendation. How can I set Russian localization like default?