creating dynamic NSLocale with location data

339 Views Asked by At

I'm working on an app which should create an NSLocale object based NOT on the user's region (which should remain at the user's preferred language for most interface elements), but on the physical location of the traveler, to format currency. However, to build an NSLocale I need to concatenate the language (e.g. 'en') and the location (e.g. 'US') to initWithLocaleIdentifier:@"en_US", and thus to get the currency conventions into the formatter.

I can get the ISOcountry code from the CLPlacemark, but the language information... is harder to identify. Is there a lookup table of language options for each country, or some other option for initializing an NSLocale object based only upon the 'country' information?

I've made a cheap concatenation of @"us_US" which seems to work as well as @"de_DE" (!), but I don't know if I can count on that in all cases.

Thanks,

Tim

1

There are 1 best solutions below

0
On

For what it's worth, it seems that the NSLocales can in fact be initialized -- at least for the purpose of obtaining currency information -- with 'gb_GB' or 'us_US' locale identifier. I haven't found exceptions in the locations offered by Xcode.