forked from enlightenment/efl
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>
This commit is contained in:
parent
ed01a32c13
commit
26b27319b4
|
@ -154,6 +154,8 @@ Eina_Bool current_group_inherit = EINA_FALSE;
|
||||||
static Edje_Program *sequencing = NULL;
|
static Edje_Program *sequencing = NULL;
|
||||||
static Eina_List *sequencing_lookups = NULL;
|
static Eina_List *sequencing_lookups = NULL;
|
||||||
|
|
||||||
|
Eina_List *po_files;
|
||||||
|
|
||||||
struct _Edje_Cc_Handlers_Hierarchy_Info
|
struct _Edje_Cc_Handlers_Hierarchy_Info
|
||||||
{ /* Struct that keeps globals value to impl hierarchy */
|
{ /* Struct that keeps globals value to impl hierarchy */
|
||||||
Edje_Part_Collection_Directory_Entry *current_de;
|
Edje_Part_Collection_Directory_Entry *current_de;
|
||||||
|
@ -3056,23 +3058,23 @@ st_collections_group_vibration_sample_source(void)
|
||||||
..
|
..
|
||||||
file {
|
file {
|
||||||
locale: "en_IN";
|
locale: "en_IN";
|
||||||
source: "domain_name.mo";
|
source: "domain_name.po";
|
||||||
}
|
}
|
||||||
file {
|
file {
|
||||||
locale: "en_US";
|
locale: "en_US";
|
||||||
source: "domain_name.mo";
|
source: "domain_name.po";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@description
|
@description
|
||||||
The file block defines the mo file.
|
The file block defines the po or mo file.
|
||||||
@endblock
|
@endblock
|
||||||
@property
|
@property
|
||||||
name
|
name
|
||||||
@parameters
|
@parameters
|
||||||
[locale name]
|
[locale name]
|
||||||
@effect
|
@effect
|
||||||
Used to include each mo file. The full path to the directory holding
|
Used to include each po or mo file. The full path to the directory holding
|
||||||
the mo file can be defined later with edje_cc's "-md" option.
|
the po or mo file can be defined later with edje_cc's "-md" option.
|
||||||
|
|
||||||
@since 1.15
|
@since 1.15
|
||||||
@endproperty
|
@endproperty
|
||||||
|
@ -3122,10 +3124,10 @@ st_collections_group_translation_file_locale(void)
|
||||||
@property
|
@property
|
||||||
source
|
source
|
||||||
@parameters
|
@parameters
|
||||||
[mo file name]
|
[po file name or Mo file name]
|
||||||
@effect
|
@effect
|
||||||
The mo source file name (Source should be a valid mo file.
|
The po or mo source file name (Source should be a valid po or mo file.
|
||||||
Only mo files are supported now)
|
Only po or mo files are supported now)
|
||||||
@since 1.15
|
@since 1.15
|
||||||
@endproperty
|
@endproperty
|
||||||
*/
|
*/
|
||||||
|
@ -3134,7 +3136,7 @@ static void
|
||||||
st_collections_group_translation_file_source(void)
|
st_collections_group_translation_file_source(void)
|
||||||
{
|
{
|
||||||
Edje_Mo *mo_entry;
|
Edje_Mo *mo_entry;
|
||||||
|
char *mo_path_str;
|
||||||
check_arg_count(1);
|
check_arg_count(1);
|
||||||
|
|
||||||
if (!edje_file->mo_dir->mo_entries)
|
if (!edje_file->mo_dir->mo_entries)
|
||||||
|
|
|
@ -169,6 +169,8 @@ struct _Mo_Write
|
||||||
{
|
{
|
||||||
Eet_File *ef;
|
Eet_File *ef;
|
||||||
Edje_Mo *mo_entry;
|
Edje_Mo *mo_entry;
|
||||||
|
char *mo_path;
|
||||||
|
Ecore_Exe *exe;
|
||||||
char *errstr;
|
char *errstr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -205,6 +207,8 @@ static int pending_threads = 0;
|
||||||
|
|
||||||
static 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));
|
static 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));
|
||||||
|
|
||||||
|
extern Eina_List *po_files;
|
||||||
|
|
||||||
Edje_File *edje_file = NULL;
|
Edje_File *edje_file = NULL;
|
||||||
Eina_List *edje_collections = NULL;
|
Eina_List *edje_collections = NULL;
|
||||||
Eina_Hash *edje_collections_lookup = NULL;
|
Eina_Hash *edje_collections_lookup = NULL;
|
||||||
|
@ -1232,6 +1236,8 @@ data_thread_mo(void *data, Ecore_Thread *thread EINA_UNUSED)
|
||||||
eina_file_map_free(f, m);
|
eina_file_map_free(f, m);
|
||||||
}
|
}
|
||||||
eina_file_close(f);
|
eina_file_close(f);
|
||||||
|
if (mw->mo_path)
|
||||||
|
ecore_file_remove(mo_path);
|
||||||
|
|
||||||
INF("Wrote %9i bytes (%4iKb) for \"%s\" %s mo entry \"%s\"",
|
INF("Wrote %9i bytes (%4iKb) for \"%s\" %s mo entry \"%s\"",
|
||||||
bytes, (bytes + 512) / 1024, moid_str, "RAW PCM", mw->mo_entry->locale);
|
bytes, (bytes + 512) / 1024, moid_str, "RAW PCM", mw->mo_entry->locale);
|
||||||
|
@ -1249,27 +1255,25 @@ data_thread_mo_end(void *data, Ecore_Thread *thread EINA_UNUSED)
|
||||||
error_and_abort(mw->ef, mw->errstr);
|
error_and_abort(mw->ef, mw->errstr);
|
||||||
free(mw->errstr);
|
free(mw->errstr);
|
||||||
}
|
}
|
||||||
|
if (mw->mo_path)
|
||||||
|
free(mw->mo_path);
|
||||||
free(mw);
|
free(mw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Eina_Bool
|
||||||
static void
|
_exe_del_cb(void *data EINA_UNUSED, int evtype EINA_UNUSED, void *evinfo)
|
||||||
data_write_mo(Eet_File *ef, int *mo_num)
|
|
||||||
{
|
{
|
||||||
if ((edje_file) && (edje_file->mo_dir))
|
Mo_Write *mw = data;
|
||||||
|
Ecore_Exe_Event_Del *ev = evinfo;
|
||||||
|
if (!ev->exe) return ECORE_CALLBACK_RENEW;
|
||||||
|
if (ecore_exe_data_get(ev->exe) != mw) return ECORE_CALLBACK_RENEW;
|
||||||
|
if (ev->exit_code != 0)
|
||||||
{
|
{
|
||||||
int i;
|
error_and_abort(mw->ef, "Creation of .mo from .po failed.");
|
||||||
|
return ECORE_CALLBACK_CANCEL;
|
||||||
for (i = 0; i < (int)edje_file->mo_dir->mo_entries_count; i++)
|
}
|
||||||
|
if (ecore_file_exists(mw->mo_path))
|
||||||
{
|
{
|
||||||
Mo_Write *mw;
|
|
||||||
|
|
||||||
mw = calloc(1, sizeof(Mo_Write));
|
|
||||||
if (!mw) continue;
|
|
||||||
mw->ef = ef;
|
|
||||||
mw->mo_entry = &edje_file->mo_dir->mo_entries[i];
|
|
||||||
*mo_num += 1;
|
|
||||||
pending_threads++;
|
|
||||||
if (threads)
|
if (threads)
|
||||||
ecore_thread_run(data_thread_mo, data_thread_mo_end, NULL, mw);
|
ecore_thread_run(data_thread_mo, data_thread_mo_end, NULL, mw);
|
||||||
else
|
else
|
||||||
|
@ -1278,6 +1282,70 @@ data_write_mo(Eet_File *ef, int *mo_num)
|
||||||
data_thread_mo_end(mw, NULL);
|
data_thread_mo_end(mw, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return ECORE_CALLBACK_RENEW;
|
||||||
|
if (pending_threads <= 0) ecore_main_loop_quit();
|
||||||
|
return ECORE_CALLBACK_CANCEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
data_write_mo(Eet_File *ef, int *mo_num)
|
||||||
|
{
|
||||||
|
if ((edje_file) && (edje_file->mo_dir))
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char *po_entry;
|
||||||
|
char *sub_str;
|
||||||
|
char buf[PATH_MAX];
|
||||||
|
Eina_List *ll;
|
||||||
|
char *dir_path = NULL;
|
||||||
|
char mo_path[PATH_MAX];
|
||||||
|
char po_path[PATH_MAX];
|
||||||
|
|
||||||
|
for (i = 0; i < (int)edje_file->mo_dir->mo_entries_count; i++)
|
||||||
|
{
|
||||||
|
Mo_Write *mw;
|
||||||
|
mw = calloc(1, sizeof(Mo_Write));
|
||||||
|
if (!mw) continue;
|
||||||
|
mw->ef = ef;
|
||||||
|
mw->mo_entry = &edje_file->mo_dir->mo_entries[i];
|
||||||
|
*mo_num += 1;
|
||||||
|
pending_threads++;
|
||||||
|
|
||||||
|
po_entry = strdup(mw->mo_entry->mo_src);
|
||||||
|
sub_str = strstr(mw->mo_entry->mo_src, ".po");
|
||||||
|
|
||||||
|
if (sub_str)
|
||||||
|
{
|
||||||
|
sub_str[1] = 'm';
|
||||||
|
EINA_LIST_FOREACH(mo_dirs, ll, dir_path)
|
||||||
|
{
|
||||||
|
snprintf((char *)mo_path, sizeof(mo_path), "%s/%s/%s", dir_path, mw->mo_entry->locale, mw->mo_entry->mo_src);
|
||||||
|
snprintf((char *)po_path, sizeof(po_path), "%s/%s/%s", dir_path, mw->mo_entry->locale, po_entry);
|
||||||
|
if (ecore_file_exists(po_path))
|
||||||
|
{
|
||||||
|
snprintf(buf, sizeof(buf), "msgfmt -o %s %s", mo_path, po_path);
|
||||||
|
mw->mo_path = strdup(mo_path);
|
||||||
|
mw->exe = ecore_exe_run(buf, mw);
|
||||||
|
ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
|
||||||
|
_exe_del_cb, mw);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
error_and_abort(mw->ef, "Invalid .po file.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (threads)
|
||||||
|
ecore_thread_run(data_thread_mo, data_thread_mo_end, NULL, mw);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data_thread_mo(mw, NULL);
|
||||||
|
data_thread_mo_end(mw, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(po_entry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,11 @@
|
||||||
|
msgid "LOADING"
|
||||||
|
msgstr "Loading..."
|
||||||
|
|
||||||
|
msgid "LANG"
|
||||||
|
msgstr "Language English"
|
||||||
|
|
||||||
|
msgid "SYSTEM LANGUAGE"
|
||||||
|
msgstr "System Language"
|
||||||
|
|
||||||
|
msgid "CHANGED"
|
||||||
|
msgstr "Changed"
|
Binary file not shown.
|
@ -0,0 +1,11 @@
|
||||||
|
msgid "LOADING"
|
||||||
|
msgstr "लोड हो रहा है..."
|
||||||
|
|
||||||
|
msgid "LANG"
|
||||||
|
msgstr "भाषा हिन्दी"
|
||||||
|
|
||||||
|
msgid "SYSTEM LANGUAGE"
|
||||||
|
msgstr "सिस्टम भाषा"
|
||||||
|
|
||||||
|
msgid "CHANGED"
|
||||||
|
msgstr "बदल"
|
|
@ -21,15 +21,15 @@ collections {
|
||||||
translation {
|
translation {
|
||||||
file {
|
file {
|
||||||
locale: en_IN;
|
locale: en_IN;
|
||||||
source: domain_name.mo; /* Can be either .po file or .mo file */
|
source: domain_name.po; /* Can be either .po file or .mo file*/
|
||||||
}
|
}
|
||||||
file {
|
file {
|
||||||
locale: hi_IN;
|
locale: hi_IN;
|
||||||
source: domain_name.mo;
|
source: domain_name.po;
|
||||||
}
|
}
|
||||||
file {
|
file {
|
||||||
locale: ta_IN;
|
locale: ta_IN;
|
||||||
source: domain_name.mo;
|
source: domain_name.po;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
styles {
|
styles {
|
||||||
|
@ -144,11 +144,11 @@ collections {
|
||||||
translation {
|
translation {
|
||||||
file {
|
file {
|
||||||
locale: en_IN;
|
locale: en_IN;
|
||||||
source: domain_name.mo;
|
source: domain_name.po;
|
||||||
}
|
}
|
||||||
file {
|
file {
|
||||||
locale: hi_IN;
|
locale: hi_IN;
|
||||||
source: domain_name.mo;
|
source: domain_name.po;
|
||||||
}
|
}
|
||||||
file {
|
file {
|
||||||
locale: ta_IN;
|
locale: ta_IN;
|
||||||
|
@ -267,11 +267,11 @@ collections {
|
||||||
translation {
|
translation {
|
||||||
file {
|
file {
|
||||||
locale: en_IN;
|
locale: en_IN;
|
||||||
source: domain_name.mo;
|
source: domain_name.po;
|
||||||
}
|
}
|
||||||
file {
|
file {
|
||||||
locale: hi_IN;
|
locale: hi_IN;
|
||||||
source: domain_name.mo;
|
source: domain_name.po;
|
||||||
}
|
}
|
||||||
file {
|
file {
|
||||||
locale: ta_IN;
|
locale: ta_IN;
|
||||||
|
@ -390,11 +390,11 @@ collections {
|
||||||
translation {
|
translation {
|
||||||
file {
|
file {
|
||||||
locale: en_IN;
|
locale: en_IN;
|
||||||
source: domain_name.mo;
|
source: domain_name.po;
|
||||||
}
|
}
|
||||||
file {
|
file {
|
||||||
locale: hi_IN;
|
locale: hi_IN;
|
||||||
source: domain_name.mo;
|
source: domain_name.po;
|
||||||
}
|
}
|
||||||
file {
|
file {
|
||||||
locale: ta_IN;
|
locale: ta_IN;
|
||||||
|
|
|
@ -84,6 +84,8 @@ _edje_extract_mo_files(Edje *ed)
|
||||||
Edje_Mo *mo_entry;
|
Edje_Mo *mo_entry;
|
||||||
char out[PATH_MAX];
|
char out[PATH_MAX];
|
||||||
char outdir[PATH_MAX];
|
char outdir[PATH_MAX];
|
||||||
|
char *sub_str;
|
||||||
|
char *mo_src;
|
||||||
|
|
||||||
mo_entry = &ed->file->mo_dir->mo_entries[i];
|
mo_entry = &ed->file->mo_dir->mo_entries[i];
|
||||||
|
|
||||||
|
@ -101,8 +103,14 @@ _edje_extract_mo_files(Edje *ed)
|
||||||
"%s/edje/%s/LC_MESSAGES",
|
"%s/edje/%s/LC_MESSAGES",
|
||||||
cache_path, mo_entry->locale);
|
cache_path, mo_entry->locale);
|
||||||
ecore_file_mkpath(outdir);
|
ecore_file_mkpath(outdir);
|
||||||
|
mo_src = strdup(mo_entry->mo_src);
|
||||||
|
sub_str = strstr(mo_src, ".po");
|
||||||
|
|
||||||
|
if (sub_str)
|
||||||
|
sub_str[1] = 'm';
|
||||||
|
|
||||||
snprintf(out, sizeof(out), "%s/%s-%s",
|
snprintf(out, sizeof(out), "%s/%s-%s",
|
||||||
outdir, ed->file->fid, mo_entry->mo_src);
|
outdir, ed->file->fid, mo_src);
|
||||||
if (ecore_file_exists(out))
|
if (ecore_file_exists(out))
|
||||||
{
|
{
|
||||||
if (ed->file->mtime > ecore_file_mod_time(out))
|
if (ed->file->mtime > ecore_file_mod_time(out))
|
||||||
|
@ -122,6 +130,7 @@ _edje_extract_mo_files(Edje *ed)
|
||||||
else
|
else
|
||||||
ERR("Could not open for writing mo: %s: %s", out, strerror(errno));
|
ERR("Could not open for writing mo: %s: %s", out, strerror(errno));
|
||||||
}
|
}
|
||||||
|
free(mo_src);
|
||||||
}
|
}
|
||||||
|
|
||||||
eina_strbuf_reset(mo_id_str);
|
eina_strbuf_reset(mo_id_str);
|
||||||
|
|
|
@ -695,7 +695,7 @@ struct _Edje_Sound_Directory
|
||||||
struct _Edje_Mo /*Mo Sample*/
|
struct _Edje_Mo /*Mo Sample*/
|
||||||
{
|
{
|
||||||
const char *locale; /* the nominal name of the Mo */
|
const char *locale; /* the nominal name of the Mo */
|
||||||
const char *mo_src; /* Mo source file */
|
char *mo_src; /* Mo source file */
|
||||||
int id; /* the id no. of the Mo file */
|
int id; /* the id no. of the Mo file */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue