Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Internationalization of distances in java

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)

like image 666
Sebastien Lorber Avatar asked Oct 05 '11 10:10

Sebastien Lorber


People also ask

What is internalization in Java?

Internalization or I18N refers to the capability of an Application to be able to serve users in multiple and different languages. Java has in-built support for Internalization. Java also provides formatting of numbers, currencies and adjustment of date and time accordingly.

How do I change localization in Java?

setDefault(Locale) method. The setDefault(Locale aLocale) method lets your application set a systemwide (actually VM-wide) resource. After you set the default locale with this method, subsequent calls to Locale. getDefault() will return the newly set locale.

Which method is used for getting the language in Internationalisation?

Commonly used methods of Locale classpublic String getDisplayLanguage() it returns the language name of this locale object. public String getDisplayVariant() it returns the variant code for this locale object. public String getISO3Country() it returns the three letter abbreviation for the current locale's country.


1 Answers

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

like image 165
Paweł Dyda Avatar answered Oct 13 '22 20:10

Paweł Dyda