diff options
author | katpavalli <katpaga.a@samsung.com> | 2015-05-13 18:08:04 +0200 |
---|---|---|
committer | Cedric BAIL <cedric@osg.samsung.com> | 2015-05-14 18:41:47 +0200 |
commit | dca95fb45af216068b5476f7110639cb3715b96b (patch) | |
tree | 49691183f3c708bebf663a3f8a34d00028ae6f5d /src/bin/edje/edje_cc_out.c | |
parent | a312e304bf181777aa8190f4281ebdac49a827a5 (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 '')
-rwxr-xr-x | src/bin/edje/edje_cc_out.c | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/src/bin/edje/edje_cc_out.c b/src/bin/edje/edje_cc_out.c index e1627070d3..95798fb5b0 100755 --- a/src/bin/edje/edje_cc_out.c +++ b/src/bin/edje/edje_cc_out.c | |||
@@ -116,6 +116,7 @@ typedef struct _Head_Write Head_Write; | |||
116 | typedef struct _Fonts_Write Fonts_Write; | 116 | typedef struct _Fonts_Write Fonts_Write; |
117 | typedef struct _Image_Write Image_Write; | 117 | typedef struct _Image_Write Image_Write; |
118 | typedef struct _Sound_Write Sound_Write; | 118 | typedef struct _Sound_Write Sound_Write; |
119 | typedef struct _Mo_Write Mo_Write; | ||
119 | typedef struct _Vibration_Write Vibration_Write; | 120 | typedef struct _Vibration_Write Vibration_Write; |
120 | typedef struct _Group_Write Group_Write; | 121 | typedef struct _Group_Write Group_Write; |
121 | typedef struct _License_Write License_Write; | 122 | typedef struct _License_Write License_Write; |
@@ -164,6 +165,13 @@ struct _Sound_Write | |||
164 | int i; | 165 | int i; |
165 | }; | 166 | }; |
166 | 167 | ||
168 | struct _Mo_Write | ||
169 | { | ||
170 | Eet_File *ef; | ||
171 | Edje_Mo *mo_entry; | ||
172 | char *errstr; | ||
173 | }; | ||
174 | |||
167 | struct _Vibration_Write | 175 | struct _Vibration_Write |
168 | { | 176 | { |
169 | Eet_File *ef; | 177 | Eet_File *ef; |
@@ -1170,6 +1178,109 @@ data_write_sounds(Eet_File *ef, int *sound_num) | |||
1170 | } | 1178 | } |
1171 | 1179 | ||
1172 | static void | 1180 | static void |
1181 | data_thread_mo(void *data, Ecore_Thread *thread EINA_UNUSED) | ||
1182 | { | ||
1183 | Mo_Write *mw = data; | ||
1184 | char buf[PATH_MAX]; | ||
1185 | Eina_List *ll; | ||
1186 | |||
1187 | char *dir_path = NULL; | ||
1188 | char mo_path[PATH_MAX]; | ||
1189 | char moid_str[50]; | ||
1190 | Eina_File *f = NULL; | ||
1191 | void *m = NULL; | ||
1192 | int bytes = 0; | ||
1193 | |||
1194 | // Search the mo file in all the -md ( mo directory ) | ||
1195 | EINA_LIST_FOREACH(mo_dirs, ll, dir_path) | ||
1196 | { | ||
1197 | snprintf((char *)mo_path, sizeof(mo_path), "%s/%s/%s", dir_path, mw->mo_entry->locale, mw->mo_entry->mo_src); | ||
1198 | f = eina_file_open(mo_path, 0); | ||
1199 | if (f) break; | ||
1200 | } | ||
1201 | if (!f) | ||
1202 | { | ||
1203 | snprintf((char *)mo_path, sizeof(mo_path), "%s", mw->mo_entry->mo_src); | ||
1204 | f = eina_file_open(mo_path, 0); | ||
1205 | } | ||
1206 | |||
1207 | if (f) using_file(mo_path, 'S'); | ||
1208 | |||
1209 | if (!f) | ||
1210 | { | ||
1211 | snprintf(buf, sizeof(buf), "Unable to load mo data of: %s", mo_path); | ||
1212 | ERR("%s", buf); | ||
1213 | mw->errstr = strdup(buf); | ||
1214 | exit(-1); | ||
1215 | } | ||
1216 | |||
1217 | snprintf(moid_str, sizeof(moid_str), "edje/mo/%i/%s/LC_MESSAGES", mw->mo_entry->id, mw->mo_entry->locale); | ||
1218 | m = eina_file_map_all(f, EINA_FILE_WILLNEED); | ||
1219 | if (m) | ||
1220 | { | ||
1221 | bytes = eet_write(mw->ef, moid_str, m, eina_file_size_get(f), EET_COMPRESSION_NONE); | ||
1222 | if (eina_file_map_faulted(f, m)) | ||
1223 | { | ||
1224 | snprintf(buf, sizeof(buf), "File access error when reading '%s'", | ||
1225 | eina_file_filename_get(f)); | ||
1226 | ERR("%s", buf); | ||
1227 | mw->errstr = strdup(buf); | ||
1228 | eina_file_close(f); | ||
1229 | exit(-1); | ||
1230 | } | ||
1231 | eina_file_map_free(f, m); | ||
1232 | } | ||
1233 | eina_file_close(f); | ||
1234 | |||
1235 | INF("Wrote %9i bytes (%4iKb) for \"%s\" %s mo entry \"%s\"", | ||
1236 | bytes, (bytes + 512) / 1024, moid_str, "RAW PCM", mw->mo_entry->locale); | ||
1237 | |||
1238 | } | ||
1239 | |||
1240 | static void | ||
1241 | data_thread_mo_end(void *data, Ecore_Thread *thread EINA_UNUSED) | ||
1242 | { | ||
1243 | Mo_Write *mw = data; | ||
1244 | pending_threads--; | ||
1245 | if (pending_threads <= 0) ecore_main_loop_quit(); | ||
1246 | if (mw->errstr) | ||
1247 | { | ||
1248 | error_and_abort(mw->ef, mw->errstr); | ||
1249 | free(mw->errstr); | ||
1250 | } | ||
1251 | free(mw); | ||
1252 | } | ||
1253 | |||
1254 | |||
1255 | static void | ||
1256 | data_write_mo(Eet_File *ef, int *mo_num) | ||
1257 | { | ||
1258 | if ((edje_file) && (edje_file->mo_dir)) | ||
1259 | { | ||
1260 | int i; | ||
1261 | |||
1262 | for (i = 0; i < (int)edje_file->mo_dir->mo_entries_count; i++) | ||
1263 | { | ||
1264 | Mo_Write *mw; | ||
1265 | |||
1266 | mw = calloc(1, sizeof(Mo_Write)); | ||
1267 | if (!mw) continue; | ||
1268 | mw->ef = ef; | ||
1269 | mw->mo_entry = &edje_file->mo_dir->mo_entries[i]; | ||
1270 | *mo_num += 1; | ||
1271 | pending_threads++; | ||
1272 | if (threads) | ||
1273 | ecore_thread_run(data_thread_mo, data_thread_mo_end, NULL, mw); | ||
1274 | else | ||
1275 | { | ||
1276 | data_thread_mo(mw, NULL); | ||
1277 | data_thread_mo_end(mw, NULL); | ||
1278 | } | ||
1279 | } | ||
1280 | } | ||
1281 | } | ||
1282 | |||
1283 | static void | ||
1173 | data_thread_vibrations(void *data, Ecore_Thread *thread EINA_UNUSED) | 1284 | data_thread_vibrations(void *data, Ecore_Thread *thread EINA_UNUSED) |
1174 | { | 1285 | { |
1175 | Vibration_Write *vw = data; | 1286 | Vibration_Write *vw = data; |
@@ -1986,6 +2097,7 @@ data_write(void) | |||
1986 | Eet_Error err; | 2097 | Eet_Error err; |
1987 | int image_num = 0; | 2098 | int image_num = 0; |
1988 | int sound_num = 0; | 2099 | int sound_num = 0; |
2100 | int mo_num = 0; | ||
1989 | int vibration_num = 0; | 2101 | int vibration_num = 0; |
1990 | int font_num = 0; | 2102 | int font_num = 0; |
1991 | int collection_num = 0; | 2103 | int collection_num = 0; |
@@ -2047,6 +2159,8 @@ data_write(void) | |||
2047 | INF("fonts: %3.5f", ecore_time_get() - t); t = ecore_time_get(); | 2159 | INF("fonts: %3.5f", ecore_time_get() - t); t = ecore_time_get(); |
2048 | data_write_sounds(ef, &sound_num); | 2160 | data_write_sounds(ef, &sound_num); |
2049 | INF("sounds: %3.5f", ecore_time_get() - t); t = ecore_time_get(); | 2161 | INF("sounds: %3.5f", ecore_time_get() - t); t = ecore_time_get(); |
2162 | data_write_mo(ef, &mo_num); | ||
2163 | INF("mo: %3.5f", ecore_time_get() - t); t = ecore_time_get(); | ||
2050 | data_write_vibrations(ef, &vibration_num); | 2164 | data_write_vibrations(ef, &vibration_num); |
2051 | INF("vibrations: %3.5f", ecore_time_get() - t); t = ecore_time_get(); | 2165 | INF("vibrations: %3.5f", ecore_time_get() - t); t = ecore_time_get(); |
2052 | data_write_license(ef); | 2166 | data_write_license(ef); |