Ignore:
Timestamp:
2015-02-21T15:27:40+01:00 (8 years ago)
Author:
stoecker
Message:

proper handling of language infor for maps name and description

File:
1 edited

Legend:

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

    r7509 r8091  
    123123    }
    124124
     125    /**
     126     * Check if a new language is better than a previous existing. Can be used in classes where
     127     * multiple user supplied language marked strings appear and the best one is searched. Following
     128     * priorities: current language, english, any other
     129     *
     130     * @param oldLanguage the language code of the existing string
     131     * @param newLanguage the language code of the new string
     132     * @return true if new one is better
     133     * @since 8091
     134     */
     135    public static boolean isBetterLanguage(String oldLanguage, String newLanguage) {
     136        if (oldLanguage == null)
     137            return true;
     138        String want = getJOSMLocaleCode();
     139        return want.equals(newLanguage) || (!want.equals(oldLanguage) && newLanguage.startsWith("en"));
     140    }
     141   
     142    /**
     143     * Replies the language prefix for use in XML elements (with a dot appended).
     144     *
     145     * @return the XML language prefix
     146     * @see #getJOSMLocaleCode()
     147     */
    125148    public static String getLanguageCodeXML() {
    126149        return getJOSMLocaleCode()+".";
    127150    }
    128151
     152    /**
     153     * Replies the language prefix for use in manifests (with an underscore appended).
     154     *
     155     * @return the manifest language prefix
     156     * @see #getJOSMLocaleCode()
     157     */
    129158    public static String getLanguageCodeManifest() {
    130159        return getJOSMLocaleCode()+"_";
Note: See TracChangeset for help on using the changeset viewer.