From 176d33d98fe7f90dd673e38a584c9df29552c47e Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Tue, 6 Aug 2019 16:54:35 +0900 Subject: Support language change in runtime Change-Id: I475e519af39e83c3086e55d8faf3fb1bb4890077 Signed-off-by: Jihoon Kim --- src/autofill_setting_list.cpp | 10 +++++++++- src/autofill_setting_list_ui.cpp | 43 ++++++++++++++++++++++++++++++---------- 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/src/autofill_setting_list.cpp b/src/autofill_setting_list.cpp index 9b6dab9..f08ffdb 100644 --- a/src/autofill_setting_list.cpp +++ b/src/autofill_setting_list.cpp @@ -127,8 +127,16 @@ app_terminate(void *data) static void ui_app_lang_changed(app_event_info_h event_info, void *user_data) { - LOGD(""); /*APP_EVENT_LANGUAGE_CHANGED*/ + char *lang = NULL; + app_event_get_language(event_info, &lang); + + LOGD("lang : %s", lang); + + if (lang) { + elm_language_set(lang); + free(lang); + } } static void diff --git a/src/autofill_setting_list_ui.cpp b/src/autofill_setting_list_ui.cpp index 0670fe5..2c3fe42 100644 --- a/src/autofill_setting_list_ui.cpp +++ b/src/autofill_setting_list_ui.cpp @@ -27,11 +27,11 @@ #define AUTOFILL_SETTING_LIST_PACKAGE PACKAGE #define AUTOFILL_SETTING_LIST_LOCALE_DIR tzplatform_mkpath(TZ_SYS_RO_APP, PACKAGE_NAME"/res/locale") -#define AUTOFILL_SETTING_LIST_TITLE dgettext(PACKAGE, "IDS_HEADER_AUTOFILL_SERVICE") +#define AUTOFILL_SETTING_LIST_TITLE "IDS_HEADER_AUTOFILL_SERVICE" #define AUTOFILL_SETTING_SERVICE_NONE dgettext(PACKAGE, "IDS_AUTOFILL_SERVICE_SETTING_NONE") -#define AUTOFILL_SETTING_LIST_MAKE_SURE_TRUST dgettext(PACKAGE, "IDS_AUTOFILL_MAKE_SURE_TRUST_THIS_APP_HEADER") -#define AUTOFILL_SETTING_LIST_POPUP_OK dgettext(PACKAGE, "IDS_AUTOFILL_OK") -#define AUTOFILL_SETTING_LIST_POPUP_CANCEL dgettext(PACKAGE, "IDS_COM_SK_CANCEL_ABB") +#define AUTOFILL_SETTING_LIST_MAKE_SURE_TRUST "IDS_AUTOFILL_MAKE_SURE_TRUST_THIS_APP_HEADER" +#define AUTOFILL_SETTING_LIST_POPUP_OK "IDS_AUTOFILL_OK" +#define AUTOFILL_SETTING_LIST_POPUP_CANCEL "IDS_COM_SK_CANCEL_ABB" #define AUTOFILL_SETTING_LIST_POPUP_TEXT dgettext(PACKAGE, "IDS_AUTOFILL_WILL_BE_ABLE_TO_SEE_WHATS_ON_YOUR_SCREEN_IN_ALL_APPS_TO_DETERMINE") #define ICON_DIR RESDIR"/images" @@ -261,6 +261,21 @@ static void _popup_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_inf delete cb_data; } +static void set_popup_message(Evas_Object *obj, int autofill_service_index) +{ + char chFormatMsg[1024] = {'\0'}; + char chPopupMsg[1024] = {'\0'}; + snprintf(chFormatMsg, sizeof(chFormatMsg), "%s", AUTOFILL_SETTING_LIST_POPUP_TEXT); + snprintf(chPopupMsg, sizeof(chPopupMsg), chFormatMsg, g_autofill_list[autofill_service_index].label.c_str()); + elm_object_text_set(obj, chPopupMsg); +} + +static void popup_lang_changed(void *data, Evas_Object *obj, void *event_info) +{ + int index = (int)data; + set_popup_message(obj, index); +} + static void autofill_setting_list_show_popup(void *data, Evas_Object *obj, popup_ok_cb ime_setting_list_ok_callback, popup_cancel_cb ime_setting_list_cancel_callback) { int index = (int)reinterpret_cast(data); @@ -276,15 +291,11 @@ static void autofill_setting_list_show_popup(void *data, Evas_Object *obj, popup elm_object_domain_translatable_part_text_set(popup, "title,text", PACKAGE, AUTOFILL_SETTING_LIST_MAKE_SURE_TRUST); elm_object_style_set(popup, "circle"); - char chFormatMsg[1024] = {'\0'}; - char chPopupMsg[1024] = {'\0'}; - snprintf(chFormatMsg, sizeof(chFormatMsg), "%s", AUTOFILL_SETTING_LIST_POPUP_TEXT); - snprintf(chPopupMsg, sizeof(chPopupMsg), chFormatMsg, g_autofill_list[index].label.c_str()); - Evas_Object *layout = elm_layout_add(popup); elm_layout_theme_set(layout, "layout", "popup", "content/circle/buttons2"); - elm_object_domain_translatable_part_text_set(layout, "elm.text", PACKAGE, chPopupMsg); + set_popup_message(layout, index); elm_object_content_set(popup, layout); + evas_object_smart_callback_add(layout, "language,changed", popup_lang_changed, (void *)index); popup_cb_data *cb_data = new popup_cb_data; cb_data->popup = popup; @@ -390,6 +401,13 @@ static Evas_Object *autofill_setting_list_naviframe_create(Evas_Object* parent) return naviframe; } +static void gl_lang_changed(void *data, Evas_Object *obj, void *event_info) +{ + autofill_setting_list_load_autofill_info(); + + elm_genlist_realized_items_update(obj); +} + static Evas_Object *autofill_setting_list_genlist_create(appdata *ad) { Evas_Object *genlist = elm_genlist_add(ad->naviframe); @@ -402,6 +420,9 @@ static Evas_Object *autofill_setting_list_genlist_create(appdata *ad) eext_rotary_object_event_activated_set(ad->main_circle_genlist, EINA_TRUE); #endif evas_object_show(genlist); + + evas_object_smart_callback_add(genlist, "language,changed", gl_lang_changed, NULL); + return genlist; } @@ -435,7 +456,7 @@ static char *autofill_setting_list_genlist_item_label_get(void *data, Evas_Objec static char *autofill_setting_list_genlist_title_label_get(void *data, Evas_Object *obj, const char *part) { if (!strcmp(part, "elm.text")) { - return strdup(AUTOFILL_SETTING_LIST_TITLE); + return strdup(dgettext(PACKAGE, AUTOFILL_SETTING_LIST_TITLE)); } return NULL; } -- cgit v1.2.3