Ignore:
Timestamp:
2014-12-27T00:08:31+01:00 (8 years ago)
Author:
Don-vip
Message:

Enable CLDR and add support for Khmer language (km) for Java 8 users

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

Legend:

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

    r7893 r7894  
    3939    }
    4040
     41    /**
     42     * Enumeration of possible plural modes.
     43     * See <a href="http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html">CLDR</a>
     44     * for a complete list.
     45     * @see #pluralEval
     46     */
    4147    private enum PluralMode {
    42         MODE_NOTONE, MODE_NONE, MODE_GREATERONE,
    43         MODE_CS/*, MODE_AR*/, MODE_PL/*, MODE_RO*/, MODE_RU, MODE_SK/*, MODE_SL*/}
     48        /** Plural = Not 1. This is the default for many languages, including English: 1 day, but 0 days or 2 days. */
     49        MODE_NOTONE,
     50        /** No plural. Mainly for Asian languages (Indonesian, Chinese, Japanese, ...) */
     51        MODE_NONE,
     52        /** Plural = Greater than 1. For some latin languages (French, Brazilian Portuguese) */
     53        MODE_GREATERONE,
     54        /* Special mode for
     55         * <a href="http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html#ar">Arabic</a>.*
     56        MODE_AR,*/
     57        /** Special mode for
     58         * <a href="http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html#cs">Czech</a>. */
     59        MODE_CS,
     60        /** Special mode for
     61         * <a href="http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html#pl">Polish</a>. */
     62        MODE_PL,
     63        /* Special mode for
     64         * <a href="http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html#ro">Romanian</a>.*
     65        MODE_RO,*/
     66        /** Special mode for
     67         * <a href="http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html#ru">Russian</a>. */
     68        MODE_RU,
     69        /** Special mode for
     70         * <a href="http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html#sk">Slovak</a>. */
     71        MODE_SK,
     72        /* Special mode for
     73         * <a href="http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html#sl">Slovenian</a>.*
     74        MODE_SL,*/
     75    }
     76
    4477    private static PluralMode pluralMode = PluralMode.MODE_NOTONE; /* english default */
    4578    private static String loadedCode = "en";
     
    353386     */
    354387    public static void init() {
     388        // Enable CLDR locale provider on Java 8 to get additional languages, such as Khmer.
     389        // http://docs.oracle.com/javase/8/docs/technotes/guides/intl/enhancements.8.html#cldr
     390        // This can be removed after we switch to a minimal version of Java that enables CLDR by default
     391        // or includes all languages we need in the JRE. See http://openjdk.java.net/jeps/8043554 for Java 9
     392        Utils.updateSystemProperty("java.locale.providers", "JRE,CLDR");
     393
    355394        //languages.put("ar", PluralMode.MODE_AR);
    356395        languages.put("bg", PluralMode.MODE_NOTONE);
     
    374413        languages.put("it", PluralMode.MODE_NOTONE);
    375414        languages.put("ja", PluralMode.MODE_NONE);
     415        if (Main.isJava8orLater()) {
     416            // Java 8 and later code
     417            languages.put("km", PluralMode.MODE_NONE);
     418        }
    376419        //languages.put("nb", PluralMode.MODE_NOTONE);
    377420        languages.put("nl", PluralMode.MODE_NOTONE);
     
    649692        case MODE_NOTONE: /* bg, da, de, el, en, en_GB, es, et, eu, fi, gl, is, it, iw_IL, nb, nl, sv */
    650693            return ((n != 1) ? 1 : 0);
    651         case MODE_NONE: /* ja, tr, zh_CN, zh_TW */
     694        case MODE_NONE: /* id, ja, km, tr, zh_CN, zh_TW */
    652695            return 0;
    653696        case MODE_GREATERONE: /* fr, pt_BR */
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java

    r7846 r7894  
    1919import org.openstreetmap.josm.Main;
    2020import org.openstreetmap.josm.actions.OpenFileAction.OpenFileTask;
    21 import org.openstreetmap.josm.data.Preferences;
    2221import org.openstreetmap.josm.io.OsmTransferException;
    2322import org.xml.sax.SAXException;
     
    3736        // And will not work when one of the system independent LAFs is used.
    3837        // They just insist on painting themselves...
    39         Preferences.updateSystemProperty("apple.laf.useScreenMenuBar", "true");
     38        Utils.updateSystemProperty("apple.laf.useScreenMenuBar", "true");
    4039        migrateOldDirectory();
    4140    }
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r7869 r7894  
    11441144        return new Pair<>(noThreads, pool);
    11451145    }
     1146
     1147    /**
     1148     * Updates a given system property.
     1149     * @param key The property key
     1150     * @param value The property value
     1151     * @return the previous value of the system property, or {@code null} if it did not have one.
     1152     * @since 7894
     1153     */
     1154    public static String updateSystemProperty(String key, String value) {
     1155        if (value != null) {
     1156            String old = System.setProperty(key, value);
     1157            if (!key.toLowerCase().contains("password")) {
     1158                Main.debug("System property '"+key+"' set to '"+value+"'. Old value was '"+old+"'");
     1159            } else {
     1160                Main.debug("System property '"+key+"' changed.");
     1161            }
     1162            return old;
     1163        }
     1164        return null;
     1165    }
    11461166}
Note: See TracChangeset for help on using the changeset viewer.