Skip to content

Instantly share code, notes, and snippets.

@maniak-dobrii
Created May 7, 2015 14:15
Show Gist options
  • Save maniak-dobrii/9ab459cde78a6f94daa7 to your computer and use it in GitHub Desktop.
Save maniak-dobrii/9ab459cde78a6f94daa7 to your computer and use it in GitHub Desktop.
Locales toy
NSLog(@"all supported localizations: %@", [[NSBundle mainBundle] localizations]);
NSLog(@"development localization: %@", [[NSBundle mainBundle] developmentLocalization]);
NSLog(@"preffered languages: %@", [NSLocale preferredLanguages]);
NSLog(@"");
NSLog(@"preffered localizations(most suitable): %@", [[NSBundle mainBundle] preferredLocalizations]);
NSLocale *activeLocale = [NSLocale localeWithLocaleIdentifier:[[[NSBundle mainBundle] preferredLocalizations] firstObject]];
NSLog(@"active locale: %@", activeLocale.localeIdentifier);
NSLog(@"current locale: %@", [NSLocale currentLocale].localeIdentifier);
NSLog(@"autoupdating current locale: %@", [NSLocale autoupdatingCurrentLocale].localeIdentifier);
NSLog(@"system locale: %@", [NSLocale systemLocale].localeIdentifier);
NSDate *now = [NSDate date];
NSLog(@"now (active locale) = %@", [now descriptionWithLocale:activeLocale]);
/*
2015-05-07 17:07:57.734 hey[81753:8793391] all supported localizations: (
Base,
"en-GB",
ru
)
2015-05-07 17:07:57.734 hey[81753:8793391] development localization: ru
2015-05-07 17:07:57.735 hey[81753:8793391] preffered languages: (
en,
"en-AU",
fr,
it,
ru
)
2015-05-07 17:07:57.735 hey[81753:8793391] preffered localizations(most suitable): (
"en-GB"
)
2015-05-07 17:07:57.736 hey[81753:8793391] active locale: en-GB
2015-05-07 17:07:57.736 hey[81753:8793391] current locale: en_GB
2015-05-07 17:07:57.736 hey[81753:8793391] autoupdating current locale: en_GB
2015-05-07 17:07:57.736 hey[81753:8793391] system locale:
2015-05-07 17:07:57.738 hey[81753:8793391] now (active locale) = Thursday, 7 May 2015 17:07:57 Moscow Standard Time
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment