我想把一种或一种翻译成中文或其他语言。这个数字可以从零开始到无穷远。我应该如何翻译/显示(用NSLocalizedString或其他)?
发布于 2014-08-18 09:14:58
正如特罗扬福所建议的那样,坚持数字似乎是个好主意。
如果你想翻译数字,可以这样做:-
NSDecimalNumber *yourNumber = [NSDecimalNumber decimalNumberWithString:@"456"];
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
NSLocale *yourLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh"];
[formatter setLocale: yourLocale];
NSLog(@"%@", [formatter stringFromNumber: yourNumber]); // It logs value in chinese
[formatter setLocale:[NSLocale currentLocale]];
NSLog(@"%@", [formatter stringFromNumber: yourNumber]); // It logs value in Current Localehttps://stackoverflow.com/questions/25359589
复制相似问题