Skip to content

Instantly share code, notes, and snippets.

@Koze
Created October 1, 2013 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Koze/6785077 to your computer and use it in GitHub Desktop.
Save Koze/6785077 to your computer and use it in GitHub Desktop.
Switch language in app
// select language from application's localizations
NSBundle *mainBundle = [NSBundle mainBundle];
NSArray *localizations = mainBundle.localizations;
NSString *localization = localizations.lastObject;
// search bundle contains Localizable.string
NSURL *URL = [mainBundle URLForResource:@"Localizable" withExtension:@"strings" subdirectory:nil localization:localization];
NSBundle *bundle = [NSBundle bundleWithURL:URL.URLByDeletingLastPathComponent];
// get localized string from bundle
NSString *string;
string = NSLocalizedStringFromTableInBundle(@"test", nil, bundle, nil);
NSLog(@"%@", string);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment