Starting with V40, locale.library maintains a global environment variable called "Language" which contains the name of the current default language as used in the system. This is the name of the language associated with the Locale structure returned by
OpenLocale(NULL).
From a shell:
Echo "The system language currently is: $Language"
will print the name of the current system language ("english",
"français", etc)
locale.library provides an ARexx function host interface that enables ARexx programs to take advantage of system localization. The functions provided by the interface are directly related to the functions described herein, with the differences mostly being in the way they are called.
The function host library vector is located at offset -30 from the library. This is the value you provide to ARexx in the AddLib() function call.
/* localetest.rexx */
/* Make sure locale is loaded as a function host */
IF ~SHOW(L,'locale.library') THEN DO
CALL ADDLIB('locale.library',0,-30)
END;
say
ConvToLower("A");
say
ConvToUpper("b");
say IsAlpha("1");
catalog =
OpenCatalog("sys/workbench.catalog","english",0);
say
GetCatalogStr(catalog,34,"default");
say
CloseCatalog(catalog);
say
StrnCmp("test","test",2);
The Locale structure is the main public structure provided by locale.library. The structure is defined in <libraries/locale.h> and consists of the following fields:
loc_LocaleName (STRPTR)- Locale's name.
- loc_LanguageName (STRPTR)
-
The language of the driver bound to this locale.
- loc_PrefLanguages (STRPTR[10])
-
The ordered list of preferred languages for this locale.
- loc_Flags (ULONG)
-
Locale flags. Currently always 0.
- loc_CodeSet (ULONG)
-
Specifies the code set required by this locale. Before V46, this value was always 0. Since V46, this is the IANA charset number (see L:CharSets/character-sets). For compatibility, 0 should be handled as equal to 4, both meaning ISO-8859-1 Latin1.
- loc_CountryCode (ULONG)
-
The international country code.
- loc_TelephoneCode (ULONG)
-
The international telephone code for the country.
- loc_GMTOffset (LONG)
-
The offset in minutes of the current location from GMT. Positive indicates a Westerly direction from GMT, negative Easterly.
- loc_MeasuringSystem (UBYTE)
-
The measuring system being used.
- loc_DateTimeFormat (STRPTR)
-
The date and time format string, ready to pass to FormatDate()
- loc_DateFormat (STRPTR)
-
The date format string.
- loc_TimeFormat (STRPTR)
-
The time format string.
loc_ShortDateTimeFormat (STRPTR) -
The short date and time format string, ready to pass to
FormatDate()
- loc_ShortDateFormat (STRPTR)
-
The short date format string.
- loc_ShortTimeFormat (STRPTR)
-
The short time format string.
- loc_DecimalPoint (STRPTR)
-
The decimal point character used to format non-monetary quantities.
- loc_GroupSeparator (STRPTR)
-
The characters used to separate groups of digits before the decimal-point character in formatted non-monetary quantities.
- loc_FracGroupSeparator (STRPTR)
-
The characters used to separate groups of digits after the decimal-point character in formatted non-monetary quantities.
- loc_Grouping (STRPTR)
-
A string whose elements indicate the size of each group of digits before the decimal-point character in formatted non-monetary quantities.
- loc_FracGrouping (STRPTR)
-
A string whose elements indicate the size of each group of digits after the decimal-point character in formatted non-monetary quantities.
- loc_MonDecimalPoint (STRPTR)
-
The decimal-point used to format monetary quantities.
- loc_MonGroupSeparator (STRPTR)
-
The separator for groups of digits before the decimal-point in monetary quantities.
- loc_MonFracGroupSeparator (STRPTR)
-
The separator for groups of digits after the decimal-point in monetary quantities.
- loc_MonGrouping (STRPTR)
-
A string whose elements indicate the size of each group of digits before the decimal-point character in monetary quantities.
- loc_MonFracGrouping (STRPTR)
-
A string whose elements indicate the size of each group of digits after the decimal-point character in monetary quantities.
- loc_MonFracDigits (UBYTE)
-
The number of fractional digits (those after the decimal-point) to be displayed in a formatted monetary quantity.
- loc_MonIntFracDigits (UBYTE)
-
The number of fractional digits (those after the decimal-point) to be displayed in an internationally formatted monetary quantity.
- loc_MonCS (STRPTR)
-
The local currency symbol applicable to the current locale.
- loc_MonSmallCS (STRPTR)
-
The currency symbol for small amounts.
- loc_MonIntCS (STRPTR)
-
The international currency symbol applicable to the current locale. The first three characters contain the alphabetic international currency symbol in accordance with those specified in ISO 4217 Codes for the Representation of Currency and Funds. The fourth character (immediately preceding the NULL) is the character used to separate the international currency symbol from the monetary quantity.
- loc_MonPositiveSign (STRPTR)
-
The string used to indicate a non-negative monetary quantity.
- loc_MonPositiveSpaceSep (UBYTE)
-
Specifies the number of spaces separating the currency symbol from the non-negative monetary quantity.
- loc_MonPositiveSignPos (UBYTE)
-
Set to a value indicating the positioning of loc_MonPositiveSign for a non-negative monetary quantity.
- loc_MonPositiveCSPos (UBYTE)
-
Set to 1 or 0 if loc_MonCS respectively precedes or succeeds the value for a non-negative monetary quantity.
- loc_MonNegativeSign (STRPTR)
-
The string used to indicate a negative monetary quantity.
- loc_MonNegativeSpaceSep (UBYTE)
-
Specifies the number of spaces separating the currency symbol from the negative monetary quantity.
- loc_MonNegativeSignPos (UBYTE)
-
Set to a value indicating the positioning of loc_MonNegativeSign for a negative monetary quantity.
- loc_MonNegativeCSPos (UBYTE)
-
Set to 1 or 0 if loc_MonCS respectively precedes or succeeds the value for a negative monetary quantity.
The grouping tables pointed to by loc_Grouping, loc_FracGrounping, loc_MonGrouping, and loc_MonFracGrouping contain a stream of bytes with the following values:
-
255 No further grouping is to be performed.
-
0 The previous element is to be repeatedly used for the remainder of the digits.
-
1..254 The integer value is the number of digits that comprise the current group. The next element is examined to determine the size of the next group of digits before the current group.
The values of loc_MonPositiveSignPos and loc_MonNegativeSignPos are interpreted according to the following:
-
0 Parentheses surround the quantity and currency symbol
-
1 The sign string precedes the quantity and currency symbol
-
2 The sign string succeeds the quantity and currency symbol
-
3 The sign string immediately precedes the currency symbol
-
4 The sign string immediately succeeds the currency symbol.