0

is there a way to set the locale according to the currency code selected .i can get a list of currency codes.now if i select a currency code say USD ,then i should be able to get the locale identifier "en-US" and set the locale accordingly.The purpose is to format all currencies used in my application to this locale. how to do this?

i now set the normal string to currency string using the code

NSLocale* locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"ja_JP"] autorelease]; 
NSDecimalNumber *someAmount = [NSDecimalNumber decimalNumberWithString:unformattedString];
NSNumberFormatter *currencyFormatter = [[NSNumberFormatter alloc] init]; 
[currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[currencyFormatter setLocale:locale];

for that i have to get the locale identifier(in this case @"ja_JP"). in my app i have an option to change the currency.if euro is set then the locale identifier changes

sujith1406
  • 2,822
  • 6
  • 40
  • 60
  • @Mat i now set the normal string to currency string using the code NSLocale* locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"ja_JP"] autorelease]; NSDecimalNumber *someAmount = [NSDecimalNumber decimalNumberWithString:unformattedString]; NSNumberFormatter *currencyFormatter = [[NSNumberFormatter alloc] init]; [currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle]; [currencyFormatter setLocale:locale]; for that i have to get the locale identifier. in my app i have an option to change the currency.if euro is set then the locale identifier changes – sujith1406 Sep 29 '11 at 06:16
  • The point is, EUR (and other currencies) are in use in many locales. For euro, that's FR, GB, DE, IT, ES, BE, NL, AT, ... the list goes on. Setting a locale based on a currency is simply not generally possible. – Mat Sep 29 '11 at 07:13
  • @mat thanks for the point, but i am just using the locale for displaying the currency icon, so whether it is in france ,germany or denmark,the euro icon remains the same :) – sujith1406 Sep 29 '11 at 07:35
  • See Sijo's answer in http://stackoverflow.com/questions/7477702/how-can-i-get-the-locale-from-currency-names-list – Carl Hovland Dec 14 '11 at 10:32
  • @CarlHovland thanks for sharing the link.... but pls look who asked the question :) – sujith1406 Dec 15 '11 at 09:52

0 Answers0