Package org.pepstock.charba.client.intl
Class CLocale
- java.lang.Object
-
- org.pepstock.charba.client.intl.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
Thelocaleclient 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
-
-
Field Summary
Fields Modifier and Type Field Description static CLocaleCANADAUseful constant forRegion.CANADA.static CLocaleCANADA_FRENCHUseful constant forRegion.CANADA, forLanguage.FRENCH.static CLocaleCHINAUseful constant forRegion.CHINA.static CLocaleFRANCEUseful constant forRegion.FRANCE.static CLocaleGERMANYUseful constant forRegion.GERMANY.static CLocaleITALYUseful constant forRegion.ITALY.static CLocaleJAPANUseful constant forRegion.JAPAN.static StringLOCALE_QUERY_STRING_PARAM_KEYQuery string parameter key, used to retrieve the locale value, dynamically.static CLocaleRUSSIAUseful constant forRegion.RUSSIA.static CLocaleUKUseful constant forRegion.UNITED_KINGDOM.static CLocaleUSUseful constant forRegion.UNITED_STATES.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)static CLocalegetDefault()Gets the current value of the default locale for this instance.StringgetIdentifier()Returns the locale identifier which consists of a language identifier and extension tags.LanguagegetLanguage()Returns the language of the locale.RegiongetRegion()Returns the region of the locale.
It could benull.ScriptgetScript()Returns the script code of the locale.
It could benull.StringgetVariantAndExtension()Returns the variant and extension parts of the locale.
It could benull.inthashCode()static booleanmustKeepDefaultsAligned()Returnstrueif the default locale must kept aligned with theOptions.setLocale(CLocale).static voidsetDefault(CLocale locale)Sets the current value of the default locale for this instance.static voidsetMustKeepDefaultsAligned(boolean keptAlignedWithDefaults)Setstrueif the default locale must kept aligned with theOptions.setLocale(CLocale).StringtoString()
-
-
-
Field Detail
-
FRANCE
public static final CLocale FRANCE
Useful constant forRegion.FRANCE.
-
GERMANY
public static final CLocale GERMANY
Useful constant forRegion.GERMANY.
-
ITALY
public static final CLocale ITALY
Useful constant forRegion.ITALY.
-
JAPAN
public static final CLocale JAPAN
Useful constant forRegion.JAPAN.
-
CHINA
public static final CLocale CHINA
Useful constant forRegion.CHINA.
-
UK
public static final CLocale UK
Useful constant forRegion.UNITED_KINGDOM.
-
US
public static final CLocale US
Useful constant forRegion.UNITED_STATES.
-
CANADA
public static final CLocale CANADA
Useful constant forRegion.CANADA.
-
CANADA_FRENCH
public static final CLocale CANADA_FRENCH
Useful constant forRegion.CANADA, forLanguage.FRENCH.
-
RUSSIA
public static final CLocale RUSSIA
Useful constant forRegion.RUSSIA.
-
LOCALE_QUERY_STRING_PARAM_KEY
public static final String LOCALE_QUERY_STRING_PARAM_KEY
Query string parameter key, used to retrieve the locale value, dynamically.- See Also:
- Constant Field Values
-
-
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 benull.- Returns:
- the script code of the locale.
It could benull.
-
getRegion
public Region getRegion()
Returns the region of the locale.
It could benull.- Returns:
- the region of the locale.
It could benull.
-
getVariantAndExtension
public String getVariantAndExtension()
Returns the variant and extension parts of the locale.
It could benull.- Returns:
- the variant and extension parts of the locale.
It could benull.
-
mustKeepDefaultsAligned
public static boolean mustKeepDefaultsAligned()
Returnstrueif the default locale must kept aligned with theOptions.setLocale(CLocale).- Returns:
trueif the default locale must kept aligned with theOptions.setLocale(CLocale)
-
setMustKeepDefaultsAligned
public static void setMustKeepDefaultsAligned(boolean keptAlignedWithDefaults)
Setstrueif the default locale must kept aligned with theOptions.setLocale(CLocale).- Parameters:
keptAlignedWithDefaults-trueif the default locale must kept aligned with theOptions.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
-
-