A Locale object represents a specific geographical, political, or
cultural region.
Once you've created a Locale you can query it for information about
itself. Use getCountry to get the ISO Country Code and getLanguage to
get the ISO Language Code. You can use getDisplayCountry to get the name
of the country suitable for displaying to the user. Similarly, you can
use getDisplayLanguage to get the name of the language suitable for
displaying to the user. Interestingly, the getDisplayXXX methods are
themselves locale- sensitive and have two versions: one that uses the
default locale and one that uses the locale specified as an argument.
The language argument to constructors is a valid ISO Language Code.
These codes are the lower-case two-letter codes as defined by ISO-639.
You can find a full list of these codes at a number of sites, such as: http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt
The language argument to constructors is a valid ISO Country Code.
These codes are the upper-case two-letter codes as defined by ISO-3166.
You can find a full list of these codes at a number of sites, such as: http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html
One constructor requires a third argument--the Variant. The Variant
codes are vendor and browser-specific. For example, use WIN for Windows,
MAC for Macintosh, and POSIX for POSIX. Where there are two variants,
separate them with an underscore, and put the most important one first.
For example, a Traditional Spanish collation might construct a locale
with parameters for language, country and variant as: "es", "ES",
"Traditional_WIN".
Your locale:
print Locale.getDefault.getDisplayCountry
print Locale.getDefault.getDisplayLanguage
print Locale.getDefault.getDisplayName
print Locale.getDefault.getDisplayVariant
A simple example:
$loc = Locale.create("ro", "RO")
print $loc.getDisplayCountry
print $loc.getDisplayLanguage
print $loc.getDisplayName
print $loc.getDisplayVariant
With the result ---
România
românã
românã (România)
Another simple example:
$roLoc = Locale.create("fr", "FR")
$usLoc = Locale.create("en", "US")
print $usLoc.getDisplayCountry($roLoc)
print $usLoc.getDisplayLanguage($roLoc)
print $usLoc.getDisplayName($roLoc)
print $usLoc.getDisplayVariant($roLoc)
With the result ---
Etats-Unis
anglais
anglais (Etats-Unis)
Methods inherited from: Concept
cloneConcept, extendsConcept, fromXML, getAllInheritedConcepts, getConceptAttribute, getConceptAttributeField, getConceptAttributeFields, getConceptAttributes, getConceptConstructors, getConceptElement, getConceptElementField, getConceptElementFields, getConceptElements, getConceptLabel, getConceptMethod, getConceptMethods, getConceptOperators, getConceptType, getErrorHandler, getInheritedConcepts, getResourceURI, hasConceptAttribute, hasConceptElement, hasConceptMethod, hasPath, isHidden, loadContent, setConceptLabel, setErrorHandler, setHidden, setShowEmpty, showEmpty, toTXT, toXML, setResourceURI |
|
Parameters: |
$language : | lowercase two-letter ISO-639 code. |
$country : | uppercase two-letter ISO-3166 code. |
$variant : | vendor and browser specific code. See description |
|
Construct a locale from language, country, variant. NOTE:
ISO
639 is not a stable standard; some of the language codes it
defines (specifically iw, ji, and in) have changed. This
constructor accepts both the old codes (iw, ji, and in) and the
new codes (he, yi, and id), but all other API on Locale will
return only the OLD codes.
Parameters: |
$language : | lowercase two-letter ISO-639 code. |
$country : | uppercase two-letter ISO-3166 code. |
|
Construct a locale from language, country. To create a locale
that only identifies a language, use "" for the country.NOTE:
ISO 639 is not a stable standard; some of the language codes it
defines (specifically iw, ji, and in) have changed. This
constructor accepts both the old codes (iw, ji, and in) and the
new codes (he, yi, and id), but all other API on Locale will
return only the OLD codes.
Constructs a localte with the default value.
Returns a list of all installed locales.
print Locale.getAvailableLocales
-- the result is --
en
en_US
uk
uk_UA
Returns the country/region code for this locale, which will
either be the empty string or an upercase ISO 3166 2-letter
code.
$l = Locale.create
print $l.getCountry
-- the result is --
US
Gets the current value of the default locale for the current
instance of the MN8.
MN8 sets the default locale during startup based on the host
environment. It is used by many locale-sensitive methods if no
locale is explicitly specified. It can be changed using the
setDefault method.
print Locale.getDefault
-- the result is --
en_US
Returns a name for the locale's country that is appropriate for
display to the user. If possible, the name returned will be
localized for the default locale. For example, if the locale is
fr_FR and the default locale is en_US, getDisplayCountry() will
return "France"; if the locale is en_US and the default locale
is fr_FR, getDisplayLanguage() will return "Etats-Unis". If the
name returned cannot be localized for the default locale, (say,
we don't have a Japanese name for Croatia), this function falls
back on the English name, and uses the ISO code as a last-resort
value. If the locale doesn't specify a country, this function
returns the empty string.
$l = Locale.create
print $l.getDisplayCountry
-- the result is --
United States
Parameters: |
$inLocale : | the country name will be localized according to
this locale. |
|
Returns a name for the locale's country that is appropriate for
display to the user. If possible, the name returned will be
localized according to inLocale. For example, if the locale is
fr_FR and inLocale is en_US, getDisplayCountry() will return
"France"; if the locale is en_US and inLocale is fr_FR,
getDisplayLanguage() will return "Etats-Unis". If the name
returned cannot be localized according to inLocale. (say, we
don't have a Japanese name for Croatia), this function falls
back on the default locale, on the English name, and finally on
the ISO code as a last-resort value. If the locale doesn't
specify a country, this function returns the empty string.
$us = Locale.create
$ro = Locale.create("ro", "RO")
print $ro.getDisplayCountry($us)
-- the result is --
Romania
Returns a name for the locale's language that is appropriate for
display to the user. If possible, the name returned will be
localized for the default locale. For example, if the locale is
fr_FR and the default locale is en_US, getDisplayLanguage() will
return "French"; if the locale is en_US and the default locale
is fr_FR, getDisplayLanguage() will return "anglais". If the
name returned cannot be localized for the default locale, (say,
we don't have a Japanese name for Croatian), this function falls
back on the English name, and uses the ISO code as a last-resort
value. If the locale doesn't specify a language, this function
returns the empty string.
$l = Locale.create
print $l.getDisplayLanguage
-- the result is --
English
Parameters: |
$inLocale : | the language name will be localized according to
this locale. |
|
Returns a name for the locale's language that is appropriate for
display to the user. If possible, the name returned will be
localized according to inLocale. For example, if the locale is
fr_FR and inLocale is en_US, getDisplayLanguage() will return
"French"; if the locale is en_US and inLocale is fr_FR,
getDisplayLanguage() will return "anglais". If the name returned
cannot be localized according to inLocale, (say, we don't have a
Japanese name for Croatian), this function falls back on the
default locale, on the English name, and finally on the ISO code
as a last-resort value. If the locale doesn't specify a
language, this function returns the empty string.
$us = Locale.create
$ro = Locale.create("ro", "RO")
print $ro.getDisplayLanguage($us)
-- the result is --
Romanian
Returns a name for the locale that is appropriate for display
to the user. This will be the values returned by
getDisplayLanguage(), getDisplayCountry(), and
getDisplayVariant() assembled into a single string. The display
name will have one of the following forms:
language (country, variant)
language (country)
language (variant)
country (variant)
language
country
variant
depending on which fields are specified in the locale. If the
language, country, and variant fields are all empty, this
function returns the empty string.
$l = Locale.create
print $l.getDisplayName
-- the result is --
English (United States)
Parameters: |
$inLocale : | the name will be localized according to
this locale. |
|
Returns a name for the locale that is appropriate for display
to the user. This will be the values returned by
getDisplayLanguage(), getDisplayCountry(), and
getDisplayVariant() assembled into a single string. The display
name will have one of the following forms:
language (country, variant)
language (country)
language (variant)
country (variant)
language
country
variant
depending on which fields are specified in the locale. If the
language, country, and variant fields are all empty, this
function returns the empty string.
$us = Locale.create
$ro = Locale.create("ro", "RO")
print $ro.getDisplayName($us)
-- the result is --
Romanian (Romania)
Returns a name for the locale's variant code that is appropriate
for display to the user. If possible, the name will be localized
for the default locale. If the locale doesn't specify a variant
code, this function returns the empty string.
$l = Locale.create
print $l.getDisplayVariant
Parameters: |
$inLocale : | the variant will be localized according to
this locale. |
|
Returns a name for the locale's variant code that is appropriate
for display to the user. If possible, the name will be localized
for inLocale. If the locale doesn't specify a variant code, this
function returns the empty string.
$us = Locale.create
$ro = Locale.create("ro", "RO")
print $ro.getDisplayVariant($us)
Returns a three-letter abbreviation for this locale's country.
If the locale doesn't specify a country, this will be tbe the
empty string. Otherwise, this will be an uppercase ISO 3166 3-
letter country code.
$l = Locale.create
print $l.getISO3Country
-- the result is --
USA
Returns a three-letter abbreviation for this locale's language.
If the locale doesn't specify a language, this will be the empty
string. Otherwise, this will be a lowercase ISO 639-2/T language code. The ISO 639-2 language codes can be found on-line at ftp://dkuug.dk/i18n/iso-639-2.txt
$l = Locale.create
print $l.getISO3Language
-- the result is --
eng
Returns a series of strings of all 2-letter country codes
defined in ISO 3166. Can be used to create Locales.
print Locale.getISOCountries
-- the result is --
AD
AE
AF
AG
AI
AL
AM
...
Returns a series of strings of all 2-letter language codes defined in ISO
639. Can be used to create Locales. [NOTE:
ISO 639 is not a
stable standard-- some languages' codes have changed. The list
this function returns includes both the new and the old codes
for the languages whose codes have changed.]
print Locale.getISOLanguages
-- the result is --
aa
ab
af
am
ar
as
ay
...
Returns the language code for this locale, which will either be
the empty string or a lowercase ISO 639 code.
NOTE:
ISO 639 is not a stable standard-- some
languages' codes have changed. Locale's constructor recognizes
both the new and the old codes for the languages whose codes
have changed, but this function always returns the old code
$l = Locale.create
print $l.getLanguage
-- the result is --
en
Returns the variant code for this locale.
$l = Locale.create
print $l.getVariant
-- the result is --
en
Parameters: |
$newLocale : | the new locale. |
|
Sets the default locale for this instance of the MN8.
This does not affect the host locale.
$ro = Locale.create("ro", "RO")
Locale.setDefault($ro)
$l = Locale.create
$l.getDisplayCountry
-- the result is --
Romania