summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOlliver Schinagl <o.schinagl@ultimaker.com>2015-06-09 08:53:00 (GMT)
committerOlliver Schinagl <o.schinagl@ultimaker.com>2015-06-12 05:30:15 (GMT)
commitaae7b5859a07cb737f311a6be39f1c6dc3bf5004 (patch)
tree8d01d9000eb10e3a938a3bc3e8ae87c0f61c094a /src
parent43b6edab83ca2c209de49c2648a01d6398fb17cf (diff)
downloadeulogium-aae7b5859a07cb737f311a6be39f1c6dc3bf5004.zip
eulogium-aae7b5859a07cb737f311a6be39f1c6dc3bf5004.tar.gz
eulogium-aae7b5859a07cb737f311a6be39f1c6dc3bf5004.tar.bz2
Very preliminairy gettext support
Signed-off-by: Olliver Schinagl <o.schinagl@ultimaker.com>
Diffstat (limited to 'src')
-rw-r--r--src/eulogium.c75
1 files changed, 41 insertions, 34 deletions
diff --git a/src/eulogium.c b/src/eulogium.c
index 2451a11..ae9f999 100644
--- a/src/eulogium.c
+++ b/src/eulogium.c
@@ -14,6 +14,13 @@
#include "gettext.h"
+#if HAVE_GETTEXT && ENABLE_NLS
+#define _(string) gettext(string)
+#else
+#define _(string) (string)
+#endif
+#define gettext_noop(string) string
+
#include "eulogium.h"
#define COPYRIGHT "Copyright © 2015 Olliver Schinagl <o.schinagl@ultimaker.com> and various contributors (see AUTHORS)."
@@ -62,7 +69,7 @@ static void _but_material_customize_cb(void *data, Evas_Object *obj EINA_UNUSED,
/* Buttons */
static struct button_def but_return = {
- .text = "RETURN",
+ .text = gettext_noop("RETURN"),
.cb = {
.func = &_cb_content_prev_set,
.data = NULL,
@@ -304,9 +311,9 @@ static struct menu_def menu_system_settings = {
.entry = {
{
.icon = "user-home",
- .label = "Return",
+ .label = gettext_noop("Return"),
.end = NULL,
- .footer = "Return to Main menu",
+ .footer = gettext_noop("Return to Main menu"),
.footer_alt = NULL,
.func = &_cb_content_prev_set,
.toggle_timer = NULL,
@@ -513,7 +520,7 @@ static struct menu_def menu_settings_language = {
.icon = NULL,
.label = "English",
.end = NULL,
- .footer = "Change to English",
+ .footer = "Welcome",
.footer_alt = NULL,
.func = NULL,
.toggle_timer = NULL,
@@ -1399,7 +1406,7 @@ static void _but_network_stats_cb(void *data, Evas_Object *obj EINA_UNUSED, void
elm_box_pack_end(box, object);
object = elm_button_add(box);
- elm_object_text_set(object, but_return.text); /* not pretty using the global XXX */
+ elm_object_text_set(object, _(but_return.text)); /* not pretty using the global XXX */
evas_object_smart_callback_add(object, "clicked", but_return.cb.func, but_return.cb.data);
evas_object_show(object);
elm_box_pack_end(box, object);
@@ -1591,7 +1598,7 @@ Evas_Object *eulogium_button_list_prepend(Evas_Object *list, const char *label,
button = elm_button_add(box);
if (label)
- elm_object_text_set(button, label);
+ elm_object_text_set(button, _(label));
if (icon)
elm_object_part_content_set(button, "icon", icon);
if (func)
@@ -1622,7 +1629,7 @@ Evas_Object *eulogium_button_list_append(Evas_Object *list, const char *label, E
button = elm_button_add(box);
if (label)
- elm_object_text_set(button, label);
+ elm_object_text_set(button, _(label));
if (icon)
elm_object_part_content_set(button, "icon", icon);
if (func)
@@ -1653,7 +1660,7 @@ Evas_Object *eulogium_button_list_sorted_insert(Evas_Object *list, const char *l
button = elm_button_add(box);
if (label)
- elm_object_text_set(button, label);
+ elm_object_text_set(button, _(label));
if (icon)
elm_object_part_content_set(button, "icon", icon);
if (data)
@@ -1807,7 +1814,7 @@ static Eina_Bool _timer_progress_data_update_cb(void *data)
eldbus_proxy_call(eulogium->dbus.proxy[PRINTER], "getTime", _on_get_time_ret, &eulogium->print.time, -1, "");
if (eulogium->printer.status != status) {
- elm_object_text_set(eulogium->status, griffin_print_status[eulogium->printer.status]);
+ elm_object_text_set(eulogium->status, _(griffin_print_status[eulogium->printer.status]));
if (eulogium->printer.status == COOLING)
elm_progressbar_inverted_set(eulogium->progress, EINA_TRUE);
status = eulogium->printer.status;
@@ -1817,7 +1824,7 @@ static Eina_Bool _timer_progress_data_update_cb(void *data)
progress = eulogium->print.progress;
}
if (eulogium->print.name_changed == EINA_TRUE) {
- elm_object_text_set(eulogium->name, eulogium->print.name);
+ elm_object_text_set(eulogium->name, _(eulogium->print.name));
eulogium->print.name_changed = EINA_FALSE;
}
if (eulogium->print.time != time) {
@@ -1858,7 +1865,7 @@ static Eina_Bool _timer_progress_data_update_cb(void *data)
}
snprintf(buf, sizeof(buf), str, (int)eulogium->print.time, (time > 1) ? "s" : ""); /* TODO: This won't work with in10 */
- elm_object_text_set(eulogium->time, buf);
+ elm_object_text_set(eulogium->time, _(buf));
eulogium->print.time = time;
}
@@ -1882,14 +1889,14 @@ Evas_Object *eulogium_print_progress(struct eulogium_data *eulogium)
evas_object_show(_top);
eulogium->time = elm_label_add(_top);
- elm_object_text_set(eulogium->time, "Calculating time ...");
+ elm_object_text_set(eulogium->time, _("Calculating time ..."));
elm_label_slide_mode_set(eulogium->time, ELM_LABEL_SLIDE_MODE_NONE);
evas_object_size_hint_align_set(eulogium->time, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(eulogium->time);
elm_box_pack_end(_top, eulogium->time);
eulogium->status = elm_label_add(_top);
- elm_object_text_set(eulogium->status, "Unknown print status");
+ elm_object_text_set(eulogium->status, _("Unknown print status"));
elm_label_slide_mode_set(eulogium->status, ELM_LABEL_SLIDE_MODE_NONE);
evas_object_size_hint_align_set(eulogium->status, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(eulogium->status);
@@ -1932,14 +1939,14 @@ Evas_Object *eulogium_generic_error(struct eulogium_data *eulogium, uint8_t eulo
object = elm_label_add(eulogium->navi);
snprintf(buf, sizeof(buf), "Printer error %d.<br>Please contact support via<br>http://ultimaker.com/support.", eulogium_error);
- elm_object_text_set(object, buf);
+ elm_object_text_set(object, _(buf));
evas_object_show(object);
elm_box_pack_end(box, object);
#if 0
/* XXX what to do here, reboot? make support notice via wget? */
object = elm_button_add(eulogium->navi);
- elm_object_text_set(object, "ABORT"); /* TODO create abort button */
+ elm_object_text_set(object, _("ABORT")); /* TODO create abort button */
evas_object_size_hint_align_set(object, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(object, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_smart_callback_add(object, "clicked", _print_abort_cb, eulogium); /* TODO what button to use here? */
@@ -2003,13 +2010,13 @@ Evas_Object *eulogium_clear_print_bed(struct eulogium_data *eulogium)
evas_object_show(box);
obj = elm_label_add(box);
- elm_object_text_set(obj, "Please empty print bed.");
+ elm_object_text_set(obj, _("Please empty print bed."));
evas_object_show(obj);
elm_box_pack_end(box, obj);
/* TODO replace with left/right button call, this is just a quick Hack XXX */
obj = elm_button_add(box);
- elm_object_text_set(obj, "Print removed");
+ elm_object_text_set(obj, _("Print removed"));
evas_object_smart_callback_add(obj, "clicked", _cleared_bed_cb, eulogium);
evas_object_show(obj);
elm_box_pack_end(box, obj);
@@ -2159,9 +2166,9 @@ static Eina_Bool _timer_footer_toggle_cb(void *data)
static uint_fast8_t toggle = 0;
if (toggle)
- elm_object_text_set(footer, entry->footer);
+ elm_object_text_set(footer, _(entry->footer));
else
- elm_object_text_set(footer, entry->footer_alt);
+ elm_object_text_set(footer, _(entry->footer_alt));
toggle = !toggle;
return ECORE_CALLBACK_RENEW;
@@ -2173,10 +2180,10 @@ static void _update_menu_footer_focus_cb(void *data, Evas_Object *obj EINA_UNUSE
Evas_Object *footer = entry->data;
if (!entry->footer) {
- elm_object_text_set(footer, entry->label);
+ elm_object_text_set(footer, _(entry->label));
return;
}
- elm_object_text_set(footer, entry->footer);
+ elm_object_text_set(footer, _(entry->footer));
if (entry->footer_alt) {
entry->toggle_timer = ecore_timer_add(1.5, _timer_footer_toggle_cb, entry); /* XXX magic value!! */
@@ -2235,9 +2242,10 @@ Evas_Object *menu_widget_list(struct eulogium_data *eulogium, Evas_Object *paren
box = elm_box_add(parent);
eulogium->footer = elm_label_add(box);
+ elm_object_text_set(eulogium->footer, NULL);
obj = elm_label_add(box);
- elm_object_text_set(obj, menu->title); /* XXX THIS IS NOT ALWAYS IN DATA! */
+ elm_object_text_set(obj, _(menu->title)); /* XXX THIS IS NOT ALWAYS IN DATA! */
evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(obj);
elm_box_pack_start(box, obj);
@@ -2264,7 +2272,6 @@ Evas_Object *menu_widget_list(struct eulogium_data *eulogium, Evas_Object *paren
elm_box_pack_end(box, obj);
/* Footer is initialized at the start of the function, so that the for loop can work with it. */
- elm_object_text_set(eulogium->footer, NULL);
evas_object_size_hint_align_set(eulogium->footer, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(eulogium->footer);
elm_box_pack_end(box, eulogium->footer);
@@ -2330,7 +2337,7 @@ Evas_Object *eulogium_multi_screen_menu(struct eulogium_data *eulogium, Evas_Obj
if (pageindex) {
object = elm_label_add(_top);
snprintf(buf, sizeof(buf), "%d/%d", pagenum + 1, screen_data->count);
- elm_object_text_set(object, buf);
+ elm_object_text_set(object, _(buf));
evas_object_show(object);
evas_object_size_hint_weight_set(object, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(object, 1.0, 0);
@@ -2339,7 +2346,7 @@ Evas_Object *eulogium_multi_screen_menu(struct eulogium_data *eulogium, Evas_Obj
if (screen_data->screen[pagenum].text) {
object = elm_label_add(_top);
- elm_object_text_set(object, screen_data->screen[pagenum].text);
+ elm_object_text_set(object, _(screen_data->screen[pagenum].text));
evas_object_size_hint_align_set(object, 0.5, 0.5);
evas_object_show(object);
elm_box_pack_end(_top, object);
@@ -2406,7 +2413,7 @@ Evas_Object *eulogium_multi_screen_menu(struct eulogium_data *eulogium, Evas_Obj
object = elm_button_add(parent);
evas_object_size_hint_align_set(object, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(object, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_object_text_set(object, screen_data->screen[pagenum].prev_button);
+ elm_object_text_set(object, _(screen_data->screen[pagenum].prev_button));
evas_object_smart_callback_add(object, "clicked", _cb_content_prev_set, eulogium);
evas_object_show(object);
elm_box_pack_end(_bottom, object);
@@ -2415,7 +2422,7 @@ Evas_Object *eulogium_multi_screen_menu(struct eulogium_data *eulogium, Evas_Obj
object = elm_button_add(parent);
evas_object_size_hint_align_set(object, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(object, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_object_text_set(object, screen_data->screen[pagenum].next_button);
+ elm_object_text_set(object, _(screen_data->screen[pagenum].next_button));
evas_object_smart_callback_add(object, "clicked", _eulogium_multi_screen_next_cb, multi_screen_next_cb_data);
evas_object_show(object);
elm_box_pack_end(_bottom, object);
@@ -2451,7 +2458,7 @@ Evas_Object *eulogium_dual_button_add(Evas_Object *parent, const struct button_d
obj = elm_button_add(box);
evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_object_text_set(obj, left->text);
+ elm_object_text_set(obj, _(left->text));
evas_object_smart_callback_add(obj, "clicked", left->cb.func, left->cb.data);
evas_object_show(obj);
elm_box_pack_end(butbox, obj);
@@ -2472,7 +2479,7 @@ Evas_Object *eulogium_dual_button_add(Evas_Object *parent, const struct button_d
obj = elm_button_add(box);
evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_object_text_set(obj, right->text);
+ elm_object_text_set(obj, _(right->text));
evas_object_smart_callback_add(obj, "clicked", right->cb.func, right->cb.data);
evas_object_show(obj);
elm_box_pack_end(butbox, obj);
@@ -2488,7 +2495,7 @@ Evas_Object *eulogium_tripple_button_menu(Evas_Object *parent, const struct butt
evas_object_show(_top);
_bottom = elm_button_add(parent);
- elm_object_text_set(_bottom, bottom->text);
+ elm_object_text_set(_bottom, _(bottom->text));
evas_object_smart_callback_add(_bottom, "clicked", bottom->cb.func, bottom->cb.data);
evas_object_show(_bottom);
@@ -3179,10 +3186,10 @@ EAPI_MAIN int elm_main(int argc, char **argv)
elm_app_compile_locale_set(LOCALE_DIR);
#endif
#if ENABLE_NLS /* TODO Check for removal, elm_app_compile may solve this allready */
-// setlocale(LC_ALL, "");
-// bindtextdomain(PACKAGE, LOCALE_DIR);
-// bind_textdomain_codeset(PACKAGE, "UTF-8");
-// textdomain(PACKAGE);
+ setlocale(LC_ALL, "");
+ bindtextdomain(PACKAGE, LOCALE_DIR);
+ bind_textdomain_codeset(PACKAGE, "UTF-8");
+ textdomain(PACKAGE);
#endif
elm_app_info_set(NULL, PACKAGE, NULL); /* TODO */
#if (ELM_VERSION_MAJOR > 1) || (ELM_VERSION_MINOR >= 10)