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
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.