4

I have an iOS app where I want to include the user's country (as defined by region) in a text string, e.g. “In Portugal this is …”. For most country names this is easy:

        let countryCode = locale.objectForKey(NSLocaleCountryCode) as! String
        let countryName = locale.displayNameForKey(NSLocaleCountryCode,
                                                   value: countryCode)!
        let text = "In \(countryName) this is …"

However, for some country names, the name should be prefixed by “the”, for example “the Netherlands” and “the United States”. Is this information available in NSLocale somehow, or are there other libraries that can help with this?

beta
  • 2,380
  • 21
  • 38
  • 1
    I'm sitting with the exact same question, but unfortunately no answer to give you. Just some background information: iOS uses the Unicode CLDR database ( http://cldr.unicode.org/ ) for this data, and as far as I can see there is no such information there. So I think the question about whether this information is available in NSLocale is "no", and that any third party library that solves the issue would have to maintain their own database. :/ – skagedal May 11 '16 at 13:31

0 Answers0