Ignore:
Timestamp:
2015-04-19T13:12:20+02:00 (10 years ago)
Author:
stoecker
Message:

see #11148 - move language stuff to the correct place instead of spreading it in the code

File:
1 edited

Legend:

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

    r8227 r8232  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.tools;
     3
     4import static org.openstreetmap.josm.tools.I18n.trc;
    35
    46import java.util.Locale;
     
    107109     * Replies the locale code used by Java for a given locale.
    108110     *
     111     * @param locale the locale. Replies "en" if null.
     112     * @return the Java code for the given locale
     113     * @since 8232
     114     */
     115    public static String getJavaLocaleCode(String localeName) {
     116        if (localeName == null) return "en";
     117        if ("ca@valencia".equals(localeName)) {
     118            localeName = "ca__valencia";
     119        } else if ("he".equals(localeName)) {
     120            localeName = "iw_IL";
     121        } else if ("id".equals(localeName)) {
     122            localeName = "in";
     123        }
     124        return localeName;
     125    }
     126
     127    /**
     128     * Replies the display string used by JOSM for a given locale.
     129     *
     130     * In most cases returns text replied by {@link Locale#getDisplayName()}, for some
     131     * locales an override is used (i.e. when unsupported by Java).
     132     *
     133     * @param locale the locale. Replies "en" if null.
     134     * @return the display string for the given locale
     135     * @since 8232
     136     */
     137    public static String getDisplayName(Locale locale) {
     138        String full = locale.toString();
     139        if ("ca__valencia".equals(full))
     140            return trc("language", "Valencian");
     141
     142        return locale.getDisplayName();
     143    }
     144
     145    /**
     146     * Replies the locale code used by Java for a given locale.
     147     *
    109148     * In most cases JOSM and Java uses the same codes, but for some exceptions this is needed.
    110149     *
     
    113152     */
    114153    public static Locale getLocale(String localeName) {
    115         if ("ca@valencia".equals(localeName)) {
     154        localeName = getJavaLocaleCode(localeName);
     155        if ("ca__valencia".equals(localeName)) {
    116156            return new Locale("ca", "", "valencia");
    117         }
    118         if ("he".equals(localeName)) {
    119             localeName = "iw_IL";
    120         }
    121         else if ("id".equals(localeName)) {
    122             localeName = "in";
    123157        }
    124158        Locale l;
Note: See TracChangeset for help on using the changeset viewer.