There are similar questions to this from beginners like me in localization, but I could not find what the trick does for me.
Here is my problem. We can get all ISO country codes in NSArray with the form [NSLocale ISOCountryCodes] . Now for each country in which I would like to print the local currency, as well as the currency code used in that country. What would be a suitable way to do this?
I did the following, which doesnβt work in the sense that I get US USA form strings: (null) ((null)) when instead I would like to get US form strings: $ (USD):
myCountryCode = [[NSLocale ISOCountryCodes] objectAtIndex:row]; appLocale = [[NSLocale alloc] initWithLocaleIdentifier: @"en_US"]; identifier = [NSLocale localeIdentifierFromComponents: [NSDictionary dictionaryWithObject: myCountryCode forKey: NSLocaleCountryCode]]; myDictionary = [NSLocale componentsFromLocaleIdentifier: identifier]; myCountryName = [appLocale displayNameForKey:NSLocaleCountryCode value:[myDictionary objectForKey:NSLocaleCountryCode]]; localCurrencySymbol = [appLocale displayNameForKey:NSLocaleCurrencySymbol value:[myDictionary objectForKey:NSLocaleCurrencySymbol]]; currencyCode = [appLocale displayNameForKey:NSLocaleCurrencyCode value: [myDictionary objectForKey:NSLocaleCurrencyCode]]; title = [NSString stringWithFormat:@"%@ %@: %@ (%@)", myCountryCode, myCountryName, localCurrencySymbol, currencyCode]; [appLocale release];
(Above the identifier, myCountryCode, myCountryName, localCurrencySymbol, currencyCode and title are all NSString pointers. Moreover, myDictionary is an NSDictionary pointer, and appLocale is an NSLocale pointer). Essentially, the above code will be in pickerview, where I want to generate the title of each line on the fly.
Thanks so much for your time. In fact, the question is how do we ever have an ISO country code, how can we print (in the application locale) a currency symbol and a currency code for this particular country.
source share