-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Locale handling should be improved #1
Comments
Note that the |
When the current default JVM Locale cannot be found, djunits will fallback to en_US (or en for short).
The Localization (now UnitLocale) class is just providing localization for the units through the corresponding resource bundles; the formatting of the numbers will be done with a NumberFormatter that corresponds to the current default (or given) Locale.
Resource bundles have moved to a subfolder 'locale' in /src/main/resources (/resources in generated jar files), and names of the resource bundles have been shortened (no need to start with 'locale' anymore). |
|
There are two categories of Locales: those for |
Added: getLocalizedDisplayAbbreviation(), getLocalizedTextualAbbreviation(), getLocalizedName(). These will always use the current default locale for the JVM.
This unit tests was commented out because it did not work. Now, it works as intended, and retrieves the names and abbreviations for Durations. Some more tests will be implemented, e.g., the ones using special symbols.
This test code now finally works (it was commented out in the unit tests because it never worked as intended): Locale.setDefault(Locale.US);
assertEquals("Duration", DurationUnit.MINUTE.getLocalizedName());
assertEquals("h", DurationUnit.HOUR.getLocalizedDisplayAbbreviation());
assertEquals("hour", DurationUnit.HOUR.getLocalizedTextualAbbreviation());
Locale.setDefault(new Locale("nl", "NL"));
assertEquals("Tijdsduur", DurationUnit.MINUTE.getLocalizedName());
assertEquals("u", DurationUnit.HOUR.getLocalizedDisplayAbbreviation());
assertEquals("uur", DurationUnit.HOUR.getLocalizedTextualAbbreviation()); |
And add method getLocalizedAbbreviations()
The use of
Locale
andDefaultLocale
in djunits is not optimal. The following issues should (at least) be repaired:Locale
files, such as en-US for the US locale and nl-NL for the Dutch locale.Locale
.DefaultLocale
class. Use the en_US locale files for prefixes when the used Locale does not have prefix files. Still format the numbers according to the used Locale.The text was updated successfully, but these errors were encountered: