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
Thelocale
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
-
-
Field Summary
Fields Modifier and Type Field Description static CLocale
CANADA
Useful constant forRegion.CANADA
.static CLocale
CANADA_FRENCH
Useful constant forRegion.CANADA
, forLanguage.FRENCH
.static CLocale
CHINA
Useful constant forRegion.CHINA
.static CLocale
FRANCE
Useful constant forRegion.FRANCE
.static CLocale
GERMANY
Useful constant forRegion.GERMANY
.static CLocale
ITALY
Useful constant forRegion.ITALY
.static CLocale
JAPAN
Useful constant forRegion.JAPAN
.static String
LOCALE_QUERY_STRING_PARAM_KEY
Query string parameter key, used to retrieve the locale value, dynamically.static CLocale
RUSSIA
Useful constant forRegion.RUSSIA
.static CLocale
UK
Useful constant forRegion.UNITED_KINGDOM
.static CLocale
US
Useful constant forRegion.UNITED_STATES
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
static CLocale
getDefault()
Gets the current value of the default locale for this instance.String
getIdentifier()
Returns the locale identifier which consists of a language identifier and extension tags.Language
getLanguage()
Returns the language of the locale.Region
getRegion()
Returns the region of the locale.
It could benull
.Script
getScript()
Returns the script code of the locale.
It could benull
.String
getVariantAndExtension()
Returns the variant and extension parts of the locale.
It could benull
.int
hashCode()
static boolean
mustKeepDefaultsAligned()
Returnstrue
if the default locale must kept aligned with theOptions.setLocale(CLocale)
.static void
setDefault(CLocale locale)
Sets the current value of the default locale for this instance.static void
setMustKeepDefaultsAligned(boolean keptAlignedWithDefaults)
Setstrue
if the default locale must kept aligned with theOptions.setLocale(CLocale)
.String
toString()
-
-
-
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()
Returnstrue
if the default locale must kept aligned with theOptions.setLocale(CLocale)
.- Returns:
true
if the default locale must kept aligned with theOptions.setLocale(CLocale)
-
setMustKeepDefaultsAligned
public static void setMustKeepDefaultsAligned(boolean keptAlignedWithDefaults)
Setstrue
if the default locale must kept aligned with theOptions.setLocale(CLocale)
.- Parameters:
keptAlignedWithDefaults
-true
if 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
-
-