Created
October 1, 2013 21:04
-
-
Save Koze/6785077 to your computer and use it in GitHub Desktop.
Switch language in app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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