Package com.ibm.icu.impl

Examples of com.ibm.icu.impl.LocaleIDParser


   * @see #getDisplayLanguage()
   * @see #getDisplayLanguage(ULocale)
   * @stable ICU 3.0
   */
  public static String getLanguage(final String localeID) {
    return new LocaleIDParser(localeID).getLanguage();
  }
View Full Code Here


   * @see #getDisplayScript()
   * @see #getDisplayScript(ULocale)
   * @stable ICU 3.0
   */
  public static String getScript(final String localeID) {
    return new LocaleIDParser(localeID).getScript();
  }
View Full Code Here

   * @see #getDisplayCountry()
   * @see #getDisplayCountry(ULocale)
   * @stable ICU 3.0
   */
  public static String getCountry(final String localeID) {
    return new LocaleIDParser(localeID).getCountry();
  }
View Full Code Here

   * @see #getDisplayVariant()
   * @see #getDisplayVariant(ULocale)
   * @stable ICU 3.0
   */
  public static String getVariant(final String localeID) {
    return new LocaleIDParser(localeID).getVariant();
  }
View Full Code Here

   */
  public static String getBaseName(final String localeID) {
    if (localeID.indexOf('@') == -1) {
      return localeID;
    }
    return new LocaleIDParser(localeID).getBaseName();
  }
View Full Code Here

    } else {
      tmpLocaleID = localeID;
    }
    String name = nameCache.get(tmpLocaleID);
    if (name == null) {
      name = new LocaleIDParser(tmpLocaleID).getName();
      nameCache.put(tmpLocaleID, name);
    }
    return name;
  }
View Full Code Here

   *
   * @return an iterator over the keywords in the specified locale, or null if there are no keywords.
   * @stable ICU 3.0
   */
  public static Iterator<String> getKeywords(final String localeID) {
    return new LocaleIDParser(localeID).getKeywords();
  }
View Full Code Here

   *            name of the keyword whose value is desired. Case insensitive.
   * @return String the value of the keyword as a string
   * @stable ICU 3.0
   */
  public static String getKeywordValue(final String localeID, final String keywordName) {
    return new LocaleIDParser(localeID).getKeywordValue(keywordName);
  }
View Full Code Here

   *            the locale id
   * @return the canonicalized id
   * @stable ICU 3.0
   */
  public static String canonicalize(final String localeID) {
    LocaleIDParser parser = new LocaleIDParser(localeID, true);
    String baseName = parser.getBaseName();
    boolean foundVariant = false;

    // formerly, we always set to en_US_POSIX if the basename was empty, but
    // now we require that the entire id be empty, so that "@foo=bar"
    // will pass through unchanged.
    // {dlf} I'd rather keep "" unchanged.
    if (localeID.equals("")) {
      return "";
      //              return "en_US_POSIX";
    }

    // we have an ID in the form xx_Yyyy_ZZ_KKKKK

    initCANONICALIZE_MAP();

    /* convert the variants to appropriate ID */
    for (String[] vals : variantsToKeywords) {
      int idx = baseName.lastIndexOf("_" + vals[0]);
      if (idx > -1) {
        foundVariant = true;

        baseName = baseName.substring(0, idx);
        if (baseName.endsWith("_")) {
          baseName = baseName.substring(0, --idx);
        }
        parser.setBaseName(baseName);
        parser.defaultKeywordValue(vals[1], vals[2]);
        break;
      }
    }

    /* See if this is an already known locale */
    for (String[] vals : CANONICALIZE_MAP) {
      if (vals[0].equals(baseName)) {
        foundVariant = true;

        parser.setBaseName(vals[1]);
        if (vals[2] != null) {
          parser.defaultKeywordValue(vals[2], vals[3]);
        }
        break;
      }
    }

    /* total mondo hack for Norwegian, fortunately the main NY case is handled earlier */
    if (!foundVariant) {
      if (parser.getLanguage().equals("nb") && parser.getVariant().equals("NY")) {
        parser.setBaseName(lscvToID("nn", parser.getScript(), parser.getCountry(), null));
      }
    }

    return parser.getName();
  }
View Full Code Here

   *            the value to add/set, or null to remove this particular keyword.
   * @return the updated locale id
   * @stable ICU 3.2
   */
  public static String setKeywordValue(final String localeID, final String keyword, final String value) {
    LocaleIDParser parser = new LocaleIDParser(localeID);
    parser.setKeywordValue(keyword, value);
    return parser.getName();
  }
View Full Code Here

TOP

Related Classes of com.ibm.icu.impl.LocaleIDParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.