Skip to content

Instantly share code, notes, and snippets.

@jemmons
Created February 29, 2016 19:15
Show Gist options
  • Save jemmons/cad7709ef98cfaea2a0f to your computer and use it in GitHub Desktop.
Save jemmons/cad7709ef98cfaea2a0f to your computer and use it in GitHub Desktop.
/* Doesn't work. */
NSLocale.currentLocale().displayNameForKey(NSLocaleCountryCode, value: "DE")
//> nil
/* Does work. */
NSLocale(localeIdentifier: "en_US").displayNameForKey(NSLocaleCountryCode, value: "DE")
//> "Germany"
/* Just to make sure my currentLocale isn't nil or something daft */
let identifier = NSLocale.currentLocale().localeIdentifier
//> "en_US"
/* Ensure the same locale as currentLocale */
NSLocale(localeIdentifier: identifier).displayNameForKey(NSLocaleCountryCode, value: "DE")
//> "Germany
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment