我正在尝试获取一个字符串文件表,以便在 NSLocalizedStringFromTableInBundle 中使用。
我正在使用以下方法:
+(NSBundle*)getBundleForLang:(NSString*)lang{
//get the path to the bundle
NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"localizable" ofType:@"strings" inDirectory:nil forLocalization:lang];
NSLog(@"bundlePath = %@",bundlePath);
//load the bundle
NSBundle *langBundle = [[NSBundle alloc] initWithPath:[bundlePath stringByDeletingLastPathComponent]];
NSLog(@"langBundle = %@",langBundle);
return langBundle;
}
虽然仿真器上表现良好,但当我尝试在 iPhone 设备上使用它时,会出现如下 NSLog:
2011-12-09 00:40:14.533 MyApp[12754:707] langBundle = NSBundle
</var/mobile/Applications/915E6BCB-EC44-4F1D-891B-EF68E2FA89C2/MyApp.app/he.lproj>
(not yet loaded)
为什么它没有加载,问题出在哪里呢?
谢谢,
Shani
Localizable.strings
而不是localizable.strings
,请注意大小写。 - Lily Ballard