ios - NSLocalizedString for number -
i want translate 1 or 1 chinese or other languages. number can start 0 infinity. how shall translate/show (with nslocalizedstring or other) ?
as trojanfoe suggest stick numbers seems opinion.
if want translate numbers, can done follows :-
nsdecimalnumber *yournumber = [nsdecimalnumber decimalnumberwithstring:@"456"]; nsnumberformatter *formatter = [[nsnumberformatter alloc] init]; nslocale *yourlocale = [[nslocale alloc] initwithlocaleidentifier:@"zh"]; [formatter setlocale: yourlocale]; nslog(@"%@", [formatter stringfromnumber: yournumber]); // logs value in chinese [formatter setlocale:[nslocale currentlocale]]; nslog(@"%@", [formatter stringfromnumber: yournumber]); // logs value in current locale
Comments
Post a Comment