I want to know how to display arabic numbers inside iPhone apps without localizing each digit.
like for example, I have an integer in the code whose value = 123
I want to display it as ١٢٣ without having to localize each digit on its own and force the app to use arabic as the localization language regardless of the user's chosen language
because I have many numbers all over the application that change dynamically, so I need a generic smart solution
NSDecimalNumber *someNumber = [NSDecimalNumber decimalNumberWithString:@"123"];
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
NSLocale *arLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@"ar"] autorelease];
[formatter setLocale:arLocale];
NSLog(@"%@", [formatter stringFromNumber:someNumber]); // Prints in Arabic
[formatter setLocale:[NSLocale currentLocale]];
NSLog(@"%@", [formatter stringFromNumber:someNumber]); // Prints in Current Locale
[formatter release];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With