Enlightenment CVS committal
Author : e-taro
Project : e17
Module : apps/e
Dir : e17/apps/e/src/bin
Modified Files:
e_apps.c e_intl.c e_intl.h
Log Message:
Make E_Apps support LANG value like [zh_TW], [ja] etc.
(exposing shorne's useful _e_intl_locale_canonic_get function for this)
----------------------------------------------------------------------
src/bin/e_apps.c src/bin/e_intl.c src/bin/e_intl.h CVS:
----------------------------------------------------------------------
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_apps.c,v
retrieving revision 1.125
retrieving revision 1.126
diff -u -3 -r1.125 -r1.126
--- e_apps.c 2 Mar 2006 12:03:48 -0000 1.125
+++ e_apps.c 9 Mar 2006 14:50:12 -0000 1.126
@@ -57,6 +57,7 @@
static int _e_app_cb_scan_cache_timer(void *data);
static E_App *_e_app_cache_new (E_App_Cache *ac, const char *path,
int scan_subdirs);
static int _e_app_exe_valid_get (const char *exe);
+static char *_e_app_localized_val_get (Eet_File *ef, const char *lang,
const char *field, int *size);
/* local subsystem globals */
static Evas_Hash *_e_apps = NULL;
@@ -986,7 +987,6 @@
e_app_fields_fill(E_App *a, const char *path)
{
Eet_File *ef;
- char buf[PATH_MAX];
char *str, *v;
char *lang;
int size;
@@ -1009,34 +1009,11 @@
a->member = evas_stringshare_add(str); \
free(v); \
}
- if (lang)
- {
- snprintf(buf, sizeof(buf), "app/info/name[%s]", lang);
- v = eet_read(ef, buf, &size);
- if (!v) v = eet_read(ef, "app/info/name", &size);
- }
- else
- v = eet_read(ef, "app/info/name", &size);
+ v = _e_app_localized_val_get(ef, lang, "app/info/name", &size);
STORE(name);
-
- if (lang)
- {
- snprintf(buf, sizeof(buf), "app/info/generic[%s]", lang);
- v = eet_read(ef, buf, &size);
- if (!v) v = eet_read(ef, "app/info/generic", &size);
- }
- else
- v = eet_read(ef, "app/info/generic", &size);
+ v = _e_app_localized_val_get(ef, lang, "app/info/generic", &size);
STORE(generic);
-
- if (lang)
- {
- snprintf(buf, sizeof(buf), "app/info/comment[%s]", lang);
- v = eet_read(ef, buf, &size);
- if (!v) v = eet_read(ef, "app/info/comment", &size);
- }
- else
- v = eet_read(ef, "app/info/comment", &size);
+ v = _e_app_localized_val_get(ef, lang, "app/info/comment", &size);
STORE(comment);
v = eet_read(ef, "app/info/exe", &size);
@@ -1066,6 +1043,32 @@
eet_close(ef);
}
+static char *
+_e_app_localized_val_get(Eet_File *ef, const char *lang, const char *field,
int *size)
+{
+ char *s, *v;
+ char buf[PATH_MAX];
+
+ if (lang)
+ {
+ s = e_intl_locale_canonic_get(lang, E_INTL_LOC_LANG |
E_INTL_LOC_REGION);
+ snprintf(buf, sizeof(buf), "%s[%s]", field, s);
+ free(s);
+ v = eet_read(ef, buf, size);
+ if (v)
+ return v;
+
+ s = e_intl_locale_canonic_get(lang, E_INTL_LOC_LANG);
+ snprintf(buf, sizeof(buf), "%s[%s]", field, s);
+ free(s);
+ v = eet_read(ef, buf, size);
+ if (v)
+ return v;
+ }
+ /* Fall back to default locale */
+ return eet_read(ef, field, size);
+}
+
EAPI void
e_app_fields_save(E_App *a)
{
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_intl.c,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -3 -r1.76 -r1.77
--- e_intl.c 23 Feb 2006 15:17:52 -0000 1.76
+++ e_intl.c 9 Mar 2006 14:50:12 -0000 1.77
@@ -27,10 +27,10 @@
#define E_EXE_STOP(EXE) if (EXE != NULL) { ecore_exe_terminate(EXE);
ecore_exe_free(EXE); EXE = NULL; }
#define E_EXE_IS_VALID(EXE) (!((EXE == NULL) || (EXE[0] == 0)))
-#define E_LOC_CODESET 1 << 0
-#define E_LOC_REGION 1 << 1
-#define E_LOC_MODIFIER 1 << 2
-#define E_LOC_LANG 1 << 3
+#define E_LOC_CODESET E_INTL_LOC_CODESET
+#define E_LOC_REGION E_INTL_LOC_REGION
+#define E_LOC_MODIFIER E_INTL_LOC_MODIFIER
+#define E_LOC_LANG E_INTL_LOC_LANG
#define E_LOC_ALL E_LOC_LANG | E_LOC_REGION | E_LOC_CODESET |
E_LOC_MODIFIER
#define E_LOC_SIGNIFICANT E_LOC_LANG | E_LOC_REGION | E_LOC_CODESET
@@ -41,7 +41,6 @@
static int _e_intl_language_list_find(Evas_List *language_list,
char *language);
/* Locale Validation and Discovery */
-static char *_e_intl_locale_canonic_get(char *locale, int ret_mask);
static char *_e_intl_locale_alias_get(char *language);
static Evas_Hash *_e_intl_locale_alias_hash_get(void);
static Evas_List *_e_intl_locale_system_locales_get(void);
@@ -202,7 +201,7 @@
{
char * match_lang;
- match_lang = _e_intl_locale_canonic_get(alias_locale,
E_LOC_LANG);
+ match_lang = e_intl_locale_canonic_get(alias_locale,
E_LOC_LANG);
/* If locale is C or some form of en don't report an error */
if ( match_lang == NULL && strcmp (alias_locale, "C") )
@@ -526,7 +525,7 @@
char *search_locale;
search_locale = next_search->data;
- clean_file = _e_intl_locale_canonic_get(file, E_LOC_ALL);
+ clean_file = e_intl_locale_canonic_get(file, E_LOC_ALL);
/* Match directory with the search locale */
if (clean_file && !strcmp(clean_file, search_locale))
{
@@ -603,7 +602,7 @@
if (language == NULL || !strncmp(language, "POSIX", strlen("POSIX")))
return strdup("C");
- canonic = _e_intl_locale_canonic_get(language, E_LOC_ALL );
+ canonic = e_intl_locale_canonic_get(language, E_LOC_ALL );
alias_hash = _e_intl_locale_alias_hash_get();
if (alias_hash == NULL)
@@ -702,8 +701,8 @@
*
* the returned string needs to be freed
*/
-static char *
-_e_intl_locale_canonic_get(char *locale, int ret_mask)
+EAPI char *
+e_intl_locale_canonic_get(char *locale, int ret_mask)
{
char *clean_locale;
int clean_e_intl_locale_size;
@@ -880,7 +879,7 @@
int found;
found = 0;
- search_locale = _e_intl_locale_canonic_get(locale, E_LOC_SIGNIFICANT );
+ search_locale = e_intl_locale_canonic_get(locale, E_LOC_SIGNIFICANT );
if ( search_locale == NULL )
search_locale = strdup(locale);
/* If this validates their is probably an alias issue */
@@ -897,7 +896,7 @@
char *clean_test_locale;
/* FOR BSD, need to canonicalize the locale from "locale -a" */
- clean_test_locale = _e_intl_locale_canonic_get(test_locale,
E_LOC_ALL);
+ clean_test_locale = e_intl_locale_canonic_get(test_locale,
E_LOC_ALL);
if (clean_test_locale)
{
if (!strcmp(clean_test_locale, search_locale)) found = 1;
@@ -930,7 +929,7 @@
search_list = NULL;
for ( mask = E_LOC_ALL; mask >= E_LOC_LANG; mask-- )
{
- masked_locale = _e_intl_locale_canonic_get(locale, mask);
+ masked_locale = e_intl_locale_canonic_get(locale, mask);
if (loc_mask == mask)
search_list = evas_list_append(search_list, masked_locale);
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_intl.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- e_intl.h 10 Jan 2006 04:23:43 -0000 1.10
+++ e_intl.h 9 Mar 2006 14:50:12 -0000 1.11
@@ -16,6 +16,11 @@
#define E_INTL_LANGUAGE_PACK_VERSION 1
#define E_INTL_INPUT_METHOD_CONFIG_VERSION 1
+#define E_INTL_LOC_CODESET 1 << 0
+#define E_INTL_LOC_REGION 1 << 1
+#define E_INTL_LOC_MODIFIER 1 << 2
+#define E_INTL_LOC_LANG 1 << 3
+
struct _E_Language_Pack
{
int language_pack_version;
@@ -50,5 +55,7 @@
EAPI E_Input_Method_Config *e_intl_input_method_config_read (Eet_File
*imc_file);
EAPI int e_intl_input_method_config_write (Eet_File *imc_file,
E_Input_Method_Config *imc);
EAPI void e_intl_input_method_config_free (E_Input_Method_Config
*imc);
+/* Getting locale */
+EAPI char *e_intl_locale_canonic_get(char *locale, int ret_mask);
#endif
#endif
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs