如何本地化文本中的所有数字?

时间:2017-08-16 14:00:04

标签: java android localization

在android中,我可以使用:

本地化数字
String.format(Locale.getDefault(), "%d", xxxxx) 

此处“xxxxx”必须仅包含数字。如果有一个数字与TextView中的文本混合的情况怎么办?我通过在for循环中用等号替换所有英文数字来解决这个问题,但有没有最好的方法来进行这种本地化? 例如:

 String.format(Locale.getDefault(), "%s", "The identification number is : 1234567");

此示例中的数字不会更改。

1 个答案:

答案 0 :(得分:0)

我希望这有帮助。

NumberFormat num_format = NumberFormat.getInstance(Locale.GERMAN);
String your_string = num_format.format(1000000);