I have a framework that has localizations in a bundle.
Screenshot of localizations before bundle is built:
This is the code I use in my framework to grab the bundle and strings:
+ (NSBundle*) bundleWithName:(NSString*)name {
NSString *mainBundlePath = [[NSBundle mainBundle] resourcePath];
NSString *frameworkBundlePath = [mainBundlePath stringByAppendingPathComponent:name];
if ([[NSFileManager defaultManager] fileExistsAtPath:frameworkBundlePath]){
return [NSBundle bundleWithPath:frameworkBundlePath];
}
return nil;
}
+(NSString *)localizedStringFromBundleWithKey:(NSString *)keyString
{
return NSLocalizedStringFromTableInBundle(keyString, nil, [Common bundleWithName:@"MyCool.bundle"], nil);
}
Then to access my localized strings:
[infoView setFirstButtonTitle:[Common localizedStringFromBundleWithKey:@"dialog_button_preferences"]];
When I drop the framework and bundle into a test project it looks like this:
If I change my device to Spanish or any other language the strings all show up in english in the test project.
Then to further the problem - if I add Localizable.strings to the test project (in addition to the ones in the framework bundle), none of the localizations work and instead show the "key" names.
What is the proper way of localizing an iOS framework?