Interface GwtLocale

All Superinterfaces:
java.lang.Comparable<GwtLocale>

public interface GwtLocale
extends java.lang.Comparable<GwtLocale>
Class representing GWT locales and conversion to/from other formats.

These locales correspond to BCP47.

  • Field Summary

    Fields
    Modifier and Type Field Description
    static java.lang.String DEFAULT_LOCALE  
  • Method Summary

    Modifier and Type Method Description
    int compareTo​(GwtLocale o)
    The default comparison is a lexical ordering.
    java.util.List<GwtLocale> getAliases()
    Returns the list of aliases for this locale.
    java.lang.String getAsString()
    Returns the locale as a fixed-format string suitable for use in searching for localized resources.
    GwtLocale getCanonicalForm()
    Returns this locale in canonical form.
    java.util.List<GwtLocale> getCompleteSearchList()
    Returns the complete list of locales to search for the current locale.
    java.util.List<GwtLocale> getInheritanceChain()
    Returns a list of locales to search for, in order of preference.
    java.lang.String getLanguage()
    Returns the language portion of the locale, or null if none.
    java.lang.String getLanguageNotNull()
    Returns the language portion of the locale, or the empty string if none.
    java.lang.String getRegion()
    Returns the region portion of the locale, or null if none.
    java.lang.String getRegionNotNull()
    Returns the region portion of the locale, or the empty string if none.
    java.lang.String getScript()
    Returns the script portion of the locale, or null if none.
    java.lang.String getScriptNotNull()
    Returns the script portion of the locale, or the empty string if none.
    java.lang.String getVariant()
    Returns the variant portion of the locale, or null if none.
    java.lang.String getVariantNotNull()
    Returns the variant portion of the locale, or the empty string if none.
    boolean inheritsFrom​(GwtLocale parent)
    Returns true if this locale inherits from the specified locale.
    boolean isDefault()
    Returns true if this is the default or root locale.
    java.lang.String toString()
    Returns a human readable string -- "default" or the same as getAsString().
    boolean usesSameScript​(GwtLocale other)
    Checks if this locale uses the same script as another locale.
  • Field Details

  • Method Details

    • compareTo

      int compareTo​(GwtLocale o)
      The default comparison is a lexical ordering.
      Specified by:
      compareTo in interface java.lang.Comparable<GwtLocale>
    • getAliases

      java.util.List<GwtLocale> getAliases()
      Returns the list of aliases for this locale. The canonical form of the current locale is always first on the list.

      Language/region codes have changed over time, so some systems continue to use the older codes. Aliases allow GWT to use the official Unicode CLDR locales while still interoperating with such systems.

      Returns:
      alias list
    • getAsString

      java.lang.String getAsString()
      Returns the locale as a fixed-format string suitable for use in searching for localized resources. The format is language_Script_REGION_VARIANT, where language is a 2-8 letter code (possibly with 3-letter extensions), script is a 4-letter code with an initial capital letter, region is a 2-character country code or a 3-digit region code, and variant is a 5-8 character (may be 4 if the first character is numeric) code. If a component is missing, its preceding _ is also omitted. If this is the default locale, the empty string will be returned.
      Returns:
      String representing locale
    • getCanonicalForm

      GwtLocale getCanonicalForm()
      Returns this locale in canonical form.
      • Deprecated language/region tags are replaced with official versions
      • Default scripts are removed (including region-specific defaults for Chinese)
      • no/nb/nn are normalized
      • Default region for zh_Hans and zh_Hant if none specified
      Returns:
      GwtLocale instance
    • getCompleteSearchList

      java.util.List<GwtLocale> getCompleteSearchList()
      Returns the complete list of locales to search for the current locale. This list will always start with the canonical form of this locale, and end with "default", and include all appropriate aliases along the way.
      Returns:
      search list
    • getInheritanceChain

      java.util.List<GwtLocale> getInheritanceChain()
      Returns a list of locales to search for, in order of preference. The current locale is always first on the list. Aliases are not included in the list -- use getAliases() to expand those.
      Returns:
      inheritance list
    • getLanguage

      java.lang.String getLanguage()
      Returns the language portion of the locale, or null if none.
    • getLanguageNotNull

      java.lang.String getLanguageNotNull()
      Returns the language portion of the locale, or the empty string if none.
    • getRegion

      java.lang.String getRegion()
      Returns the region portion of the locale, or null if none.
    • getRegionNotNull

      java.lang.String getRegionNotNull()
      Returns the region portion of the locale, or the empty string if none.
    • getScript

      java.lang.String getScript()
      Returns the script portion of the locale, or null if none.
    • getScriptNotNull

      java.lang.String getScriptNotNull()
      Returns the script portion of the locale, or the empty string if none.
    • getVariant

      java.lang.String getVariant()
      Returns the variant portion of the locale, or null if none.
    • getVariantNotNull

      java.lang.String getVariantNotNull()
      Returns the variant portion of the locale, or the empty string if none.
    • inheritsFrom

      boolean inheritsFrom​(GwtLocale parent)
      Returns true if this locale inherits from the specified locale. Note that locale.inheritsFrom(locale) is false -- if you want that to be true, you should just use locale.getInheritanceChain().contains(x).
      Parameters:
      parent - locale to test against
      Returns:
      true if parent is an ancestor of this locale
    • isDefault

      boolean isDefault()
      Returns true if this is the default or root locale.
    • toString

      java.lang.String toString()
      Returns a human readable string -- "default" or the same as getAsString().
      Overrides:
      toString in class java.lang.Object
    • usesSameScript

      boolean usesSameScript​(GwtLocale other)
      Checks if this locale uses the same script as another locale.
      Parameters:
      other -
      Returns:
      true if the scripts are the same