A.19 The Package Locales
A locale identifies
a geopolitical place or region and its associated language, which can
be used to determine other internationalization-related characteristics.
The library package Locales has the following declaration:
package Ada.Locales is
type Language_Code is array (1 .. 3) of Character range 'a' .. 'z';
type Country_Code is array (1 .. 2) of Character range 'A' .. 'Z';
Language_Unknown : constant Language_Code := "und";
Country_Unknown : constant Country_Code := "ZZ";
function Language return Language_Code;
function Country return Country_Code;
The active locale
is the locale associated with the partition of the current task.
Some environments define both a system locale and
the locale of the current user. For such environments, the active locale
is that of current user if any; otherwise (as in a partition running
on a server without a user), the system locale should be used.
Language_Code is a lower-case string representation
of an ISO 639-3 alpha-3 code that identifies a language.
common language codes are: "eng" – English; "fra"
– French; "deu" – German; "zho" –
Chinese. These are the same codes as used by POSIX systems. We considered
including constants for the most common languages, but that was rejected
as the likely source of continual arguments about the constant names
and which languages are important enough to include.
Country_Code is an upper-case string representation
of an ISO 3166-1 alpha-2 code that identifies a country.
common country codes are: "CA" – Canada; "FR"
– France; "DE" – Germany; "IT" –
Italy; "ES" – Spain; "GB" – United Kingdom;
"US" – United States. These are the same codes as used
by POSIX systems. We didn't include any country constants for the same
reasons that we didn't include any language constants.
Function Language returns the code of the language
associated with the active locale. If the Language_Code associated with
the active locale cannot be determined from the environment, then Language
Function Country returns the code of the country
associated with the active locale. If the Country_Code associated with
the active locale cannot be determined from the environment, then Country
Extensions to Ada 2005
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe