Internationalization of distances in java

元气小坏坏 提交于 2019-12-10 02:22:28

问题


Is it possible in Java without any extra library to internationalize distances?

I mean it is possible to handle that with date, time, currencies, numbers...

I would have expected to find a NumberFormat.getDistanceInstance or something.

Is there something like that already embedded or should i make my own internationalization system for distances (mostly miles vs kilometers)


回答1:


I would love to hear about such formatter but unfortunately I never did. The problem is, there is no such data in CLDR yet, so it is not to easy to do.

That is to say that people actually think about this for quite a while – see ICU's Measure class. Unfortunately for now, it seems as close you can get is to determine measurement system – see LocaleData and LocaleData.MeasurementSystem.
After that you are on your own. You would need to leave this for translators (they need to actually translate units as well as formatting pattern).




回答2:


No, there's nothing in the JDK to i18n distances, weights and most other measurement units, except for calendars (I know it's not really a unit, but the lunar calendar is quite different from the Gregorian calendar). Even OSs don't have that kind of information.

The only i18n you can do with time, currencies, numbers is the formatting. There's no feature to change the measurement unit.

So you'll need to build your own for distances :S.



来源:https://stackoverflow.com/questions/7659952/internationalization-of-distances-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!