iOS Localizable.strings not being retrieved from BASE file

為{幸葍}努か 提交于 2019-11-29 12:38:15

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], @"");

If the current language is:

English it returns Camera

Spanish it returns Cámara

Anything else that doesn't have a localization file returns CAMERA

Simple solution that does everything I need.

Works on both iOS 6.1 and iOS 7.1.

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