Is there the official way to set fallback localized language in iOS app?

大憨熊 提交于 2019-12-12 02:45:51

问题


In iOS app development, I could't find the official way to set fallback localized language. I want to use English when user language is not included in my app's localizations. I tried way to use Base Internationalisation, however, all doesn't work for all language. Now, replace base.lproj to en.lproj, only languages added into my app are work well, but other languages are doesn't work well. (English not used, instead Korean is used when select a Russian...)

Some sites say that, set fallback language with value of "Localisation native development region", However, it didn't work well. Do you have any idea? Thanks.


回答1:


Your problem sounds pretty much like the problem I was having. Spent a lot of time looking for a solution until I finally came up with this approach (my issue link and text below).

iOS Localizable.strings not being retrieved from BASE file


Found a way to determine whether or not I have a localization file for the currently selected language, and if not, I can pull from the Base localization file.

NSString *path = [[NSBundle mainBundle] pathForResource:[[NSLocale preferredLanguages] objectAtIndex:0] ofType:@"lproj"];
if (path == nil)
{
    path = [[NSBundle mainBundle] pathForResource:@"Base" ofType:@"lproj"];
}

NSLocalizedStringFromTableInBundle(@"TAB_TITLE_Camera", @"Localizable", [NSBundle bundleWithPath:path], @"");

Simple solution that does everything I need.

Works on both iOS 6.1 and iOS 7.1.


If you don't have a localization file for the currently selected language, or you want to specify a particular language, just set the value for pathForResource and you should get the language you want.



来源:https://stackoverflow.com/questions/24568867/is-there-the-official-way-to-set-fallback-localized-language-in-ios-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!