Evas language: add full locale language getter

evas_common_language_from_locale_get truncates the country letters in
the language. We don't always want that (one example is dictionaries).
This commit is contained in:
Daniel Hirt 2015-11-15 11:31:32 +02:00
parent 59ffefb9c1
commit 4c086b6e1b
2 changed files with 28 additions and 0 deletions

View File

@ -156,6 +156,31 @@ evas_common_language_from_locale_get(void)
return "";
}
const char *
evas_common_language_from_locale_full_get(void)
{
static char lang[32];
if (*lang) return lang;
const char *locale;
locale = setlocale(LC_MESSAGES, NULL);
if (locale && *locale)
{
size_t i;
for (i = 0 ; locale[i] ; i++)
{
const char c = locale[i];
if ((c == '.') || (c == '@') || (c == ' ')) /* Looks like en_US.UTF8 or de_DE@euro or aa_ER UTF-8*/
break;
}
strncpy(lang, locale, i);
lang[i] = '\0';
return lang;
}
return "";
}
/*
* @}
*/

View File

@ -128,5 +128,8 @@ evas_common_language_char_script_get(Eina_Unicode unicode);
const char *
evas_common_language_from_locale_get(void);
const char *
evas_common_language_from_locale_full_get(void);
#endif