herdsman pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=4c086b6e1bebc8e2c6c06115f1dcfd061f65bfbe

commit 4c086b6e1bebc8e2c6c06115f1dcfd061f65bfbe
Author: Daniel Hirt <daniel.h...@samsung.com>
Date:   Sun Nov 15 11:31:32 2015 +0200

    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).
---
 src/lib/evas/common/language/evas_language_utils.c | 25 ++++++++++++++++++++++
 src/lib/evas/common/language/evas_language_utils.h |  3 +++
 2 files changed, 28 insertions(+)

diff --git a/src/lib/evas/common/language/evas_language_utils.c 
b/src/lib/evas/common/language/evas_language_utils.c
index 7d13965..737b510 100644
--- a/src/lib/evas/common/language/evas_language_utils.c
+++ b/src/lib/evas/common/language/evas_language_utils.c
@@ -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 "";
+}
+
 /*
  * @}
  */
diff --git a/src/lib/evas/common/language/evas_language_utils.h 
b/src/lib/evas/common/language/evas_language_utils.h
index fa795ec..5e24912 100644
--- a/src/lib/evas/common/language/evas_language_utils.h
+++ b/src/lib/evas/common/language/evas_language_utils.h
@@ -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
 

-- 


Reply via email to