Reputation: 18932
In iOS, if I create a bundle and add it to my target, I presume I should be able to load localized strings from it. What should the directory structure be? Currently I have:
mybundle.bundle/Contents/Resources/en.lproj/Localizable.strings
I'm trying to load them like this:
NSString *path = [[NSBundle mainBundle] pathForResource:@"mybundle" ofType:@"bundle"];
bundle = [NSBundle bundleWithPath:path];
[bundle localizedStringForKey:@"mykey" value:@"default value" table:nil];
This does not seem to be working. I can see the bundle is getting copied into the app.
Upvotes: 1
Views: 2199
Reputation: 18932
I was actually doing this correctly. The problem was that my Localizable.strings file was corrupted and, unlike app-level localizations, Xcode will not complain, it will just fail. In my case, I left out a semi-colon.
Upvotes: 3