summaryrefslogtreecommitdiff
path: root/src/lib/edje/edje_text.c
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/lib/edje/edje_text.c
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/lib/edje/edje_text.c')
-rw-r--r--src/lib/edje/edje_text.c61
1 files changed, 52 insertions, 9 deletions
diff --git a/src/lib/edje/edje_text.c b/src/lib/edje/edje_text.c
index 057d6d0..27a9ca7 100644
--- a/src/lib/edje/edje_text.c
+++ b/src/lib/edje/edje_text.c
@@ -14,6 +14,7 @@
14 * function everywhere instead of calling evas_object_geometry_get() 14 * function everywhere instead of calling evas_object_geometry_get()
15 * directly. 15 * directly.
16 */ 16 */
17
17static inline void 18static inline void
18part_get_geometry(Edje_Real_Part *rp, Evas_Coord *w, Evas_Coord *h) 19part_get_geometry(Edje_Real_Part *rp, Evas_Coord *w, Evas_Coord *h)
19{ 20{
@@ -26,6 +27,38 @@ part_get_geometry(Edje_Real_Part *rp, Evas_Coord *w, Evas_Coord *h)
26 } 27 }
27} 28}
28 29
30const char *
31_set_translated_string(Edje *ed, Edje_Real_Part *ep)
32{
33 const char *domain = NULL;
34 const char *text = NULL;
35 Edje_Part_Description_Text *chosen_desc;
36
37 chosen_desc = (Edje_Part_Description_Text*)ep->chosen_description;
38 domain = chosen_desc->text.domain;
39 text = edje_string_get(&chosen_desc->text.text);
40
41 if (domain && text)
42 {
43#ifdef ENABLE_NLS
44 char p[PATH_MAX];
45 char *curpath;
46 char *curlocale;
47
48 snprintf(p, sizeof(p), "%s-%s", ed->file->fid, domain);
49
50 curlocale = setlocale(LC_ALL, "");
51 curpath = bindtextdomain(p, _edje_cache_path);
52
53 text = dgettext(p, text);
54
55 bindtextdomain(p, curpath);
56 setlocale(LC_ALL, curlocale);
57#endif
58 }
59 return text;
60}
61
29void 62void
30_edje_text_init(void) 63_edje_text_init(void)
31{ 64{
@@ -162,18 +195,18 @@ void
162_edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep, 195_edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
163 Edje_Calc_Params *params, 196 Edje_Calc_Params *params,
164 Edje_Part_Description_Text *chosen_desc, 197 Edje_Part_Description_Text *chosen_desc,
165 Eina_Bool calc_only) 198 Eina_Bool calc_only)
166{ 199{
167 const char *text = NULL; 200 const char *text = NULL;
168 const char *font; 201 const char *font;
169 char *font2 = NULL; 202 char *font2 = NULL;
170 char *sfont = NULL; 203 char *sfont = NULL;
171 int size; 204 int size;
172 const char *filter, *source_name; 205 const char *filter, *source_name;
173 Eina_List *filter_sources = NULL, *prev_sources = NULL, *li; 206 Eina_List *filter_sources = NULL, *prev_sources = NULL, *li;
174 Evas_Coord tw, th; 207 Evas_Coord tw, th;
175 Evas_Coord sw, sh; 208 Evas_Coord sw, sh;
176 int inlined_font = 0, free_text = 0; 209 int inlined_font = 0, free_text = 0;
177 Eina_Bool same_text = EINA_FALSE; 210 Eina_Bool same_text = EINA_FALSE;
178 FLOAT_T sc; 211 FLOAT_T sc;
179 212
@@ -181,7 +214,17 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
181 (!ep->typedata.text)) return; 214 (!ep->typedata.text)) return;
182 sc = DIV(ed->scale, ed->file->base_scale); 215 sc = DIV(ed->scale, ed->file->base_scale);
183 if (sc == ZERO) sc = DIV(_edje_scale, ed->file->base_scale); 216 if (sc == ZERO) sc = DIV(_edje_scale, ed->file->base_scale);
184 text = edje_string_get(&chosen_desc->text.text); 217
218 if (chosen_desc->text.domain)
219 {
220 if (!chosen_desc->text.text.translated)
221 chosen_desc->text.text.translated = _set_translated_string(ed, ep);
222 if (chosen_desc->text.text.translated)
223 text = chosen_desc->text.text.translated;
224 }
225
226 if (!text)
227 text = edje_string_get(&chosen_desc->text.text);
185 font = _edje_text_class_font_get(ed, chosen_desc, &size, &sfont); 228 font = _edje_text_class_font_get(ed, chosen_desc, &size, &sfont);
186 filter = chosen_desc->text.filter.str; 229 filter = chosen_desc->text.filter.str;
187 230