diff options
Diffstat (limited to 'src/widget_service.c')
-rw-r--r-- | src/widget_service.c | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/src/widget_service.c b/src/widget_service.c index 9aaa2cc..da15ede 100644 --- a/src/widget_service.c +++ b/src/widget_service.c @@ -1515,7 +1515,7 @@ static char *_get_name(const char *widget_id, const char *lang, uid_t uid) { static const char query[] = "SELECT label FROM label " - "WHERE classid=? AND (locale=? OR locale IS NULL) " + "WHERE classid=? AND (LOWER(locale)=LOWER(?) OR locale IS NULL) " "ORDER BY locale DESC"; int ret; sqlite3 *db; @@ -1570,9 +1570,37 @@ static char *_get_name(const char *widget_id, const char *lang, uid_t uid) } +static char *__get_cur_locale(void) +{ + char *language; + char *ptr; + + language = vconf_get_str(VCONFKEY_LANGSET); + if (language) { + ptr = language; + while (*ptr) { + if (*ptr == '.') { + *ptr = '\0'; + break; + } + + if (*ptr == '_') { + *ptr = '-'; + } + + ptr++; + } + } else { + language = strdup("en-us"); + } + + return language; +} + EAPI char *widget_service_get_name(const char *widget_id, const char *lang) { char *name; + char *language; if (!_is_widget_feature_enabled()) { _E("not supported"); @@ -1591,9 +1619,22 @@ EAPI char *widget_service_get_name(const char *widget_id, const char *lang) return NULL; } - name = _get_name(widget_id, lang, getuid()); + if (!lang) + language = __get_cur_locale(); + else + language = strdup(lang); + + if (!language) { + _E("Out-of-memory"); + set_last_result(WIDGET_ERROR_OUT_OF_MEMORY); + return NULL; + } + + name = _get_name(widget_id, language, getuid()); if (name == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST) - name = _get_name(widget_id, lang, GLOBALAPP_USER); + name = _get_name(widget_id, language, GLOBALAPP_USER); + + free(language); return name; } |