summaryrefslogtreecommitdiff
path: root/src/examples/edje
diff options
context:
space:
mode:
authorkatpavalli <katpaga.a@samsung.com>2015-05-13 18:08:04 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-05-14 18:41:47 +0200
commitdca95fb45af216068b5476f7110639cb3715b96b (patch)
tree49691183f3c708bebf663a3f8a34d00028ae6f5d /src/examples/edje
parenta312e304bf181777aa8190f4281ebdac49a827a5 (diff)
edje: support translation on static strings in edc.
Summary: Internationalisation of the static text specified as part of the edc is implemented. Problem: Static text when specified in the edc, remains unchanged when the system language is changed. Solution: Language support is provided even for the static strings in the edc. Test Plan: Test code to test this implementation is done as part of efl/src/examples/edje/edje-text.c and efl/src/examples/edje/text.edc Compile the code with the below command edje_cc -md <dir path>/efl/src/examples/edje/ text.edc && gcc -o edje-text edje-text.c `pkg-config --libs --cflags ecore-evas edje evas ecore` ./edje-text 1) change the language of the system using the command export LANGUAGE=hi ./edje.text Not the text Loading gets displayed in hindi language 2) change the language of the system using the command export LANGUAGE=ta ./edje.text Not the text Loading gets displayed in tamil language 3) change the language of the system using the command export LANGUAGE=en ./edje.text Not the text Loading gets displayed in english language As the number of .mo files in the /edje folder can be increased, those many languages can be supported Reviewers: cedric, shilpasingh Reviewed By: shilpasingh Subscribers: cedric, rajeshps, govi, poornima.srinivasan Differential Revision: https://phab.enlightenment.org/D2336 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/examples/edje')
-rw-r--r--src/examples/edje/Makefile.am4
-rw-r--r--src/examples/edje/edje-text.c23
-rw-r--r--src/examples/edje/en_IN/domain_name.mobin0 -> 75 bytes
-rw-r--r--src/examples/edje/hi_IN/domain_name.mobin0 -> 101 bytes
-rw-r--r--src/examples/edje/ta_IN/domain_name.mobin0 -> 86 bytes
-rw-r--r--src/examples/edje/text.edc78
6 files changed, 97 insertions, 8 deletions
diff --git a/src/examples/edje/Makefile.am b/src/examples/edje/Makefile.am
index 3755a4d636..a311c5b93f 100644
--- a/src/examples/edje/Makefile.am
+++ b/src/examples/edje/Makefile.am
@@ -9,6 +9,8 @@ if ENABLE_MULTISENSE
9SND_DIR = -sd $(srcdir) 9SND_DIR = -sd $(srcdir)
10endif 10endif
11 11
12MO_DIR = -md $(srcdir)
13
12#put here all EDCs one needs to the examples 14#put here all EDCs one needs to the examples
13EDCS = \ 15EDCS = \
14edje-group.edc \ 16edje-group.edc \
@@ -67,7 +69,7 @@ endif
67DIST_EDCS += $(PHYSICS_EDCS) 69DIST_EDCS += $(PHYSICS_EDCS)
68 70
69.edc.edj: 71.edc.edj:
70 $(AM_V_EDJ)$(EDJE_CC) $(EDJE_CC_FLAGS) $(SND_DIR) $< $(builddir)/$(@F) 72 $(AM_V_EDJ)$(EDJE_CC) $(EDJE_CC_FLAGS) $(SND_DIR) $(MO_DIR) $< $(builddir)/$(@F)
71 73
72 74
73EDJS = $(EDCS:%.edc=%.edj) 75EDJS = $(EDCS:%.edc=%.edj)
diff --git a/src/examples/edje/edje-text.c b/src/examples/edje/edje-text.c
index 8242ea90d0..39ab128655 100644
--- a/src/examples/edje/edje-text.c
+++ b/src/examples/edje/edje-text.c
@@ -5,7 +5,7 @@
5 * buffer one). See stdout/stderr for output. 5 * buffer one). See stdout/stderr for output.
6 * 6 *
7 * @verbatim 7 * @verbatim
8 * edje_cc text.edc && gcc -o edje-text edje-text.c `pkg-config --libs --cflags ecore-evas edje` 8 * edje_cc -md ~/efl/src/examples/edje/ text.edc && gcc -o edje-text edje-text.c `pkg-config --libs --cflags ecore-evas edje evas ecore`
9 * @endverbatim 9 * @endverbatim
10 */ 10 */
11 11
@@ -22,10 +22,18 @@
22#include <Ecore.h> 22#include <Ecore.h>
23#include <Ecore_Evas.h> 23#include <Ecore_Evas.h>
24#include <Edje.h> 24#include <Edje.h>
25#include <locale.h>
25 26
26#define WIDTH (300) 27#define WIDTH (300)
27#define HEIGHT (300) 28#define HEIGHT (300)
28 29
30static int lang_idx = 0;
31static const char *lang[] = {
32 "en_IN",
33 "ta_IN",
34 "hi_IN"
35};
36
29static void 37static void
30_on_delete(Ecore_Evas *ee EINA_UNUSED) 38_on_delete(Ecore_Evas *ee EINA_UNUSED)
31{ 39{
@@ -38,6 +46,14 @@ _on_text_change(void *data EINA_UNUSED, Evas_Object *obj, const char *part)
38 printf("text: %s\n", edje_object_part_text_unescaped_get(obj, part)); 46 printf("text: %s\n", edje_object_part_text_unescaped_get(obj, part));
39} 47}
40 48
49static void
50_on_mouse_down(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info EINA_UNUSED)
51{
52 lang_idx = (lang_idx + 1) % (sizeof (lang)/ sizeof (lang[0]));
53 fprintf(stderr, "Setting lang to '%s'\n", lang[lang_idx]);
54 setenv("LANGUAGE", lang[lang_idx], 1);
55 edje_language_set(lang[lang_idx]);
56}
41int 57int
42main(int argc EINA_UNUSED, char *argv[] EINA_UNUSED) 58main(int argc EINA_UNUSED, char *argv[] EINA_UNUSED)
43{ 59{
@@ -77,9 +93,9 @@ main(int argc EINA_UNUSED, char *argv[] EINA_UNUSED)
77 evas_object_resize(edje_obj, WIDTH - 40, HEIGHT - 40); 93 evas_object_resize(edje_obj, WIDTH - 40, HEIGHT - 40);
78 evas_object_show(edje_obj); 94 evas_object_show(edje_obj);
79 95
96 edje_language_set("en_IN");
80 edje_object_text_change_cb_set(edje_obj, _on_text_change, NULL); 97 edje_object_text_change_cb_set(edje_obj, _on_text_change, NULL);
81 edje_object_part_text_set(edje_obj, "part_one", "one"); 98 edje_object_part_text_set(edje_obj, "part_two", "<b>Click here");
82 edje_object_part_text_set(edje_obj, "part_two", "<b>two");
83 99
84 edje_object_part_text_select_allow_set(edje_obj, "part_two", EINA_TRUE); 100 edje_object_part_text_select_allow_set(edje_obj, "part_two", EINA_TRUE);
85 edje_object_part_text_select_all(edje_obj, "part_two"); 101 edje_object_part_text_select_all(edje_obj, "part_two");
@@ -87,6 +103,7 @@ main(int argc EINA_UNUSED, char *argv[] EINA_UNUSED)
87 edje_object_part_text_select_none(edje_obj, "part_two"); 103 edje_object_part_text_select_none(edje_obj, "part_two");
88 printf("selection: %s\n", edje_object_part_text_selection_get(edje_obj, "part_two")); 104 printf("selection: %s\n", edje_object_part_text_selection_get(edje_obj, "part_two"));
89 105
106 evas_object_event_callback_add(edje_obj, EVAS_CALLBACK_MOUSE_DOWN, _on_mouse_down, NULL);
90 ecore_evas_show(ee); 107 ecore_evas_show(ee);
91 108
92 ecore_main_loop_begin(); 109 ecore_main_loop_begin();
diff --git a/src/examples/edje/en_IN/domain_name.mo b/src/examples/edje/en_IN/domain_name.mo
new file mode 100644
index 0000000000..f723b0c042
--- /dev/null
+++ b/src/examples/edje/en_IN/domain_name.mo
Binary files differ
diff --git a/src/examples/edje/hi_IN/domain_name.mo b/src/examples/edje/hi_IN/domain_name.mo
new file mode 100644
index 0000000000..3abf69472a
--- /dev/null
+++ b/src/examples/edje/hi_IN/domain_name.mo
Binary files differ
diff --git a/src/examples/edje/ta_IN/domain_name.mo b/src/examples/edje/ta_IN/domain_name.mo
new file mode 100644
index 0000000000..9d62babf84
--- /dev/null
+++ b/src/examples/edje/ta_IN/domain_name.mo
Binary files differ
diff --git a/src/examples/edje/text.edc b/src/examples/edje/text.edc
index 257a078660..4c0bf30a0d 100644
--- a/src/examples/edje/text.edc
+++ b/src/examples/edje/text.edc
@@ -18,11 +18,40 @@ collections {
18 name: "example_group"; 18 name: "example_group";
19 max: 500 500; 19 max: 500 500;
20 min: 50 50; 20 min: 50 50;
21 21 translation {
22 file {
23 locale: en_IN;
24 source: domain_name.mo;
25 }
26 file {
27 locale: hi_IN;
28 source: domain_name.mo;
29 }
30 file {
31 locale: ta_IN;
32 source: domain_name.mo;
33 }
34 }
22 styles { 35 styles {
23 style { 36 style {
24 name: "textblock_style"; 37 name: "textblock_style_en";
25 base: "font=Sans font_size=22 color=#600 wrap=word"; 38 base: "font=Sans font_size=22 color=#f00 wrap=word";
39 tag: "br" "\n";
40 tag: "hilight" "+ font_weight=Bold";
41 tag: "b" "+ font_weight=Bold";
42 tag: "tab" "\t";
43 }
44 style {
45 name: "textblock_style_ta";
46 base: "font=Sans font_size=22 color=#000 wrap=word";
47 tag: "br" "\n";
48 tag: "hilight" "+ font_weight=Bold";
49 tag: "b" "+ font_weight=Bold";
50 tag: "tab" "\t";
51 }
52 style {
53 name: "textblock_style_hi";
54 base: "font=Sans font_size=22 color=#00f wrap=word";
26 tag: "br" "\n"; 55 tag: "br" "\n";
27 tag: "hilight" "+ font_weight=Bold"; 56 tag: "hilight" "+ font_weight=Bold";
28 tag: "b" "+ font_weight=Bold"; 57 tag: "b" "+ font_weight=Bold";
@@ -40,6 +69,8 @@ collections {
40 rel1.relative: 0.0 0.0; 69 rel1.relative: 0.0 0.0;
41 rel2.relative: 1.0 0.5; 70 rel2.relative: 1.0 0.5;
42 text { 71 text {
72 text : "LOADING";
73 domain: "domain_name";
43 font: "arial"; 74 font: "arial";
44 size: 22; 75 size: 22;
45 min: 1 1; 76 min: 1 1;
@@ -58,11 +89,50 @@ collections {
58 rel1.relative: 0.0 0.5; 89 rel1.relative: 0.0 0.5;
59 rel2.relative: 1.0 1.0; 90 rel2.relative: 1.0 1.0;
60 text { 91 text {
61 style: "textblock_style"; 92 style: "textblock_style_en";
93 min: 1 1;
94 }
95 }
96 description {
97 inherit: "default" 0.0;
98 state: "one" 0.0;
99 text {
100 style: "textblock_style_hi";
101 min: 1 1;
102 }
103 }
104 description {
105 inherit: "default" 0.0;
106 state: "two" 0.0;
107 text {
108 style: "textblock_style_ta";
62 min: 1 1; 109 min: 1 1;
63 } 110 }
64 } 111 }
65 } 112 }
66 } 113 }
114 programs {
115 program {
116 signal: "edje,language,hi_IN";
117 source: "edje";
118 script {
119 set_state(PART:"part_two", "one", 1.0);
120 }
121 }
122 program {
123 signal: "edje,language,ta_IN";
124 source: "edje";
125 script {
126 set_state(PART:"part_two", "two", 1.0);
127 }
128 }
129 program {
130 signal: "edje,language,en_IN";
131 source: "edje";
132 script {
133 set_state(PART:"part_two", "default", 1.0);
134 }
135 }
136 }
67 } 137 }
68} 138}