summaryrefslogtreecommitdiff
path: root/src/bin/edje/edje_cc_out.c
diff options
context:
space:
mode:
authorkatpavalli <katpaga.a@samsung.com>2015-06-11 10:40:32 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-06-11 10:40:55 +0200
commit26b27319b42baa40acda3acbccdfedeed4dad838 (patch)
tree6d83262e84f54b0ecca93f504adf6b2c8b1cb21b /src/bin/edje/edje_cc_out.c
parented01a32c136aaba8fb23a12afaf334b4c47fc62e (diff)
edje: add po file support in edc translation.
Summary: Implementation to support .po files in edc for translation 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 edje_cc -md . text.edc && gcc -o edje-text edje-text.c `pkg-config --libs --cflags ecore-evas edje evas ecore eo` ./edje-text 1) Click On the text "Click here" The language gets changed. Reviewers: shilpasingh, cedric Reviewed By: shilpasingh, cedric Subscribers: cedric, rajeshps, govi, poornima.srinivasan Differential Revision: https://phab.enlightenment.org/D2573 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to '')
-rwxr-xr-xsrc/bin/edje/edje_cc_out.c80
1 files changed, 74 insertions, 6 deletions
diff --git a/src/bin/edje/edje_cc_out.c b/src/bin/edje/edje_cc_out.c
index f755254286..485aa8c0dc 100755
--- a/src/bin/edje/edje_cc_out.c
+++ b/src/bin/edje/edje_cc_out.c
@@ -169,6 +169,8 @@ struct _Mo_Write
169{ 169{
170 Eet_File *ef; 170 Eet_File *ef;
171 Edje_Mo *mo_entry; 171 Edje_Mo *mo_entry;
172 char *mo_path;
173 Ecore_Exe *exe;
172 char *errstr; 174 char *errstr;
173}; 175};
174 176
@@ -205,6 +207,8 @@ static int pending_threads = 0;
205 207
206static void data_process_string(Edje_Part_Collection *pc, const char *prefix, char *s, void (*func)(Edje_Part_Collection *pc, char *name, char* ptr, int len)); 208static void data_process_string(Edje_Part_Collection *pc, const char *prefix, char *s, void (*func)(Edje_Part_Collection *pc, char *name, char* ptr, int len));
207 209
210extern Eina_List *po_files;
211
208Edje_File *edje_file = NULL; 212Edje_File *edje_file = NULL;
209Eina_List *edje_collections = NULL; 213Eina_List *edje_collections = NULL;
210Eina_Hash *edje_collections_lookup = NULL; 214Eina_Hash *edje_collections_lookup = NULL;
@@ -1232,6 +1236,8 @@ data_thread_mo(void *data, Ecore_Thread *thread EINA_UNUSED)
1232 eina_file_map_free(f, m); 1236 eina_file_map_free(f, m);
1233 } 1237 }
1234 eina_file_close(f); 1238 eina_file_close(f);
1239 if (mw->mo_path)
1240 ecore_file_remove(mo_path);
1235 1241
1236 INF("Wrote %9i bytes (%4iKb) for \"%s\" %s mo entry \"%s\"", 1242 INF("Wrote %9i bytes (%4iKb) for \"%s\" %s mo entry \"%s\"",
1237 bytes, (bytes + 512) / 1024, moid_str, "RAW PCM", mw->mo_entry->locale); 1243 bytes, (bytes + 512) / 1024, moid_str, "RAW PCM", mw->mo_entry->locale);
@@ -1249,9 +1255,38 @@ data_thread_mo_end(void *data, Ecore_Thread *thread EINA_UNUSED)
1249 error_and_abort(mw->ef, mw->errstr); 1255 error_and_abort(mw->ef, mw->errstr);
1250 free(mw->errstr); 1256 free(mw->errstr);
1251 } 1257 }
1258 if (mw->mo_path)
1259 free(mw->mo_path);
1252 free(mw); 1260 free(mw);
1253} 1261}
1254 1262
1263Eina_Bool
1264_exe_del_cb(void *data EINA_UNUSED, int evtype EINA_UNUSED, void *evinfo)
1265{
1266 Mo_Write *mw = data;
1267 Ecore_Exe_Event_Del *ev = evinfo;
1268 if (!ev->exe) return ECORE_CALLBACK_RENEW;
1269 if (ecore_exe_data_get(ev->exe) != mw) return ECORE_CALLBACK_RENEW;
1270 if (ev->exit_code != 0)
1271 {
1272 error_and_abort(mw->ef, "Creation of .mo from .po failed.");
1273 return ECORE_CALLBACK_CANCEL;
1274 }
1275 if (ecore_file_exists(mw->mo_path))
1276 {
1277 if (threads)
1278 ecore_thread_run(data_thread_mo, data_thread_mo_end, NULL, mw);
1279 else
1280 {
1281 data_thread_mo(mw, NULL);
1282 data_thread_mo_end(mw, NULL);
1283 }
1284 }
1285 else
1286 return ECORE_CALLBACK_RENEW;
1287 if (pending_threads <= 0) ecore_main_loop_quit();
1288 return ECORE_CALLBACK_CANCEL;
1289}
1255 1290
1256static void 1291static void
1257data_write_mo(Eet_File *ef, int *mo_num) 1292data_write_mo(Eet_File *ef, int *mo_num)
@@ -1259,24 +1294,57 @@ data_write_mo(Eet_File *ef, int *mo_num)
1259 if ((edje_file) && (edje_file->mo_dir)) 1294 if ((edje_file) && (edje_file->mo_dir))
1260 { 1295 {
1261 int i; 1296 int i;
1297 char *po_entry;
1298 char *sub_str;
1299 char buf[PATH_MAX];
1300 Eina_List *ll;
1301 char *dir_path = NULL;
1302 char mo_path[PATH_MAX];
1303 char po_path[PATH_MAX];
1262 1304
1263 for (i = 0; i < (int)edje_file->mo_dir->mo_entries_count; i++) 1305 for (i = 0; i < (int)edje_file->mo_dir->mo_entries_count; i++)
1264 { 1306 {
1265 Mo_Write *mw; 1307 Mo_Write *mw;
1266
1267 mw = calloc(1, sizeof(Mo_Write)); 1308 mw = calloc(1, sizeof(Mo_Write));
1268 if (!mw) continue; 1309 if (!mw) continue;
1269 mw->ef = ef; 1310 mw->ef = ef;
1270 mw->mo_entry = &edje_file->mo_dir->mo_entries[i]; 1311 mw->mo_entry = &edje_file->mo_dir->mo_entries[i];
1271 *mo_num += 1; 1312 *mo_num += 1;
1272 pending_threads++; 1313 pending_threads++;
1273 if (threads) 1314
1274 ecore_thread_run(data_thread_mo, data_thread_mo_end, NULL, mw); 1315 po_entry = strdup(mw->mo_entry->mo_src);
1275 else 1316 sub_str = strstr(mw->mo_entry->mo_src, ".po");
1317
1318 if (sub_str)
1276 { 1319 {
1277 data_thread_mo(mw, NULL); 1320 sub_str[1] = 'm';
1278 data_thread_mo_end(mw, NULL); 1321 EINA_LIST_FOREACH(mo_dirs, ll, dir_path)
1322 {
1323 snprintf((char *)mo_path, sizeof(mo_path), "%s/%s/%s", dir_path, mw->mo_entry->locale, mw->mo_entry->mo_src);
1324 snprintf((char *)po_path, sizeof(po_path), "%s/%s/%s", dir_path, mw->mo_entry->locale, po_entry);
1325 if (ecore_file_exists(po_path))
1326 {
1327 snprintf(buf, sizeof(buf), "msgfmt -o %s %s", mo_path, po_path);
1328 mw->mo_path = strdup(mo_path);
1329 mw->exe = ecore_exe_run(buf, mw);
1330 ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
1331 _exe_del_cb, mw);
1332 }
1333 else
1334 error_and_abort(mw->ef, "Invalid .po file.");
1335 }
1336 }
1337 else
1338 {
1339 if (threads)
1340 ecore_thread_run(data_thread_mo, data_thread_mo_end, NULL, mw);
1341 else
1342 {
1343 data_thread_mo(mw, NULL);
1344 data_thread_mo_end(mw, NULL);
1345 }
1279 } 1346 }
1347 free(po_entry);
1280 } 1348 }
1281 } 1349 }
1282} 1350}