Skip to content

Instantly share code, notes, and snippets.

@shineycode
Last active December 11, 2015 14:39
Show Gist options
  • Save shineycode/4615575 to your computer and use it in GitHub Desktop.
Save shineycode/4615575 to your computer and use it in GitHub Desktop.
Intermittent NSLocalizedString issues
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSLog(@"Strings file: %@", [bundle pathForResource:@"Localizable" ofType:@".strings"]);
NSLog(@"Localizations: %@", [bundle localizations]);
NSLog(@"Local Dict: %@", [bundle localizedInfoDictionary]);
NSLog(@"localizedStringForKey: %@", [bundle localizedStringForKey:@"error.message.title"value:@"Wha Happened?" table:nil]);
NSLog(@"Localized String: %@", NSLocalizedString(@"error.message.title", @"Are you sure you want to start a new game?"));
// Rest of didFinishLaunchingWithOptions
}
// Contents of Localizable.strings
/*
"error.message.title" = "My Super Localized Text";
// Gets printed every other time on app launch
/*
Local Dict: (null)
localizedStringForKey: My Super Localized Text
Localized String: My Super Localized Text
*/
// Doesn't work
/*
Local Dict: (null)
localizedStringForKey: Wha Happened?
Localized String: error.message.title
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment