Changeset 15547 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2019-11-30T18:53:35+01:00 (5 years ago)
Author:
Don-vip
Message:

fix #18355 - fix regression in determination of locale/country (introduced in r15395)

Location:
trunk/src/org/openstreetmap/josm/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/I18n.java

    r15506 r15547  
    605605    public static void set(String localeName) {
    606606        if (localeName != null) {
    607             Locale l = LanguageInfo.getLocale(localeName);
     607            Locale l = LanguageInfo.getLocale(localeName, true);
    608608            if (load(LanguageInfo.getJOSMLocaleCode(l))) {
    609609                Locale.setDefault(l);
  • trunk/src/org/openstreetmap/josm/tools/LanguageInfo.java

    r15475 r15547  
    197197     */
    198198    public static Locale getLocale(String localeName) {
     199        return getLocale(localeName, false);
     200    }
     201
     202    /**
     203     * Replies the locale used by Java for a given language code.
     204     *
     205     * Accepts JOSM and Java codes as input.
     206     *
     207     * @param localeName the locale code.
     208     * @param useDefaultCountry if {@code true}, the current locale country will be used if no country is specified
     209     * @return the resulting locale
     210     * @since 15547
     211     */
     212    public static Locale getLocale(String localeName, boolean useDefaultCountry) {
    199213        int country = localeName.indexOf('_');
    200214        int variant = localeName.indexOf('@');
     
    209223            l = new Locale(localeName.substring(0, country), localeName.substring(country + 1));
    210224        } else {
    211             l = new Locale(localeName, Locale.getDefault().getCountry());
     225            l = new Locale(localeName, useDefaultCountry ? Locale.getDefault().getCountry() : "");
    212226        }
    213227        return l;
Note: See TracChangeset for help on using the changeset viewer.