aboutsummaryrefslogtreecommitdiffstats
path: root/reference
diff options
context:
space:
mode:
authorAndy Williams <andy@andywilliams.me>2017-12-06 12:46:15 +0000
committerAndy Williams <andy@andywilliams.me>2017-12-06 12:46:15 +0000
commit95c0ffad658aa57eb7d4ddeda4b444faeb051daa (patch)
treeb18041ad7587efd1d862c44f6da187ecdad6244c /reference
parentMove core_log to eina_log (diff)
downloadexamples-95c0ffad658aa57eb7d4ddeda4b444faeb051daa.tar.gz
ui: Add starter of a translation reference example
Diffstat (limited to 'reference')
-rw-r--r--reference/c/ui/meson.build1
-rw-r--r--reference/c/ui/po/LINGUAS0
-rw-r--r--reference/c/ui/po/POTFILES1
-rw-r--r--reference/c/ui/po/meson.build4
-rw-r--r--reference/c/ui/src/meson.build8
-rw-r--r--reference/c/ui/src/ui_translation.c54
6 files changed, 68 insertions, 0 deletions
diff --git a/reference/c/ui/meson.build b/reference/c/ui/meson.build
index 21002527..b42fa203 100644
--- a/reference/c/ui/meson.build
+++ b/reference/c/ui/meson.build
@@ -9,4 +9,5 @@ efl = dependency('efl-ui', version : '>=1.20.99')
inc = include_directories('.')
subdir('src')
+subdir('po')
diff --git a/reference/c/ui/po/LINGUAS b/reference/c/ui/po/LINGUAS
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/reference/c/ui/po/LINGUAS
diff --git a/reference/c/ui/po/POTFILES b/reference/c/ui/po/POTFILES
new file mode 100644
index 00000000..2d2079f3
--- /dev/null
+++ b/reference/c/ui/po/POTFILES
@@ -0,0 +1 @@
+src/ui_translation.c
diff --git a/reference/c/ui/po/meson.build b/reference/c/ui/po/meson.build
new file mode 100644
index 00000000..0f356129
--- /dev/null
+++ b/reference/c/ui/po/meson.build
@@ -0,0 +1,4 @@
+i18n = import('i18n')
+i18n.gettext('example_translation',
+ args : '--keyword=efl_ui_translatable_text_set:2')
+
diff --git a/reference/c/ui/src/meson.build b/reference/c/ui/src/meson.build
index 82793b42..07ff9fc6 100644
--- a/reference/c/ui/src/meson.build
+++ b/reference/c/ui/src/meson.build
@@ -13,3 +13,11 @@ executable('efl_reference_ui_container',
include_directories : inc,
install : true
)
+
+executable('efl_reference_ui_translation',
+ files(['ui_translation.c']),
+ dependencies : deps,
+ include_directories : inc,
+ install : true
+)
+
diff --git a/reference/c/ui/src/ui_translation.c b/reference/c/ui/src/ui_translation.c
new file mode 100644
index 00000000..70f383c0
--- /dev/null
+++ b/reference/c/ui/src/ui_translation.c
@@ -0,0 +1,54 @@
+#define EFL_EO_API_SUPPORT 1
+#define EFL_BETA_API_SUPPORT 1
+
+#include <stdio.h>
+
+#include <Eina.h>
+#include <Elementary.h>
+#include <Efl_Ui.h>
+
+/*
+ * Efl.Ui translation exmaples.
+ *
+ * Efl.Ui contains a way to manage translations provided by gettext or
+ * other translation provider. This example shows how to set it up and to
+ * extract strings for translation. (see src/meson.build).
+ *
+ * The gettext extraction command is:
+ * "xgettext --keyword=efl_ui_translatable_text_set:2 --from-code=utf-8 --foreign-user"
+ *
+ * In this project you can go to build/ and execute "ninja example_translation-pot"
+ */
+#define _TEXT_DOMAIN "example_translation"
+
+EAPI_MAIN void
+efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
+{
+ Efl_Ui_Win *win, *box;
+
+ win = efl_add(EFL_UI_WIN_CLASS, NULL,
+ efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
+ efl_ui_translatable_text_set(efl_added, "Translations",
+ _TEXT_DOMAIN),
+ efl_ui_win_autodel_set(efl_added, EINA_TRUE));
+
+ box = efl_add(EFL_UI_BOX_CLASS, win,
+ efl_content_set(win, efl_added));
+
+ efl_add(EFL_UI_BUTTON_CLASS, win,
+ efl_ui_translatable_text_set(efl_added, "Translations", _TEXT_DOMAIN),
+ efl_pack_end(box, efl_added));
+
+ efl_add(EFL_UI_BUTTON_CLASS, win,
+ efl_ui_translatable_text_set(efl_added, "Help", _TEXT_DOMAIN),
+ efl_pack_end(box, efl_added));
+
+ efl_add(EFL_UI_BUTTON_CLASS, win,
+ efl_ui_translatable_text_set(efl_added, "Quit", _TEXT_DOMAIN),
+ efl_pack_end(box, efl_added),
+ efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(100, 100)));
+
+ efl_gfx_size_set(win, EINA_SIZE2D(320, 320));
+}
+EFL_MAIN()
+