开发者

Internationalization of distances in java

开发者 https://www.devze.com 2023-04-11 01:48 出处:网络
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...

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 internationaliz开发者_Go百科ation system for distances (mostly miles vs kilometers)


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).


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号