Languages

Menu
Sites
Language
Inconsistent results by i18n_ulocale_get_display_name

In my Tizen 2.3 native mobile app I'm trying to detect the UI language as it is set in the Tizen OS Settings, and show it as a human readable format. I use the following code:

i18n_uchar *bufUC = malloc(100);
int32_t sizeReq;
if (i18n_ulocale_get_display_name(NULL, NULL, bufUC, 99, &sizeReq) == I18N_ERROR_NONE) {
 char *buf = malloc(100);
 if (i18n_ustring_copy_au(buf, bufUC) && strlen(buf)) addListItem("Tizen Language", buf, 0);
 free(buf);
}
free(bufUC);
 

However, the results are inconsitent, and I'm not sure why is that.  If I select English, Spanish, German, Hungarian and Italian language, the results are as follows:

English (United States)
espanol (Espana)
de (DE)
hu (HU)
it (IT)
 

So somehow the locale code is not properly decoded into a human readable format by i18n_ulocale_get_display_name.  Is it an OS bug?  Or maybe I should use a different method to show the information I'm looking for?  I've tried to use system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE) as well, but it provides only the locale code, not the display name of the language.

Thank you.

Regards,
Tamas

Edited by: Tamas Miklos on 15 Jun, 2015

Responses

3 Replies
Tamas Miklos

I've also discovered an OS bug via the Tizen 2.3 emulator. If I set the Display Language to "English", and not "English (United States)", the layout of the Settings panel completely falls apart, displaying strings like "IDS_ST_OPT_SETTINGS" and such, instead of proper English text.  Build string is "Tizen-2.3.0_Mobile-Emulator_20141226.1803"

daniel kim

Hi,

How about you try this code?

 

   int ret = I18N_ERROR_NONE;
   i18n_uchar result_w[64] = {0,};
   char result[64] = {0,};
   int buf_size_display_name;
   char *lang, *cnty;

   system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &lang);
   system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, &cnty);

 

   ret = i18n_ulocale_get_display_name(lang, cnty, 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);

 

 

Regards.

Tamas Miklos

Thank you for the code, but I'm afraid that produces the same output as my code above :(  It may just be an issue that only comes up in the emulator. I would check it on the Samsung Z1 device, but that one doesn't seem to support European languages at all -- which may be normal considering the current market coverage of the device.