Tizen Native API
|
Functions | |
int | i18n_ulocale_get_default (const char **locale) |
Gets I18N's default locale. | |
int | i18n_ulocale_set_default (const char *locale_id) |
Sets I18N's default locale. | |
int | i18n_ulocale_get_language (const char *locale_id, char *language, int32_t language_capacity, int32_t *buf_size_language) |
Gets the language code for the specified locale. | |
int32_t | i18n_ulocale_get_country (const char *locale_id, char *country, int32_t country_capacity, int *error) |
Gets the country code for the specified locale. | |
int | i18n_ulocale_get_display_name (const char *locale_id, const char *in_locale_id, i18n_uchar *result, int32_t max_result_size, int32_t *buf_size_display_name) |
Gets the full name suitable for display for the specified locale. | |
const char * | i18n_ulocale_get_available (int32_t n) |
Gets the specified locale from a list of all available locales. | |
int32_t | i18n_ulocale_count_available (void) |
Gets the size of the all available locale list. | |
int32_t | i18n_ulocale_get_script (const char *locale_id, char *script, int32_t script_capacity) |
Gets the script code for the specified locale. | |
int32_t | i18n_ulocale_get_variant (const char *locale_id, char *variant, int32_t variant_capacity) |
Gets the variant code for the specified locale. | |
int32_t | i18n_ulocale_get_name (const char *locale_id, char *name, int32_t name_capacity) |
Gets the full name for the specified locale. | |
int32_t | i18n_ulocale_canonicalize (const char *locale_id, char *name, int32_t name_capacity) |
Gets the full name for the specified locale. | |
const char * | i18n_ulocale_get_iso3_language (const char *locale_id) |
Gets the ISO language code for the specified locale. | |
const char * | i18n_ulocale_get_iso3_country (const char *locale_id) |
Gets the ISO country code for the specified locale. | |
uint32_t | i18n_ulocale_get_lcid (const char *locale_id) |
Gets the Win32 LCID value for the specified locale. | |
int32_t | i18n_ulocale_get_display_language (const char *locale, const char *display_locale, i18n_uchar *language, int32_t language_capacity) |
Gets the language name suitable for display for the specified locale. | |
int32_t | i18n_ulocale_get_display_script (const char *locale, const char *display_locale, i18n_uchar *script, int32_t script_capacity) |
Gets the script name suitable for display for the specified locale. | |
int32_t | i18n_ulocale_get_display_country (const char *locale, const char *display_locale, i18n_uchar *country, int32_t country_capacity) |
Gets the country name suitable for display for the specified locale. | |
int32_t | i18n_ulocale_get_display_variant (const char *locale, const char *display_locale, i18n_uchar *variant, int32_t variant_capacity) |
Gets the variant name suitable for display for the specified locale. | |
int32_t | i18n_ulocale_get_display_keyword (const char *keyword, const char *display_locale, i18n_uchar *dest, int32_t dest_capacity) |
Gets the keyword name suitable for display for the specified locale. | |
int32_t | i18n_ulocale_get_display_keyword_value (const char *locale, const char *keyword, const char *display_locale, i18n_uchar *dest, int32_t dest_capacity) |
Gets the value of the keyword suitable for display for the specified locale. | |
const char *const * | i18n_ulocale_get_iso_languages (void) |
Gets a list of all available 2-letter language codes defined in ISO 639, plus additional 3-letter codes determined to be useful for locale generation as defined by Unicode CLDR. | |
const char *const * | i18n_ulocale_get_iso_countries (void) |
Gets a list of all available 2-letter country codes defined in ISO 639. | |
int32_t | i18n_ulocale_get_parent (const char *locale_id, char *parent, int32_t parent_capacity) |
Truncates the locale ID string to get the parent locale ID. | |
int32_t | i18n_ulocale_get_base_name (const char *locale_id, char *name, int32_t name_capacity) |
Gets the full name for the specified locale. | |
int | i18n_ulocale_keywords_create (const char *locale_id, i18n_uenumeration_h *enumeration) |
Gets an enumeration of keywords for the specified locale. | |
int32_t | i18n_ulocale_get_keyword_value (const char *locale_id, const char *keyword_name, char *buffer, int32_t buffer_capacity) |
Gets the value for a keyword. | |
int32_t | i18n_ulocale_set_keyword_value (const char *keyword_name, const char *keyword_value, char *buffer, int32_t buffer_capacity) |
Sets or removes the value of the specified keyword. | |
int | i18n_ulocale_get_character_orientation (const char *locale_id, i18n_ulocale_layout_type_e *layout_type) |
Gets the layout character orientation for the specified locale. | |
int | i18n_ulocale_get_line_orientation (const char *locale_id, i18n_ulocale_layout_type_e *layout_type) |
Gets the layout line orientation for the specified locale. | |
int32_t | i18n_ulocale_get_locale_for_lcid (uint32_t host_id, char *locale, int32_t locale_capacity) |
Gets the I18N locale ID for the specified Win32 LCID value. | |
int32_t | i18n_ulocale_add_likely_subtags (const char *locale_id, char *maximized_locale_id, int32_t maximized_locale_id_capacity) |
Adds the likely subtags for a provided locale ID, per the algorithm described in the following CLDR technical report : http://www.unicode.org/reports/tr35/#Likely_Subtags. | |
int32_t | i18n_ulocale_minimize_subtags (const char *locale_id, char *minimized_locale_id, int32_t minimized_locale_id_capacity) |
Minimizes the subtags for a provided locale ID, per the algorithm described in the following CLDR technical report: http://www.unicode.org/reports/tr35/#Likely_Subtags. | |
int32_t | i18n_ulocale_for_language_tag (const char *langtag, char *locale_id, int32_t locale_id_capacity, int32_t *parsed_length) |
Returns a locale ID for the specified BCP47 language tag string. | |
int32_t | i18n_ulocale_to_language_tag (const char *locale_id, char *langtag, int32_t langtag_capacity, i18n_ubool strict) |
Returns a well-formed language tag for this locale ID. | |
Defines | |
#define | I18N_ULOCALE_CHINESE "zh" |
#define | I18N_ULOCALE_ENGLISH "en" |
#define | I18N_ULOCALE_FRENCH "fr" |
#define | I18N_ULOCALE_GERMAN "de" |
#define | I18N_ULOCALE_ITALIAN "it" |
#define | I18N_ULOCALE_JAPANESE "ja" |
#define | I18N_ULOCALE_KOREAN "ko" |
#define | I18N_ULOCALE_SIMPLIFIED_CHINESE "zh_CN" |
#define | I18N_ULOCALE_TRADITIONAL_CHINESE "zh_TW" |
#define | I18N_ULOCALE_CANADA "en_CA" |
#define | I18N_ULOCALE_CANADA_FRENCH "fr_CA" |
#define | I18N_ULOCALE_CHINA "zh_CN" |
#define | I18N_ULOCALE_PRC "zh_CN" |
#define | I18N_ULOCALE_FRANCE "fr_FR" |
#define | I18N_ULOCALE_GERMANY "de_DE" |
#define | I18N_ULOCALE_ITALY "it_IT" |
#define | I18N_ULOCALE_JAPAN "ja_JP" |
#define | I18N_ULOCALE_KOREA "ko_KR" |
#define | I18N_ULOCALE_TAIWAN "zh_TW" |
#define | I18N_ULOCALE_UK "en_GB" |
#define | I18N_ULOCALE_US "en_US" |
A Locale represents a specific geographical, political, or cultural region.
#include <utils_i18n.h>
A Locale represents a specific geographical, political, or cultural region. An operation that requires a Locale to perform its task is called locale-sensitive and uses the Locale to tailor information for the user. For example, displaying a number is a locale-sensitive operation. The number should be formatted according to the customs/conventions of the user's native country, region, or culture. In the C APIs, a locale is simply a const char string.
Gets a default locale and a full name for the locale
const char *locale; const char *in_locale_id = "en_US"; char language[64] = {0,}; i18n_uchar result_w[64] = {0,}; char result[64] = {0,}; int language_capacity = 64; int buf_size_language; int buf_size_display_name; int ret = I18N_ERROR_NONE; // Sets default locale ret = i18n_ulocale_set_default(getenv("LC_TIME")); // Gets default locale ret = i18n_ulocale_get_default(&locale); if ( ret != I18N_ERROR_NONE ) { dlog_print(DLOG_ERROR, LOG_TAG, "i18n_ulocale_get_default() failed!!! \n"); } dlog_print(DLOG_INFO, LOG_TAG, "default locale : %s\n", locale); // default locale : en_GB.UTF-8 // Gets the language code for the specified locale ret = i18n_ulocale_get_language(locale, language, language_capacity, &buf_size_language); if ( ret != I18N_ERROR_NONE ) { dlog_print(DLOG_ERROR, LOG_TAG, "i18n_ulocale_get_language() failed!!! \n"); } dlog_print(DLOG_INFO, LOG_TAG, "language code for the locale : %s\n", language); // language code for the locale : en // Gets the full name suitable for display for the specified locale ret = i18n_ulocale_get_display_name(locale, in_locale_id, result_w, 64, &buf_size_display_name); if ( ret != I18N_ERROR_NONE ) { dlog_print(DLOG_ERROR, LOG_TAG, "i18n_ulocale_get_display_name() failed!!! \n"); } i18n_ustring_copy_au(result, result_w); dlog_print(DLOG_INFO, LOG_TAG, "full name suitable for the locale : %s\n", result); // full name suitable for the locale : English (United Kingdom)
See all available locales
int i = 0; int32_t count = i18n_ulocale_count_available(); for(i = 0; i < count; i++) { dlog_print(DLOG_INFO, LOG_TAG, "Available locale %d : %s " ,i, i18n_ulocale_get_available(i)); // ... //Available locale 5 : en_GB //Available locale 6 : en_US //Available locale 7 : en_US_POSIX // ... }
#define I18N_ULOCALE_CANADA "en_CA" |
Useful constant for en_CA.
#define I18N_ULOCALE_CANADA_FRENCH "fr_CA" |
Useful constant for fr_CA.
#define I18N_ULOCALE_CHINA "zh_CN" |
Useful constant for zh_CN.
#define I18N_ULOCALE_CHINESE "zh" |
Useful constant for zh.
#define I18N_ULOCALE_ENGLISH "en" |
Useful constant for en.
#define I18N_ULOCALE_FRANCE "fr_FR" |
Useful constant for fr_FR.
#define I18N_ULOCALE_FRENCH "fr" |
Useful constant for fr.
#define I18N_ULOCALE_GERMAN "de" |
Useful constant for de.
#define I18N_ULOCALE_GERMANY "de_DE" |
Useful constant for de_DE.
#define I18N_ULOCALE_ITALIAN "it" |
Useful constant for it.
#define I18N_ULOCALE_ITALY "it_IT" |
Useful constant for it_IT.
#define I18N_ULOCALE_JAPAN "ja_JP" |
Useful constant for ja_JP.
#define I18N_ULOCALE_JAPANESE "ja" |
Useful constant for ja.
#define I18N_ULOCALE_KOREA "ko_KR" |
Useful constant for ko_KR.
#define I18N_ULOCALE_KOREAN "ko" |
Useful constant for ko.
#define I18N_ULOCALE_PRC "zh_CN" |
Useful constant for zh_CN.
#define I18N_ULOCALE_SIMPLIFIED_CHINESE "zh_CN" |
Useful constant for zh_CN.
#define I18N_ULOCALE_TAIWAN "zh_TW" |
Useful constant for zh_TW.
#define I18N_ULOCALE_TRADITIONAL_CHINESE "zh_TW" |
Useful constant for zh_TW.
#define I18N_ULOCALE_UK "en_GB" |
Useful constant for en_GB.
#define I18N_ULOCALE_US "en_US" |
Useful constant for en_US.
Enumeration for the 'out_result' parameter return value.
int32_t i18n_ulocale_add_likely_subtags | ( | const char * | locale_id, |
char * | maximized_locale_id, | ||
int32_t | maximized_locale_id_capacity | ||
) |
Adds the likely subtags for a provided locale ID, per the algorithm described in the following CLDR technical report : http://www.unicode.org/reports/tr35/#Likely_Subtags.
If locale_id is already in the maximal form, or there is no data available for maximization, it will be copied to the output buffer. For example, "und-Zzzz" cannot be maximized, since there is no reasonable maximization.
Examples :
"en" maximizes to "en_Latn_US"
"de" maximizes to "de_Latn_US"
"sr" maximizes to "sr_Cyrl_RS"
"sh" maximizes to "sr_Latn_RS" (Note this will not reverse.)
"zh_Hani" maximizes to "zh_Hans_CN" (Note this will not reverse.)
[in] | locale_id | The locale to maximize |
[out] | maximized_locale_id | The maximized locale |
[in] | maximized_locale_id_capacity | The capacity of the maximized_locale_id buffer |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int32_t i18n_ulocale_canonicalize | ( | const char * | locale_id, |
char * | name, | ||
int32_t | name_capacity | ||
) |
Gets the full name for the specified locale.
Note : This has the effect of 'canonicalizing' the string to a certain extent. Upper and lower case are set as needed, and if the components were in 'POSIX' format they are changed to I18N format. It does NOT map aliased names in any way. See the top of this header file.
[in] | locale_id | The locale to get the full name with |
[out] | name | The full name for locale_id |
[in] | name_capacity | The size of the name buffer to store the full name with |
I18N_ERROR_NONE | Successful |
I18N_ERROR_BUFFER_OVERFLOW | A result would not fit in the supplied buffer |
int32_t i18n_ulocale_count_available | ( | void | ) |
Gets the size of the all available locale list.
I18N_ERROR_NONE | Success |
int32_t i18n_ulocale_for_language_tag | ( | const char * | langtag, |
char * | locale_id, | ||
int32_t | locale_id_capacity, | ||
int32_t * | parsed_length | ||
) |
Returns a locale ID for the specified BCP47 language tag string.
If the specified language tag contains any ill-formed subtags, the first such subtag and all following subtags are ignored.
This implements the 'Language-Tag' production of BCP47, and so supports grandfathered (regular and irregular) as well as private use language tags. Private use tags are represented as 'x-whatever', and grandfathered tags are converted to their canonical replacements where they exist. Note that a few grandfathered tags have no modern replacement, these will be converted using the fallback described in the first paragraph, so some information might be lost.
[in] | langtag | The input BCP47 language tag. |
[out] | locale_id | The output buffer receiving a locale ID for the specified BCP47 language tag. |
[in] | locale_id_capacity | The size of the locale_id output buffer. |
[in] | parsed_length | If not NULL , successfully parsed length for the input language tag is set. |
NULL
or the locale_id_capacity is lower than 0
, then the I18N_ERROR_INVALID_PARAMETER error will be set and -1
will be returned.I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
const char* i18n_ulocale_get_available | ( | int32_t | n | ) |
Gets the specified locale from a list of all available locales.
The return value is a pointer to an item of a locale name array. Both this array and the pointers it contains are owned by I18N and should not be deleted or written through by the caller. The locale name is terminated by a null pointer.
[in] | n | The specific locale name index of the available locale list |
I18N_ERROR_NONE | Success |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int32_t i18n_ulocale_get_base_name | ( | const char * | locale_id, |
char * | name, | ||
int32_t | name_capacity | ||
) |
Gets the full name for the specified locale.
Note : This has the effect of 'canonicalizing' the string to a certain extent. Upper and lower case are set as needed, and if the components were in 'POSIX' format they are changed to I18N format. It does NOT map aliased names in any way. See the top of this header file.
This API strips off the keyword part, so "de_DE\@collation=phonebook" will become "de_DE". This API supports preflighting.
[in] | locale_id | The locale to get the full name with |
[out] | name | Fill in buffer for the name without keywords. |
[in] | name_capacity | Capacity of the fill in buffer. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_BUFFER_OVERFLOW | A result would not fit in the supplied buffer |
int i18n_ulocale_get_character_orientation | ( | const char * | locale_id, |
i18n_ulocale_layout_type_e * | layout_type | ||
) |
Gets the layout character orientation for the specified locale.
[in] | locale_id | locale name |
[out] | layout_type | A pointer to the enum indicating the layout orientation for characters. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int32_t i18n_ulocale_get_country | ( | const char * | locale_id, |
char * | country, | ||
int32_t | country_capacity, | ||
int * | error | ||
) |
Gets the country code for the specified locale.
[in] | locale_id | The locale to get the country code with |
[out] | country | The country code for locale_id |
[in] | country_capacity | The size of the country buffer to store the country code with |
[out] | error | Error information if retrieving the country code failed |
int i18n_ulocale_get_default | ( | const char ** | locale | ) |
Gets I18N's default locale.
The returned string is a snapshot in time, and will remain valid and unchanged even when i18n_ulocale_set_default() is called. The returned storage is owned by I18N, and must not be altered or deleted by the caller.
[out] | locale | The I18N default locale |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int32_t i18n_ulocale_get_display_country | ( | const char * | locale, |
const char * | display_locale, | ||
i18n_uchar * | country, | ||
int32_t | country_capacity | ||
) |
Gets the country name suitable for display for the specified locale.
[in] | locale | The locale to get the displayable country code with. NULL may be used to specify the default. |
[in] | display_locale | The locale to be used to display the name. NULL may be used to specify the default. |
[out] | country | The displayable country code for locale |
[in] | country_capacity | The size of the country buffer to store the displayable country code with |
NULL
or the country_capacity is lower than 0
, then the I18N_ERROR_INVALID_PARAMETER error will be set and 0
will be returned.I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int32_t i18n_ulocale_get_display_keyword | ( | const char * | keyword, |
const char * | display_locale, | ||
i18n_uchar * | dest, | ||
int32_t | dest_capacity | ||
) |
Gets the keyword name suitable for display for the specified locale.
E.g : for the locale string de_DE@collation=PHONEBOOK, this API gets the display string for the keyword collation. Usage :
i18n_error_code_e status = I18N_ERROR_NONE; const char* keyword = NULL; int32_t keyword_len = 0; int32_t keyword_count = 0; i18n_uchar display_keyword[256]; int32_t display_keyword_len = 0; i18n_uenumeration_h keyword_enum = i18n_ulocale_keywords_create("de_DE@collation=PHONEBOOK;calendar=TRADITIONAL"); for(keyword_count = i18n_uenumeration_count(keyword_enum); keyword_count > 0; keyword_count--){ status = get_last_result(); if(status > 0){ // something went wrong so handle the error break; } // the uenum_next returns NULL-terminated string keyword = i18n_uenumeration_next(keyword_enum, &keyword_len); display_keyword_len = i18n_ulocale_get_display_keyword(keyword, "en_US", display_keyword, 256); // do something interesting } i18n_uenumeration_destroy(keyword_enum);
[in] | keyword | The keyword whose display string needs to be returned. |
[in] | display_locale | The locale to be used to display the name. NULL may be used to specify the default. |
[out] | dest | The buffer to which the displayable keyword should be written. |
[in] | dest_capacity | The size of the buffer (number of i18n_uchar characters). If it is 0, then dest may be NULL and the function will only return the length of the result without writing any of the result string (pre-flighting). |
NULL
or the dest_capacity is lower than 0
, then the I18N_ERROR_INVALID_PARAMETER error will be set and 0
will be returned.I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int32_t i18n_ulocale_get_display_keyword_value | ( | const char * | locale, |
const char * | keyword, | ||
const char * | display_locale, | ||
i18n_uchar * | dest, | ||
int32_t | dest_capacity | ||
) |
Gets the value of the keyword suitable for display for the specified locale.
E.g : for the locale string de_DE@collation=PHONEBOOK, this API gets the display string for PHONEBOOK, in the display locale, when "collation" is specified as the keyword.
[in] | locale | The locale to get the displayable variant code with. NULL may be used to specify the default. |
[in] | keyword | The keyword for whose value should be used. |
[in] | display_locale | The locale to be used to display the name. NULL may be used to specify the default. |
[out] | dest | The buffer to which the displayable keyword should be written. |
[in] | dest_capacity | The size of the buffer (number of i18n_uchar characters). If it is 0, then dest may be NULL and the function will only return the length of the result without writing any of the result string (pre-flighting). |
NULL
or the dest_capacity is lower than 0
, then the I18N_ERROR_INVALID_PARAMETER error will be set and 0
will be returned.I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int32_t i18n_ulocale_get_display_language | ( | const char * | locale, |
const char * | display_locale, | ||
i18n_uchar * | language, | ||
int32_t | language_capacity | ||
) |
Gets the language name suitable for display for the specified locale.
[in] | locale | The locale to get the ISO language code with |
[in] | display_locale | The locale to be used to display the name.NULL may be used to specify the default. |
[out] | language | The displayable language code for locale. |
[in] | language_capacity | The size of the language buffer to store the displayable language code with |
NULL
or the language_capacity is lower than 0
, then the I18N_ERROR_INVALID_PARAMETER error will be set and 0
will be returned.I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ulocale_get_display_name | ( | const char * | locale_id, |
const char * | in_locale_id, | ||
i18n_uchar * | result, | ||
int32_t | max_result_size, | ||
int32_t * | buf_size_display_name | ||
) |
Gets the full name suitable for display for the specified locale.
[in] | locale_id | The locale to get the displayable name with.NULL may be used to specify the default. |
[in] | in_locale_id | The locale to be used to display the name.NULL may be used to specify the default. |
[out] | result | The displayable name for locale_id |
[in] | max_result_size | The size of the name buffer to store the displayable full name with |
[out] | buf_size_display_name | The actual buffer size needed for the displayable name. If it's greater than max_result_size, the returned displayable name will be truncated. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int32_t i18n_ulocale_get_display_script | ( | const char * | locale, |
const char * | display_locale, | ||
i18n_uchar * | script, | ||
int32_t | script_capacity | ||
) |
Gets the script name suitable for display for the specified locale.
[in] | locale | The locale to get the displayable script code with. NULL may be used to specify the default. |
[in] | display_locale | The locale to be used to display the name. NULL may be used to specify the default. |
[out] | script | The displayable country code for locale |
[in] | script_capacity | The size of the script buffer to store the displayable script code with |
NULL
or the script_capacity is lower than 0
, then the I18N_ERROR_INVALID_PARAMETER error will be set and 0
will be returned.I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int32_t i18n_ulocale_get_display_variant | ( | const char * | locale, |
const char * | display_locale, | ||
i18n_uchar * | variant, | ||
int32_t | variant_capacity | ||
) |
Gets the variant name suitable for display for the specified locale.
[in] | locale | The locale to get the displayable variant code with. NULL may be used to specify the default. |
[in] | display_locale | The locale to be used to display the name. NULL may be used to specify the default. |
[out] | variant | The displayable variant code for locale |
[in] | variant_capacity | The size of the variant buffer to store the displayable variant code with |
NULL
or the variant_capacity is lower than 0
, then the I18N_ERROR_INVALID_PARAMETER error will be set and 0
will be returned.I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
const char* i18n_ulocale_get_iso3_country | ( | const char * | locale_id | ) |
Gets the ISO country code for the specified locale.
[in] | locale_id | The locale to get the ISO country code with |
I18N_ERROR_NONE | Successful |
const char* i18n_ulocale_get_iso3_language | ( | const char * | locale_id | ) |
Gets the ISO language code for the specified locale.
[in] | locale_id | The locale to get the ISO language code with |
I18N_ERROR_NONE | Successful |
const char* const* i18n_ulocale_get_iso_countries | ( | void | ) |
Gets a list of all available 2-letter country codes defined in ISO 639.
This is a pointer to an array of pointers to arrays of char. All of these pointers are owned by I18N - do not delete them, and do not write through them. The array is terminated with a NULL
pointer.
I18N_ERROR_NONE | Successful |
const char* const* i18n_ulocale_get_iso_languages | ( | void | ) |
Gets a list of all available 2-letter language codes defined in ISO 639, plus additional 3-letter codes determined to be useful for locale generation as defined by Unicode CLDR.
This is a pointer to an array of pointers to arrays of char. All of these pointers are owned by I18N - do not delete them, and do not write through them. The array is terminated with a NULL
pointer.
I18N_ERROR_NONE | Successful |
int32_t i18n_ulocale_get_keyword_value | ( | const char * | locale_id, |
const char * | keyword_name, | ||
char * | buffer, | ||
int32_t | buffer_capacity | ||
) |
Gets the value for a keyword.
Locale name does not need to be normalized.
[in] | locale_id | A locale name containing the keyword ("de_DE@currency=EURO;collation=PHONEBOOK") |
[in] | keyword_name | The name of the keyword for which we want the value. Case insensitive. |
[out] | buffer | Receiving buffer |
[in] | buffer_capacity | Capacity of receiving buffer |
NULL
or the buffer_capacity is lower than 0
, then the I18N_ERROR_INVALID_PARAMETER error will be set and -1
will be returned.I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ulocale_get_language | ( | const char * | locale_id, |
char * | language, | ||
int32_t | language_capacity, | ||
int32_t * | buf_size_language | ||
) |
Gets the language code for the specified locale.
[in] | locale_id | The locale to get the ISO language code with.NULL may be used to specify the default. |
[out] | language | The language code for locale_id |
[in] | language_capacity | The size of the language buffer to store the language code with |
[out] | buf_size_language | The actual buffer size needed for the language code. If it's greater than language_capacity, the returned language code will be truncated. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
uint32_t i18n_ulocale_get_lcid | ( | const char * | locale_id | ) |
Gets the Win32 LCID value for the specified locale.
If the I18N locale is not recognized by Windows, 0 will be returned.
[in] | locale_id | The locale to get the Win32 LCID value with |
I18N_ERROR_NONE | Successful |
int i18n_ulocale_get_line_orientation | ( | const char * | locale_id, |
i18n_ulocale_layout_type_e * | layout_type | ||
) |
Gets the layout line orientation for the specified locale.
[in] | locale_id | locale name |
[out] | layout_type | A pointer to the enum indicating the layout orientation for lines. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int32_t i18n_ulocale_get_locale_for_lcid | ( | uint32_t | host_id, |
char * | locale, | ||
int32_t | locale_capacity | ||
) |
Gets the I18N locale ID for the specified Win32 LCID value.
[in] | host_id | The Win32 LCID to translate |
[out] | locale | The output buffer for the I18N locale ID, which will be NULL-terminated if there is room. |
[in] | locale_capacity | The size of the output buffer |
NULL
or the locale_capacity is lower than 0
, then the I18N_ERROR_INVALID_PARAMETER error will be set and -1
will be returned.I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int32_t i18n_ulocale_get_name | ( | const char * | locale_id, |
char * | name, | ||
int32_t | name_capacity | ||
) |
Gets the full name for the specified locale.
Note : This has the effect of 'canonicalizing' the I18N locale ID to a certain extent. Upper and lower case are set as needed. It does NOT map aliased names in any way. See the top of this header file. This API supports preflighting.
[in] | locale_id | The locale to get the full name with |
[out] | name | Fill in buffer for the name without keywords. |
[in] | name_capacity | Capacity of the fill in buffer. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_BUFFER_OVERFLOW | A result would not fit in the supplied buffer |
int32_t i18n_ulocale_get_parent | ( | const char * | locale_id, |
char * | parent, | ||
int32_t | parent_capacity | ||
) |
Truncates the locale ID string to get the parent locale ID.
Copies the part of the string before the last underscore. The parent locale ID will be an empty string if there is no underscore, or if there is only one underscore at locale_id[0].
[in] | locale_id | Input locale ID string. |
[out] | parent | Output string buffer for the parent locale ID. Must not be NULL . |
[in] | parent_capacity | Size of the output buffer. If it's lower than the number of characters stored in the locale_id between the first character and the last occurrence of the underscore ("_") character, than the error code will be set to I18N_ERROR_BUFFER_OVERFLOW. |
NULL
or the parent_capacity is lower than 0
, then the I18N_ERROR_INVALID_PARAMETER error will be set and -1
will be returned.I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
I18N_ERROR_BUFFER_OVERFLOW | If the capacity of the parent is lower than the number of characters in the locale_id from index 0 to the index of the last occurrence of the underscore ("_") symbol. |
int32_t i18n_ulocale_get_script | ( | const char * | locale_id, |
char * | script, | ||
int32_t | script_capacity | ||
) |
Gets the script code for the specified locale.
[in] | locale_id | The locale to get the ISO script code with |
[out] | script | The script code for locale_id. Must not be NULL . |
[in] | script_capacity | The size of the script buffer to store the script code with |
NULL
or the script_capacity is lower than 0
, then the I18N_ERROR_INVALID_PARAMETER error will be set and -1
will be returned.I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int32_t i18n_ulocale_get_variant | ( | const char * | locale_id, |
char * | variant, | ||
int32_t | variant_capacity | ||
) |
Gets the variant code for the specified locale.
[in] | locale_id | The locale to get the variant code with |
[out] | variant | The variant code for locale_id |
[in] | variant_capacity | The size of the variant buffer to store the variant code with |
NULL
or the variant_capacity is lower than 0
, then the I18N_ERROR_INVALID_PARAMETER error will be set and -1
will be returned.I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ulocale_keywords_create | ( | const char * | locale_id, |
i18n_uenumeration_h * | enumeration | ||
) |
Gets an enumeration of keywords for the specified locale.
Enumeration must get disposed of by the client using i18n_uenumeration_destroy() function.
[in] | locale_id | The locale to get the variant code with |
enumeration | A pointer to the enumeration of keywords or NULL if there are no keywords. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int32_t i18n_ulocale_minimize_subtags | ( | const char * | locale_id, |
char * | minimized_locale_id, | ||
int32_t | minimized_locale_id_capacity | ||
) |
Minimizes the subtags for a provided locale ID, per the algorithm described in the following CLDR technical report: http://www.unicode.org/reports/tr35/#Likely_Subtags.
If locale_id is already in the minimal form, or there is no data available for minimization, it will be copied to the output buffer. Since the minimization algorithm relies on proper maximization, see the comments for i18n_ulocale_add_likely_subtags() for reasons why there might not be any data.
Examples :
"en_Latn_US" minimizes to "en"
"de_Latn_US" minimizes to "de"
"sr_Cyrl_RS" minimizes to "sr"
"zh_Hant_TW" minimizes to "zh_TW" (The region is preferred to the script, and minimizing to "zh" would imply "zh_Hans_CN".)
[in] | locale_id | The locale to minimize |
[out] | minimized_locale_id | The minimized locale |
[in] | minimized_locale_id_capacity | The capacity of the minimized_locale_id buffer |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ulocale_set_default | ( | const char * | locale_id | ) |
Sets I18N's default locale.
By default (without calling this function), I18N's default locale will be based on information obtained from the underlying system environment.
Changes to I18N's default locale do not propagate back to the system environment.
Changes to I18N's default locale to not affect any services that may already be open based on the previous default locale value.
[in] | locale_id | The new I18N default locale. A value of NULL will try to get the system's default locale. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int32_t i18n_ulocale_set_keyword_value | ( | const char * | keyword_name, |
const char * | keyword_value, | ||
char * | buffer, | ||
int32_t | buffer_capacity | ||
) |
Sets or removes the value of the specified keyword.
For removing all keywords, use i18n_ulocale_get_base_name().
NOTE : Unlike almost every other I18N function which takes a buffer, this function will NOT truncate the output text. If a I18N_ERROR_BUFFER_OVERFLOW is received, it means that the original buffer is untouched. This is done to prevent incorrect or possibly even malformed locales from being generated and used.
[in] | keyword_name | A name of the keyword to be set. Case insensitive. |
[in] | keyword_value | A value of the keyword to be set. If 0-length or NULL , will result in the keyword being removed. No error is given if that keyword does not exist. |
[out] | buffer | Input buffer containing locale to be modified. |
[in] | buffer_capacity | Capacity of receiving buffer |
NULL
or the buffer_capacity is lower than 0
, then the I18N_ERROR_INVALID_PARAMETER error will be set and -1
will be returned.I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int32_t i18n_ulocale_to_language_tag | ( | const char * | locale_id, |
char * | langtag, | ||
int32_t | langtag_capacity, | ||
i18n_ubool | strict | ||
) |
Returns a well-formed language tag for this locale ID.
Note : When strict is false
, any locale fields which do not satisfy the BCP47 syntax requirement will be omitted from the result. When strict is true
, this function sets I18N_ERROR_INVALID_PARAMETER to the result if any locale fields do not satisfy the BCP47 syntax requirement.
[in] | locale_id | The input locale ID |
[out] | langtag | The output buffer receiving BCP47 language tag for the locale ID. |
[in] | langtag_capacity | The size of the BCP47 language tag output buffer. |
[in] | strict | Boolean value indicating if the function returns an error for an ill-formed input locale ID. |
NULL
or the langtag_capacity is lower than 0
, then the I18N_ERROR_INVALID_PARAMETER error will be set and -1
will be returned.I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |