Class CLocale


  • public final class CLocale
    extends Object
    Unicode represents locales with a string, called a locale identifier.
    The locale identifier consists of a language identifier and extension tags.
    Language identifiers are the core of the locale, consisting of language, script, and region subtags.
    Additional information about the locale is stored in the optional extension tags.
    Extension tags hold information about locale aspects such as calendar type, clock type, and numbering system type.
    A Unicode BCP 47 locale identifier consists of
    • a language code
    • (optionally) a script code,
    • (optionally) a region (or country) code
    • (optionally) one or more variant codes
    • (optionally) one or more extension sequences

    See MDN page for more details.
    LOCALE auto recognition
    The locale client property can be specified using either a meta tag, as part of the query string in the host page’s URL or from default platform locale.
    If all cases are specified, the query string takes precedence, then meta data and finally the navigator language.
    Author:
    Andrea "Stock" Stocchero
    • Method Detail

      • getIdentifier

        public String getIdentifier()
        Returns the locale identifier which consists of a language identifier and extension tags.
        Returns:
        the locale identifier which consists of a language identifier and extension tags
      • getLanguage

        public Language getLanguage()
        Returns the language of the locale.
        Returns:
        the language of the locale
      • getScript

        public Script getScript()
        Returns the script code of the locale.
        It could be null.
        Returns:
        the script code of the locale.
        It could be null.
      • getRegion

        public Region getRegion()
        Returns the region of the locale.
        It could be null.
        Returns:
        the region of the locale.
        It could be null.
      • getVariantAndExtension

        public String getVariantAndExtension()
        Returns the variant and extension parts of the locale.
        It could be null.
        Returns:
        the variant and extension parts of the locale.
        It could be null.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • setMustKeepDefaultsAligned

        public static void setMustKeepDefaultsAligned​(boolean keptAlignedWithDefaults)
        Sets true if the default locale must kept aligned with the Options.setLocale(CLocale).
        Parameters:
        keptAlignedWithDefaults - true if the default locale must kept aligned with the Options.setLocale(CLocale)
      • setDefault

        public static void setDefault​(CLocale locale)
        Sets the current value of the default locale for this instance.
        Parameters:
        locale - the default locale for this instance
      • getDefault

        public static CLocale getDefault()
        Gets the current value of the default locale for this instance.
        Returns:
        the default locale for this instance