Evr*_*nia 7 iphone localization numbers arabic
我想知道如何在iPhone应用程序中显示阿拉伯数字,而无需本地化每个数字.
例如,我在代码中有一个整数,其值= 123
我希望将其显示为123而不必自己本地化每个数字并强制应用程序使用阿拉伯语作为本地化语言,而不管用户选择的语言
因为我在应用程序中有很多动态变化的数字,所以我需要一个通用的智能解决方案
Ara*_*han 22
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];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4251 次 |
| 最近记录: |