The m17n Library 1.8.4
|
Locale objects and API for them. More...
Typedefs | |
typedef struct MLocale | MLocale |
struct MLocale . | |
Functions | |
MPlist * | mlanguage_list (void) |
List 3-letter language codes. | |
MSymbol | mlanguage_code (MSymbol language, int len) |
Get a language code. | |
MPlist * | mlanguage_name_list (MSymbol language, MSymbol target, MSymbol script, MSymbol territory) |
Return the language names written in the specified language. | |
MText * | mlanguage_text (MSymbol language) |
Return the language name written in that language. | |
MPlist * | mscript_list (void) |
List script names. | |
MPlist * | mscript_language_list (MSymbol script) |
List languages that use a specified script. | |
MLocale * | mlocale_set (int category, const char *name) |
Set the current locale. | |
MSymbol | mlocale_get_prop (MLocale *locale, MSymbol key) |
Get the value of a locale property. | |
int | mtext_ftime (MText *mt, const char *format, const struct tm *tm, MLocale *locale) |
Format date and time. | |
MText * | mtext_getenv (const char *name) |
Get an environment variable. | |
int | mtext_putenv (MText *mt) |
Change or add an environment variable. | |
int | mtext_coll (MText *mt1, MText *mt2) |
Compare two M-texts using the current locale. | |
Variables | |
MSymbol | Miso639_1 |
MSymbol | Miso639_2 |
MSymbol | Mterritory |
MSymbol | Mmodifier |
MSymbol | Mcodeset |
Locale objects and API for them.
The m17n library represents locale related information as objects of type MLocale.
struct
MLocale
.
The structure MLocale
is used to hold information about name, language, territory, modifier, codeset, and the corresponding coding system of locales.
The contents of this structure are implementation dependent. Its internal structure is concealed from application programs.
MPlist * mlanguage_list | ( | void | ) |
List 3-letter language codes.
The mlanguage_list() funciton returns a well-formed plist whose keys are Msymbol and values are symbols whose names are ISO639-2 3-letter language codes.
MSymbol mlanguage_code | ( | MSymbol | language, |
int | len | ||
) |
Get a language code.
The mlanguage_code() function returns a symbol whose name is the ISO639 language code of language. language is a symbol whose name is an ISO639-2 3-letter language code, an ISO639-1 2-letter language codes, or an English word.
len specifies the type of the returned language code. If it is 3, an ISO639-2 3-letter language code is returned. If it is 2, an ISO639-1 2-letter language code is returned when defined; otherwise Mnil is returned. If it is 0, a 2-letter code is returned when defined; otherwise a 3-letter code is returned.
MPlist * mlanguage_name_list | ( | MSymbol | language, |
MSymbol | target, | ||
MSymbol | script, | ||
MSymbol | territory | ||
) |
Return the language names written in the specified language.
The mlanguage_name_list() function returns a plist of LANGUAGE's names written in TARGET language. SCRIPT and TERRITORY, if not Mnil, specifies which script and territory to concern at first.
LANGUAGE and TARGET must be a symbol whose name is an ISO639-2 3-letter language code or an ISO639-1 2-letter language codes. TARGET may be Mnil, in which case, the language of the current locale is used. If locale is not set or is C, English is used.
SCRIPT and TERRITORY must be a symbol whose name is a script and territory name of a locale (e.g. "TW", "SG") respectively.
If no translation is available, NULL
is returned.
The returned plist should not be modified nor freed.
MText * mlanguage_text | ( | MSymbol | language | ) |
Return the language name written in that language.
The mlanguage_text() function returns, in the form of M-text, the language name of language written in language. If the representative characters of the language are known, the characters of the returned M-text has a text property whose key is Mtext and whose value is an M-text that contains the representative characters.
NULL
.MPlist * mscript_list | ( | void | ) |
List script names.
The mscript_list() funciton returns a well-formed plist whose keys are Msymbol and values are symbols whose names are script names.
MPlist * mscript_language_list | ( | MSymbol | script | ) |
List languages that use a specified script.
The mscript_language_list() function lists languages that use script. script is a symbol whose name is the lower-cased version of a script name that appears in the Unicode Character Database.
This function returns a well-formed plist whose keys are Msymbol and values are symbols whose names are ISO639-1 2-letter codes (or ISO639-2 3-letter codes, if the former is not available). The caller should not modify nor free it. If the m17n library does not know about script, it returns @ c NULL.
MLocale * mlocale_set | ( | int | category, |
const char * | name | ||
) |
Set the current locale.
The mlocale_set() function sets or query a part of the current locale. The part is specified by category which must be a valid first argument to setlocale()
.
If locale is not NULL, the locale of the specified part is set to locale. If locale is not supported by the system, the current locale is not changed.
If locale is NULL, the current locale of the specified part is queried.
MERROR_LOCALE
MSymbol mlocale_get_prop | ( | MLocale * | locale, |
MSymbol | key | ||
) |
Get the value of a locale property.
The mlocale_get_prop() function returns the value of a property key of local locale. key must be Mname, Mlanguage, Mterritory, Mcodeset, Mmodifier, or Mcoding.
Format date and time.
The mtext_ftime() function formats the broken-down time tm according to the format specification format and append the result to the M-text mt. The formating is done according to the locale locale (if not NULL) or the current locale (LC_TIME).
The meaning of the arguments tm and format are the same as those of strftime().
MText * mtext_getenv | ( | const char * | name | ) |
Get an environment variable.
The mtext_getenv() function searches the environment variable list for a string that matches the string pointed to by name.
If there is a match, the function decodes the value according to the current locale (LC_CTYPE) into an M-text, and return that M-text.
If there is no match, the function returns NULL.
int mtext_putenv | ( | MText * | mt | ) |
Change or add an environment variable.
The mtext_putenv() function changes or adds the value of environment variables according to M-text mt. It calls the function putenv
with an argument generated by encoding mt according to the current locale (LC_CTYPE).
Compare two M-texts using the current locale.
The mtext_coll() function compares the two M-texts mt1 and mt2. It returns an integer less than, equal to, or greater than zero if mt1 is found, respectively, to be less than, to match, or to be greater than mt2. The comparison is based on texts as appropriate for the current locale (LC_COLLATE).
This function makes use of information that is automatically cached in the M-texts as a text property. So, the second call of this function with mt1 or mt2 finishes faster than the first call.
MSymbol Miso639_1 |
MSymbol Miso639_2 |
MSymbol Mterritory |
The symbol whose name is "territory".
MSymbol Mmodifier |
The symbol whose name is "modifier".
MSymbol Mcodeset |
The symbol whose name is "codeset".