Functions |
int | i18n_ulocale_get_default (const char **locale) |
| Gets the default locale.
|
int | i18n_ulocale_set_default (const char *locale_id) |
| Sets the 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.
|
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 ulocale represents a specific geographical, political, or cultural region.
Required Header
#include <utils_i18n.h>
Overview
A ulocale represents a specific geographical, political, or cultural region. An operation that requires a ulocale to perform its task is called locale-sensitive and uses the ulocale 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.
Sample Code 1
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;
ret = i18n_ulocale_set_default(getenv("LC_TIME"));
ret = i18n_ulocale_get_default(&locale);
if ( ret != I18N_ERROR_NONE ) {
dlog_print(DLOG_INFO, LOG_TAG, "i18n_ulocale_get_default() is failed!!! \n");
}
dlog_print(DLOG_INFO, LOG_TAG, "default locale : %s\n", locale);
ret = i18n_ulocale_get_language(locale, language, language_capacity, &buf_size_language);
if ( ret != I18N_ERROR_NONE ) {
dlog_print(DLOG_INFO, LOG_TAG, "i18n_ulocale_get_language() is failed!!! \n");
}
dlog_print(DLOG_INFO, LOG_TAG, "language code for the locale : %s\n", language);
ret = i18n_ulocale_get_display_name(locale, in_locale_id, result_w, 64, &buf_size_display_name);
i18n_ustring_copy_au(result, result_w);
dlog_print(DLOG_INFO, LOG_TAG, "full name suitable for the locale : %s\n", result);
Sample Code 2
See all available locales
Define Documentation
Useful constant for en_CA
Useful constant for fr_CA
Useful constant for zh_CN
Useful constant for fr_FR
Useful constant for de_DE
Useful constant for it_IT
Useful constant for ja_JP
Useful constant for ko_KR
Useful constant for zh_CN
Useful constant for zh_CN
Useful constant for zh_TW
Useful constant for zh_TW
Useful constant for en_GB
Useful constant for en_US
Function Documentation
Gets the size of the all available locale list.
- Since :
- 2.3
- Returns:
- the size of the locale list
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.
- Since :
- 2.3
- Parameters:
-
[in] | n | the specific locale name index of the available locale list |
- Returns:
- A specified locale name of all available locales
Gets the country code for the specified locale.
- Since :
- 2.3
- Parameters:
-
[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 is failed (It must not indicate a failure before the function call) |
- Returns:
- The actual buffer size needed for the language code
If it's greater than language_capacity, the returned language code will be truncated.
Gets the default locale.
The returned string is a snapshot in time, and will remain valid and unchanged even when i18n_ulocale_set_default() is called.
- Since :
- 2.3
- Parameters:
-
[out] | locale | The default locale |
- Return values:
-
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.
- Since :
- 2.3
- Parameters:
-
[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. |
- Return values:
-
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.
- Since :
- 2.3
- Parameters:
-
[in] | locale_id | The locale to get the ISO language code with |
[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. |
- Return values:
-
Sets the default locale.
- Since :
- 2.3
- Parameters:
-
[in] | locale_id | The new ICU default locale
A value of NULL will try to get the system's default locale. |
- Return values:
-