]> git.ozlabs.org Git - petitboot/commitdiff
i18n: Mark translatable strings for ncurses UI
authorJeremy Kerr <jk@ozlabs.org>
Wed, 18 Dec 2013 01:49:23 +0000 (09:49 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Mon, 28 Jul 2014 05:20:34 +0000 (13:20 +0800)
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
lib/i18n/i18n.h [new file with mode: 0644]
po/POTFILES.in
ui/ncurses/Makefile.am
ui/ncurses/generic-main.c
ui/ncurses/nc-boot-editor.c
ui/ncurses/nc-config.c
ui/ncurses/nc-cui.c
ui/ncurses/nc-helpscreen.c
ui/ncurses/nc-menu.c
ui/ncurses/nc-sysinfo.c
ui/ncurses/nc-textscreen.c

diff --git a/lib/i18n/i18n.h b/lib/i18n/i18n.h
new file mode 100644 (file)
index 0000000..d7ff154
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ *  Copyright (C) 2013 IBM Corporation
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef I18N_H
+#define I18N_H
+
+#include <libintl.h>
+
+#define _(x) gettext(x)
+
+#endif /* I18N_H */
+
index 667e27c3cbc0d137d9e2e0ec2a6b29522c596fe9..e9a8562a26759a56e156273aeb245b3f1d64656a 100644 (file)
@@ -1 +1,10 @@
 # List of source files which contain translatable strings.
 # List of source files which contain translatable strings.
+
+ui/ncurses/nc-boot-editor.c
+ui/ncurses/nc-config.c
+ui/ncurses/nc-cui.c
+ui/ncurses/nc-helpscreen.c
+ui/ncurses/nc-menu.c
+ui/ncurses/nc-sysinfo.c
+ui/ncurses/nc-textscreen.c
+ui/ncurses/generic-main.c
index ded3193f21e4ddb9614a503f2dd3abdefb8d5172..be4c417d69e650e234b42c61ee507b6f14d34c91 100644 (file)
@@ -15,6 +15,7 @@
 AM_CPPFLAGS = \
        -I$(top_srcdir) \
        -I$(top_srcdir)/lib \
 AM_CPPFLAGS = \
        -I$(top_srcdir) \
        -I$(top_srcdir)/lib \
+       -DLOCALEDIR='"$(localedir)"' \
        $(DEFAULT_CPPFLAGS)
 
 AM_CFLAGS = \
        $(DEFAULT_CPPFLAGS)
 
 AM_CFLAGS = \
index fe288ee3cad85f25628ab5ed0e45139b63803891..abf33563a13a10bf5cb82c3fb6a67bfe3a160d72 100644 (file)
 #include <string.h>
 #include <limits.h>
 #include <sys/time.h>
 #include <string.h>
 #include <limits.h>
 #include <sys/time.h>
+#include <libintl.h>
+#include <locale.h>
 
 #include "log/log.h"
 #include "talloc/talloc.h"
 #include "waiter/waiter.h"
 
 #include "log/log.h"
 #include "talloc/talloc.h"
 #include "waiter/waiter.h"
+#include "i18n/i18n.h"
 #include "ui/common/discover-client.h"
 #include "nc-cui.h"
 
 #include "ui/common/discover-client.h"
 #include "nc-cui.h"
 
@@ -48,8 +51,9 @@ static void print_usage(void)
 {
        print_version();
        printf(
 {
        print_version();
        printf(
-"Usage: petitboot-nc [-h, --help] [-l, --log log-file]\n"
-"                    [-s, --start-daemon] [-v, --verbose] [-V, --version]\n");
+"%s: petitboot-nc [-h, --help] [-l, --log log-file]\n"
+"                    [-s, --start-daemon] [-v, --verbose] [-V, --version]\n",
+                       _("Usage"));
 }
 
 /**
 }
 
 /**
@@ -198,26 +202,26 @@ static struct pmenu *pb_mm_init(struct pb_cui *pb_cui)
                "Petitboot (" PACKAGE_VERSION ")");
        m->scr.frame.rtitle = NULL;
        m->scr.frame.help = talloc_strdup(m,
                "Petitboot (" PACKAGE_VERSION ")");
        m->scr.frame.rtitle = NULL;
        m->scr.frame.help = talloc_strdup(m,
-               "Enter=accept, e=edit, n=new, x=exit, h=help");
-       m->scr.frame.status = talloc_strdup(m, "Welcome to Petitboot");
+               _("Enter=accept, e=edit, n=new, x=exit, h=help"));
+       m->scr.frame.status = talloc_strdup(m, _("Welcome to Petitboot"));
 
        i = pmenu_item_create(m, " ");
        item_opts_off(i->nci, O_SELECTABLE);
        pmenu_item_insert(m, i, 0);
 
 
        i = pmenu_item_create(m, " ");
        item_opts_off(i->nci, O_SELECTABLE);
        pmenu_item_insert(m, i, 0);
 
-       i = pmenu_item_create(m, "System information");
+       i = pmenu_item_create(m, _("System information"));
        i->on_execute = pmenu_sysinfo;
        pmenu_item_insert(m, i, 1);
 
        i->on_execute = pmenu_sysinfo;
        pmenu_item_insert(m, i, 1);
 
-       i = pmenu_item_create(m, "System configuration");
+       i = pmenu_item_create(m, _("System configuration"));
        i->on_execute = pmenu_config;
        pmenu_item_insert(m, i, 2);
 
        i->on_execute = pmenu_config;
        pmenu_item_insert(m, i, 2);
 
-       i = pmenu_item_create(m, "Rescan devices");
+       i = pmenu_item_create(m, _("Rescan devices"));
        i->on_execute = pmenu_reinit;
        pmenu_item_insert(m, i, 3);
 
        i->on_execute = pmenu_reinit;
        pmenu_item_insert(m, i, 3);
 
-       i = pmenu_item_create(m, "Exit to shell");
+       i = pmenu_item_create(m, _("Exit to shell"));
        i->on_execute = pmenu_exit_cb;
        pmenu_item_insert(m, i, 4);
 
        i->on_execute = pmenu_exit_cb;
        pmenu_item_insert(m, i, 4);
 
@@ -229,7 +233,7 @@ static struct pmenu *pb_mm_init(struct pb_cui *pb_cui)
                goto fail_setup;
        }
 
                goto fail_setup;
        }
 
-       m->help_title = "main menu";
+       m->help_title = _("main menu");
        m->help_text = main_menu_help_text;
 
        menu_opts_off(m->ncm, O_SHOWDESC);
        m->help_text = main_menu_help_text;
 
        menu_opts_off(m->ncm, O_SHOWDESC);
@@ -281,6 +285,10 @@ int main(int argc, char *argv[])
 
        result = opts_parse(&opts, argc, argv);
 
 
        result = opts_parse(&opts, argc, argv);
 
+       setlocale(LC_ALL, "");
+       bindtextdomain(PACKAGE, LOCALEDIR);
+       textdomain(PACKAGE);
+
        if (result) {
                print_usage();
                return EXIT_FAILURE;
        if (result) {
                print_usage();
                return EXIT_FAILURE;
index 329699ab8ebdb6842369d9ad680cacf8e145907a..6bc1d89169b166da53a2eb502ffe12f1545665d5 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "log/log.h"
 #include "talloc/talloc.h"
 
 #include "log/log.h"
 #include "talloc/talloc.h"
+#include "i18n/i18n.h"
 #include "nc-boot-editor.h"
 #include "nc-widgets.h"
 
 #include "nc-boot-editor.h"
 #include "nc-widgets.h"
 
@@ -220,7 +221,7 @@ static void boot_editor_process_key(struct nc_scr *scr, int key)
                break;
        case STATE_HELP:
                boot_editor->state = STATE_EDIT;
                break;
        case STATE_HELP:
                boot_editor->state = STATE_EDIT;
-               cui_show_help(boot_editor->cui, "Boot Option Editor",
+               cui_show_help(boot_editor->cui, _("Boot Option Editor"),
                                boot_editor_help_text);
                break;
        default:
                                boot_editor_help_text);
                break;
        default:
@@ -365,7 +366,7 @@ static void boot_editor_populate_device_select(struct boot_editor *boot_editor,
         * changed. */
        selected = !boot_editor->selected_device;
 
         * changed. */
        selected = !boot_editor->selected_device;
 
-       widget_select_add_option(select, -1, "Specify paths/URLs manually",
+       widget_select_add_option(select, -1, _("Specify paths/URLs manually"),
                        selected);
 }
 
                        selected);
 }
 
@@ -445,7 +446,8 @@ static void boot_editor_setup_widgets(struct boot_editor *boot_editor,
        widgetset_set_widget_focus(boot_editor->widgetset,
                        boot_editor_widget_focus, boot_editor);
 
        widgetset_set_widget_focus(boot_editor->widgetset,
                        boot_editor_widget_focus, boot_editor);
 
-       boot_editor->widgets.device_l = widget_new_label(set, 0, 0, "Device:");
+       boot_editor->widgets.device_l = widget_new_label(set, 0, 0,
+                       _("Device:"));
        boot_editor->widgets.device_f = widget_new_select(set, 0, 0,
                                                field_size);
        widget_select_on_change(boot_editor->widgets.device_f,
        boot_editor->widgets.device_f = widget_new_select(set, 0, 0,
                                                field_size);
        widget_select_on_change(boot_editor->widgets.device_f,
@@ -454,32 +456,32 @@ static void boot_editor_setup_widgets(struct boot_editor *boot_editor,
        boot_editor_populate_device_select(boot_editor, sysinfo);
 
        boot_editor->widgets.image_l = widget_new_label(set, 0, 0,
        boot_editor_populate_device_select(boot_editor, sysinfo);
 
        boot_editor->widgets.image_l = widget_new_label(set, 0, 0,
-                       "Kernel:");
+                       _("Kernel:"));
        boot_editor->widgets.image_f = widget_new_textbox(set, 0, 0,
                                                field_size, boot_editor->image);
 
        boot_editor->widgets.initrd_l = widget_new_label(set, 0, 0,
        boot_editor->widgets.image_f = widget_new_textbox(set, 0, 0,
                                                field_size, boot_editor->image);
 
        boot_editor->widgets.initrd_l = widget_new_label(set, 0, 0,
-                       "Initrd:");
+                       _("Initrd:"));
        boot_editor->widgets.initrd_f = widget_new_textbox(set, 0, 0,
                                                field_size,
                                                boot_editor->initrd);
 
        boot_editor->widgets.dtb_l = widget_new_label(set, 0, 0,
        boot_editor->widgets.initrd_f = widget_new_textbox(set, 0, 0,
                                                field_size,
                                                boot_editor->initrd);
 
        boot_editor->widgets.dtb_l = widget_new_label(set, 0, 0,
-                       "Device tree:");
+                       _("Device tree:"));
        boot_editor->widgets.dtb_f = widget_new_textbox(set, 0, 0,
                                                field_size, boot_editor->dtb);
 
        boot_editor->widgets.args_l = widget_new_label(set, 0, 0,
        boot_editor->widgets.dtb_f = widget_new_textbox(set, 0, 0,
                                                field_size, boot_editor->dtb);
 
        boot_editor->widgets.args_l = widget_new_label(set, 0, 0,
-                       "Boot arguments:");
+                       _("Boot arguments:"));
        boot_editor->widgets.args_f = widget_new_textbox(set, 0, 0,
                                        field_size, boot_editor->args);
 
        boot_editor->widgets.ok_b = widget_new_button(set, 0, 0, 6,
        boot_editor->widgets.args_f = widget_new_textbox(set, 0, 0,
                                        field_size, boot_editor->args);
 
        boot_editor->widgets.ok_b = widget_new_button(set, 0, 0, 6,
-                                       "OK", ok_click, boot_editor);
+                                       _("OK"), ok_click, boot_editor);
        boot_editor->widgets.help_b = widget_new_button(set, 0, 0, 6,
        boot_editor->widgets.help_b = widget_new_button(set, 0, 0, 6,
-                                       "Help", help_click, boot_editor);
+                                       _("Help"), help_click, boot_editor);
        boot_editor->widgets.cancel_b = widget_new_button(set, 0, 0, 6,
        boot_editor->widgets.cancel_b = widget_new_button(set, 0, 0, 6,
-                                       "Cancel", cancel_click, boot_editor);
+                                       _("Cancel"), cancel_click, boot_editor);
 }
 
 void boot_editor_update(struct boot_editor *boot_editor,
 }
 
 void boot_editor_update(struct boot_editor *boot_editor,
@@ -535,10 +537,10 @@ struct boot_editor *boot_editor_init(struct cui *cui,
                boot_editor_post, boot_editor_unpost, boot_editor_resize);
 
        boot_editor->scr.frame.ltitle = talloc_strdup(boot_editor,
                boot_editor_post, boot_editor_unpost, boot_editor_resize);
 
        boot_editor->scr.frame.ltitle = talloc_strdup(boot_editor,
-                       "Petitboot Option Editor");
+                       _("Petitboot Option Editor"));
        boot_editor->scr.frame.rtitle = NULL;
        boot_editor->scr.frame.help = talloc_strdup(boot_editor,
        boot_editor->scr.frame.rtitle = NULL;
        boot_editor->scr.frame.help = talloc_strdup(boot_editor,
-                       "tab=next, shift+tab=previous, x=exit, h=help");
+                       _("tab=next, shift+tab=previous, x=exit, h=help"));
        nc_scr_frame_draw(&boot_editor->scr);
 
        if (item) {
        nc_scr_frame_draw(&boot_editor->scr);
 
        if (item) {
index d345c853b23a4e2f1a70b6bfcbecf63d14dac412..54eb7ac5740d891bd32c6a7bcc57655cbf19bc8a 100644 (file)
@@ -27,6 +27,7 @@
 #include <talloc/talloc.h>
 #include <types/types.h>
 #include <log/log.h>
 #include <talloc/talloc.h>
 #include <types/types.h>
 #include <log/log.h>
+#include <i18n/i18n.h>
 
 #include "nc-cui.h"
 #include "nc-config.h"
 
 #include "nc-cui.h"
 #include "nc-config.h"
@@ -144,7 +145,7 @@ static void config_screen_process_key(struct nc_scr *scr, int key)
 
        } else if (screen->show_help) {
                screen->show_help = false;
 
        } else if (screen->show_help) {
                screen->show_help = false;
-               cui_show_help(screen->cui, "System Configuration",
+               cui_show_help(screen->cui, _("System Configuration"),
                                config_help_text);
 
        } else if (handled) {
                                config_help_text);
 
        } else if (handled) {
@@ -267,7 +268,7 @@ static int screen_process_form(struct config_screen *screen)
 
                if (!ip || !*ip || !mask || !*mask) {
                        screen->scr.frame.status =
 
                if (!ip || !*ip || !mask || !*mask) {
                        screen->scr.frame.status =
-                               "No IP / mask values are set";
+                               _("No IP / mask values are set");
                        nc_scr_frame_draw(&screen->scr);
                        talloc_free(config);
                        return -1;
                        nc_scr_frame_draw(&screen->scr);
                        talloc_free(config);
                        return -1;
@@ -530,9 +531,10 @@ static enum net_conf_type find_net_conf_type(const struct config *config)
 static void config_screen_setup_empty(struct config_screen *screen)
 {
        widget_new_label(screen->widgetset, 2, screen->field_x,
 static void config_screen_setup_empty(struct config_screen *screen)
 {
        widget_new_label(screen->widgetset, 2, screen->field_x,
-                       "Waiting for configuration data...");
+                       _("Waiting for configuration data..."));
        screen->widgets.cancel_b = widget_new_button(screen->widgetset,
        screen->widgets.cancel_b = widget_new_button(screen->widgetset,
-                       4, screen->field_x, 6, "Cancel", cancel_click, screen);
+                       4, screen->field_x, 6, _("Cancel"),
+                       cancel_click, screen);
 }
 
 
 }
 
 
@@ -553,7 +555,8 @@ static void config_screen_setup_widgets(struct config_screen *screen,
        type = screen->net_conf_type;
        ifcfg = first_active_interface(config);
 
        type = screen->net_conf_type;
        ifcfg = first_active_interface(config);
 
-       screen->widgets.autoboot_l = widget_new_label(set, 0, 0, "Autoboot:");
+       screen->widgets.autoboot_l = widget_new_label(set, 0, 0,
+                                       _("Autoboot:"));
        screen->widgets.autoboot_f = widget_new_select(set, 0, 0, 55);
 
        widget_select_on_change(screen->widgets.autoboot_f,
        screen->widgets.autoboot_f = widget_new_select(set, 0, 0, 55);
 
        widget_select_on_change(screen->widgets.autoboot_f,
@@ -563,18 +566,19 @@ static void config_screen_setup_widgets(struct config_screen *screen,
 
        widget_select_add_option(screen->widgets.autoboot_f,
                                        AUTOBOOT_DISABLED,
 
        widget_select_add_option(screen->widgets.autoboot_f,
                                        AUTOBOOT_DISABLED,
-                                       "Don't autoboot",
+                                       _("Don't autoboot"),
                                        screen->autoboot_type ==
                                                AUTOBOOT_DISABLED);
        widget_select_add_option(screen->widgets.autoboot_f,
                                        AUTOBOOT_ANY,
                                        screen->autoboot_type ==
                                                AUTOBOOT_DISABLED);
        widget_select_add_option(screen->widgets.autoboot_f,
                                        AUTOBOOT_ANY,
-                                       "Autoboot from any disk/network device",
+                                       _("Autoboot from any "
+                                               "disk/network device"),
                                        screen->autoboot_type ==
                                                AUTOBOOT_ANY);
        widget_select_add_option(screen->widgets.autoboot_f,
                                        AUTOBOOT_ONE,
                                        screen->autoboot_type ==
                                                AUTOBOOT_ANY);
        widget_select_add_option(screen->widgets.autoboot_f,
                                        AUTOBOOT_ONE,
-                                       "Only autoboot from a specific "
-                                       "disk/network device",
+                                       _("Only autoboot from a specific "
+                                               "disk/network device"),
                                        screen->autoboot_type ==
                                                AUTOBOOT_ONE);
 
                                        screen->autoboot_type ==
                                                AUTOBOOT_ONE);
 
@@ -590,7 +594,7 @@ static void config_screen_setup_widgets(struct config_screen *screen,
                if (selected)
                        found = true;
 
                if (selected)
                        found = true;
 
-               label = talloc_asprintf(screen, "disk: %s [uuid: %s]",
+               label = talloc_asprintf(screen, _("disk: %s [uuid: %s]"),
                                bd->name, bd->uuid);
 
                widget_select_add_option(screen->widgets.boot_device_f, i,
                                bd->name, bd->uuid);
 
                widget_select_add_option(screen->widgets.boot_device_f, i,
@@ -608,7 +612,7 @@ static void config_screen_setup_widgets(struct config_screen *screen,
                if (selected)
                        found = true;
 
                if (selected)
                        found = true;
 
-               label = talloc_asprintf(screen, "net:  %s [mac: %s]",
+               label = talloc_asprintf(screen, _("net:  %s [mac: %s]"),
                                info->name, mac);
 
                widget_select_add_option(screen->widgets.boot_device_f,
                                info->name, mac);
 
                widget_select_add_option(screen->widgets.boot_device_f,
@@ -619,7 +623,7 @@ static void config_screen_setup_widgets(struct config_screen *screen,
        if (screen->autoboot_type == AUTOBOOT_ONE && !found) {
                char *label;
 
        if (screen->autoboot_type == AUTOBOOT_ONE && !found) {
                char *label;
 
-               label = talloc_asprintf(screen, "Unknown UUID: %s",
+               label = talloc_asprintf(screen, _("Unknown UUID: %s"),
                                config->boot_device);
 
                widget_select_add_option(screen->widgets.boot_device_f, -1,
                                config->boot_device);
 
                widget_select_add_option(screen->widgets.boot_device_f, -1,
@@ -627,33 +631,34 @@ static void config_screen_setup_widgets(struct config_screen *screen,
        }
 
        str = talloc_asprintf(screen, "%d", config->autoboot_timeout_sec);
        }
 
        str = talloc_asprintf(screen, "%d", config->autoboot_timeout_sec);
-       screen->widgets.timeout_l = widget_new_label(set, 0, 0, "Timeout:");
+       screen->widgets.timeout_l = widget_new_label(set, 0, 0, _("Timeout:"));
        screen->widgets.timeout_f = widget_new_textbox(set, 0, 0, 5, str);
        screen->widgets.timeout_f = widget_new_textbox(set, 0, 0, 5, str);
-       screen->widgets.timeout_help_l = widget_new_label(set, 0, 0, "seconds");
+       screen->widgets.timeout_help_l = widget_new_label(set, 0, 0,
+                                       _("seconds"));
 
        widget_textbox_set_fixed_size(screen->widgets.timeout_f);
        widget_textbox_set_validator_integer(screen->widgets.timeout_f, 0, 999);
 
 
        widget_textbox_set_fixed_size(screen->widgets.timeout_f);
        widget_textbox_set_validator_integer(screen->widgets.timeout_f, 0, 999);
 
-       screen->widgets.network_l = widget_new_label(set, 0, 0, "Network:");
+       screen->widgets.network_l = widget_new_label(set, 0, 0, _("Network:"));
        screen->widgets.network_f = widget_new_select(set, 0, 0, 50);
 
        widget_select_add_option(screen->widgets.network_f,
                                        NET_CONF_TYPE_DHCP_ALL,
        screen->widgets.network_f = widget_new_select(set, 0, 0, 50);
 
        widget_select_add_option(screen->widgets.network_f,
                                        NET_CONF_TYPE_DHCP_ALL,
-                                       "DHCP on all active interfaces",
+                                       _("DHCP on all active interfaces"),
                                        type == NET_CONF_TYPE_DHCP_ALL);
        widget_select_add_option(screen->widgets.network_f,
                                        NET_CONF_TYPE_DHCP_ONE,
                                        type == NET_CONF_TYPE_DHCP_ALL);
        widget_select_add_option(screen->widgets.network_f,
                                        NET_CONF_TYPE_DHCP_ONE,
-                                       "DHCP on a specific interface",
+                                       _("DHCP on a specific interface"),
                                        type == NET_CONF_TYPE_DHCP_ONE);
        widget_select_add_option(screen->widgets.network_f,
                                        NET_CONF_TYPE_STATIC,
                                        type == NET_CONF_TYPE_DHCP_ONE);
        widget_select_add_option(screen->widgets.network_f,
                                        NET_CONF_TYPE_STATIC,
-                                       "Static IP configuration",
+                                       _("Static IP configuration"),
                                        type == NET_CONF_TYPE_STATIC);
 
        widget_select_on_change(screen->widgets.network_f,
                        config_screen_network_change, screen);
 
                                        type == NET_CONF_TYPE_STATIC);
 
        widget_select_on_change(screen->widgets.network_f,
                        config_screen_network_change, screen);
 
-       screen->widgets.iface_l = widget_new_label(set, 0, 0, "Device:");
+       screen->widgets.iface_l = widget_new_label(set, 0, 0, _("Device:"));
        screen->widgets.iface_f = widget_new_select(set, 0, 0, 50);
 
        for (i = 0; i < sysinfo->n_interfaces; i++) {
        screen->widgets.iface_f = widget_new_select(set, 0, 0, 50);
 
        for (i = 0; i < sysinfo->n_interfaces; i++) {
@@ -666,7 +671,7 @@ static void config_screen_setup_widgets(struct config_screen *screen,
 
                mac_str(info->hwaddr, info->hwaddr_size, mac, sizeof(mac));
                snprintf(str, sizeof(str), "%s [%s, %s]", info->name, mac,
 
                mac_str(info->hwaddr, info->hwaddr_size, mac, sizeof(mac));
                snprintf(str, sizeof(str), "%s [%s, %s]", info->name, mac,
-                               info->link ? "link up" : "link down");
+                               info->link ? _("link up") : _("link down"));
 
                widget_select_add_option(screen->widgets.iface_f,
                                                i, str, is_default);
 
                widget_select_add_option(screen->widgets.iface_f,
                                                i, str, is_default);
@@ -687,22 +692,22 @@ static void config_screen_setup_widgets(struct config_screen *screen,
                gw = ifcfg->static_config.gateway;
        }
 
                gw = ifcfg->static_config.gateway;
        }
 
-       screen->widgets.ip_addr_l = widget_new_label(set, 0, 0, "IP/mask:");
+       screen->widgets.ip_addr_l = widget_new_label(set, 0, 0, _("IP/mask:"));
        screen->widgets.ip_addr_f = widget_new_textbox(set, 0, 0, 16, ip);
        screen->widgets.ip_mask_l = widget_new_label(set, 0, 0, "/");
        screen->widgets.ip_mask_f = widget_new_textbox(set, 0, 0, 3, mask);
        screen->widgets.ip_addr_mask_help_l =
        screen->widgets.ip_addr_f = widget_new_textbox(set, 0, 0, 16, ip);
        screen->widgets.ip_mask_l = widget_new_label(set, 0, 0, "/");
        screen->widgets.ip_mask_f = widget_new_textbox(set, 0, 0, 3, mask);
        screen->widgets.ip_addr_mask_help_l =
-               widget_new_label(set, 0, 0, "(eg. 192.168.0.10 / 24)");
+               widget_new_label(set, 0, 0, _("(eg. 192.168.0.10 / 24)"));
 
        widget_textbox_set_fixed_size(screen->widgets.ip_addr_f);
        widget_textbox_set_fixed_size(screen->widgets.ip_mask_f);
        widget_textbox_set_validator_ipv4(screen->widgets.ip_addr_f);
        widget_textbox_set_validator_integer(screen->widgets.ip_mask_f, 1, 31);
 
 
        widget_textbox_set_fixed_size(screen->widgets.ip_addr_f);
        widget_textbox_set_fixed_size(screen->widgets.ip_mask_f);
        widget_textbox_set_validator_ipv4(screen->widgets.ip_addr_f);
        widget_textbox_set_validator_integer(screen->widgets.ip_mask_f, 1, 31);
 
-       screen->widgets.gateway_l = widget_new_label(set, 0, 0, "Gateway:");
+       screen->widgets.gateway_l = widget_new_label(set, 0, 0, _("Gateway:"));
        screen->widgets.gateway_f = widget_new_textbox(set, 0, 0, 16, gw);
        screen->widgets.gateway_help_l =
        screen->widgets.gateway_f = widget_new_textbox(set, 0, 0, 16, gw);
        screen->widgets.gateway_help_l =
-               widget_new_label(set, 0, 0, "(eg. 192.168.0.1)");
+               widget_new_label(set, 0, 0, _("(eg. 192.168.0.1)"));
 
        widget_textbox_set_fixed_size(screen->widgets.gateway_f);
        widget_textbox_set_validator_ipv4(screen->widgets.gateway_f);
 
        widget_textbox_set_fixed_size(screen->widgets.gateway_f);
        widget_textbox_set_validator_ipv4(screen->widgets.gateway_f);
@@ -714,21 +719,22 @@ static void config_screen_setup_widgets(struct config_screen *screen,
                                config->network.dns_servers[i]);
        }
 
                                config->network.dns_servers[i]);
        }
 
-       screen->widgets.dns_l = widget_new_label(set, 0, 0, "DNS Server(s):");
+       screen->widgets.dns_l = widget_new_label(set, 0, 0,
+                                       _("DNS Server(s):"));
        screen->widgets.dns_f = widget_new_textbox(set, 0, 0, 32, str);
        screen->widgets.dns_help_l =
        screen->widgets.dns_f = widget_new_textbox(set, 0, 0, 32, str);
        screen->widgets.dns_help_l =
-               widget_new_label(set, 0, 0, "(eg. 192.168.0.2)");
+               widget_new_label(set, 0, 0, _("(eg. 192.168.0.2)"));
 
        widget_textbox_set_validator_ipv4_multi(screen->widgets.dns_f);
 
        screen->widgets.dns_dhcp_help_l = widget_new_label(set, 0, 0,
 
        widget_textbox_set_validator_ipv4_multi(screen->widgets.dns_f);
 
        screen->widgets.dns_dhcp_help_l = widget_new_label(set, 0, 0,
-                       "(if not provided by DHCP server)");
+                       _("(if not provided by DHCP server)"));
 
 
-       screen->widgets.ok_b = widget_new_button(set, 0, 0, 6, "OK",
+       screen->widgets.ok_b = widget_new_button(set, 0, 0, 6, _("OK"),
                        ok_click, screen);
                        ok_click, screen);
-       screen->widgets.help_b = widget_new_button(set, 0, 0, 6, "Help",
+       screen->widgets.help_b = widget_new_button(set, 0, 0, 6, _("Help"),
                        help_click, screen);
                        help_click, screen);
-       screen->widgets.cancel_b = widget_new_button(set, 0, 0, 6, "Cancel",
+       screen->widgets.cancel_b = widget_new_button(set, 0, 0, 6, _("Cancel"),
                        cancel_click, screen);
 }
 
                        cancel_click, screen);
 }
 
@@ -840,10 +846,10 @@ struct config_screen *config_screen_init(struct cui *cui,
        screen->field_x = 17;
 
        screen->scr.frame.ltitle = talloc_strdup(screen,
        screen->field_x = 17;
 
        screen->scr.frame.ltitle = talloc_strdup(screen,
-                       "Petitboot System Configuration");
+                       _("Petitboot System Configuration"));
        screen->scr.frame.rtitle = NULL;
        screen->scr.frame.help = talloc_strdup(screen,
        screen->scr.frame.rtitle = NULL;
        screen->scr.frame.help = talloc_strdup(screen,
-                       "tab=next, shift+tab=previous, x=exit, h=help");
+                       _("tab=next, shift+tab=previous, x=exit, h=help"));
        nc_scr_frame_draw(&screen->scr);
 
        scrollok(screen->scr.sub_ncw, true);
        nc_scr_frame_draw(&screen->scr);
 
        scrollok(screen->scr.sub_ncw, true);
index 6a6169431c8cedbc47e95b0b90559a024746a1ea..96d82cac21aa184d90c81c3c5a2c95866ed73300 100644 (file)
@@ -31,6 +31,7 @@
 #include "talloc/talloc.h"
 #include "waiter/waiter.h"
 #include "process/process.h"
 #include "talloc/talloc.h"
 #include "waiter/waiter.h"
 #include "process/process.h"
+#include "i18n/i18n.h"
 #include "ui/common/discover-client.h"
 #include "ui/common/ui-system.h"
 #include "nc-cui.h"
 #include "ui/common/discover-client.h"
 #include "ui/common/ui-system.h"
 #include "nc-cui.h"
@@ -116,7 +117,7 @@ int cui_run_cmd(struct pmenu_item *item)
        struct cui *cui = cui_from_item(item);
        const char **cmd_argv = item->data;
 
        struct cui *cui = cui_from_item(item);
        const char **cmd_argv = item->data;
 
-       nc_scr_status_printf(cui->current, "Running %s...", cmd_argv[0]);
+       nc_scr_status_printf(cui->current, _("Running %s..."), cmd_argv[0]);
 
        def_prog_mode();
 
 
        def_prog_mode();
 
@@ -127,7 +128,8 @@ int cui_run_cmd(struct pmenu_item *item)
 
        if (result) {
                pb_log("%s: failed: '%s'\n", __func__, cmd_argv[0]);
 
        if (result) {
                pb_log("%s: failed: '%s'\n", __func__, cmd_argv[0]);
-               nc_scr_status_printf(cui->current, "Failed: %s", cmd_argv[0]);
+               nc_scr_status_printf(cui->current, _("Failed: %s"),
+                               cmd_argv[0]);
        }
 
        return result;
        }
 
        return result;
@@ -147,13 +149,13 @@ static int cui_boot(struct pmenu_item *item)
 
        pb_debug("%s: %s\n", __func__, cod->name);
 
 
        pb_debug("%s: %s\n", __func__, cod->name);
 
-       nc_scr_status_printf(cui->current, "Booting %s...", cod->name);
+       nc_scr_status_printf(cui->current, _("Booting %s..."), cod->name);
 
        result = discover_client_boot(cui->client, NULL, cod->opt, cod->bd);
 
        if (result) {
                nc_scr_status_printf(cui->current,
 
        result = discover_client_boot(cui->client, NULL, cod->opt, cod->bd);
 
        if (result) {
                nc_scr_status_printf(cui->current,
-                               "Failed: boot %s", cod->bd->image);
+                               _("Failed: boot %s"), cod->bd->image);
        }
 
        return 0;
        }
 
        return 0;
@@ -180,7 +182,7 @@ static void cui_boot_editor_on_exit(struct cui *cui,
                int insert_pt;
 
                cod = talloc_zero(NULL, struct cui_opt_data);
                int insert_pt;
 
                cod = talloc_zero(NULL, struct cui_opt_data);
-               cod->name = talloc_asprintf(cod, "User item %u", ++user_idx);
+               cod->name = talloc_asprintf(cod, _("User item %u"), ++user_idx);
 
                item = pmenu_item_create(menu, cod->name);
                if (!item) {
 
                item = pmenu_item_create(menu, cod->name);
                if (!item) {
@@ -572,7 +574,8 @@ static void cui_update_status(struct boot_status *status, void *arg)
 
        nc_scr_status_printf(cui->current,
                        "%s: %s",
 
        nc_scr_status_printf(cui->current,
                        "%s: %s",
-                       status->type == BOOT_STATUS_ERROR ? "Error" : "Info",
+                       status->type == BOOT_STATUS_ERROR ?
+                               _("Error") : _("Info"),
                        status->message);
 
 }
                        status->message);
 
 }
@@ -666,7 +669,7 @@ struct cui *cui_init(void* platform_info,
 
        if (!cui) {
                pb_log("%s: alloc cui failed.\n", __func__);
 
        if (!cui) {
                pb_log("%s: alloc cui failed.\n", __func__);
-               fprintf(stderr, "%s: alloc cui failed.\n", __func__);
+               fprintf(stderr, _("%s: alloc cui failed.\n"), __func__);
                goto fail_alloc;
        }
 
                goto fail_alloc;
        }
 
@@ -699,19 +702,19 @@ retry_start:
                        goto retry_start;
 
                pb_log("%s: discover_client_init failed.\n", __func__);
                        goto retry_start;
 
                pb_log("%s: discover_client_init failed.\n", __func__);
-               fprintf(stderr, "%s: error: discover_client_init failed.\n",
+               fprintf(stderr, _("%s: error: discover_client_init failed.\n"),
                        __func__);
                        __func__);
-               fprintf(stderr, "could not start pb-discover, the petitboot "
-                       "daemon.\n");
+               fprintf(stderr, _("could not start pb-discover, the petitboot "
+                       "daemon.\n"));
                goto fail_client_init;
        }
 
        if (!cui->client) {
                pb_log("%s: discover_client_init failed.\n", __func__);
                goto fail_client_init;
        }
 
        if (!cui->client) {
                pb_log("%s: discover_client_init failed.\n", __func__);
-               fprintf(stderr, "%s: error: discover_client_init failed.\n",
+               fprintf(stderr, _("%s: error: discover_client_init failed.\n"),
                        __func__);
                        __func__);
-               fprintf(stderr, "check that pb-discover, "
-                       "the petitboot daemon is running.\n");
+               fprintf(stderr, _("check that pb-discover, "
+                       "the petitboot daemon is running.\n"));
                goto fail_client_init;
        }
 
                goto fail_client_init;
        }
 
index d70a8ec836f228666942e1e2be71bf276fd6fa43..3b27d5760090c618a785fd513b2feebecb66127f 100644 (file)
@@ -25,6 +25,7 @@
 #include <types/types.h>
 #include <log/log.h>
 #include <util/util.h>
 #include <types/types.h>
 #include <log/log.h>
 #include <util/util.h>
+#include <i18n/i18n.h>
 
 #include "nc-cui.h"
 #include "nc-textscreen.h"
 
 #include "nc-cui.h"
 #include "nc-textscreen.h"
@@ -56,10 +57,10 @@ struct help_screen *help_screen_init(struct cui *cui,
        screen = talloc_zero(cui, struct help_screen);
        screen->return_scr = current_scr;
 
        screen = talloc_zero(cui, struct help_screen);
        screen->return_scr = current_scr;
 
-       title = "Petitboot help";
+       title = _("Petitboot help");
        if (title_suffix)
                title = talloc_asprintf(screen,
        if (title_suffix)
                title = talloc_asprintf(screen,
-                               "Petitboot help: %s", title_suffix);
+                               _("Petitboot help: %s"), title_suffix);
 
        text_screen_init(&screen->text_scr, cui, title, on_exit);
        text_screen_set_text(&screen->text_scr, text);
 
        text_screen_init(&screen->text_scr, cui, title, on_exit);
        text_screen_set_text(&screen->text_scr, text);
index a5794f7a63608067a7de2839ea1bee342dcd6161..531ea2d9e90bd69855305ec6bbedaf2be00c61b4 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "log/log.h"
 #include "talloc/talloc.h"
 
 #include "log/log.h"
 #include "talloc/talloc.h"
+#include "i18n/i18n.h"
 #include "ui/common/ui-system.h"
 #include "nc-cui.h"
 #include "nc-menu.h"
 #include "ui/common/ui-system.h"
 #include "nc-cui.h"
 #include "nc-menu.h"
@@ -99,7 +100,7 @@ static const char *pmenu_item_label(struct pmenu_item *item, const char *name)
        /* if we have an invalid multibyte sequence, create an entirely
         * new name, indicating that we had invalid input */
        if (len == SIZE_MAX) {
        /* if we have an invalid multibyte sequence, create an entirely
         * new name, indicating that we had invalid input */
        if (len == SIZE_MAX) {
-               name = talloc_asprintf(item, "!Invalid option %d\n",
+               name = talloc_asprintf(item, _("!Invalid option %d"),
                                ++invalid_idx);
                return name;
        }
                                ++invalid_idx);
                return name;
        }
index aa1daea612354618fe23b387fd8184056a4b13dd..0d362e481d493ce88fa6ed4ca4478855f6cc6ddb 100644 (file)
@@ -25,6 +25,7 @@
 #include <types/types.h>
 #include <log/log.h>
 #include <util/util.h>
 #include <types/types.h>
 #include <log/log.h>
 #include <util/util.h>
+#include <i18n/i18n.h>
 
 #include "nc-cui.h"
 #include "nc-textscreen.h"
 
 #include "nc-cui.h"
 #include "nc-textscreen.h"
@@ -56,24 +57,24 @@ static void sysinfo_screen_populate(struct sysinfo_screen *screen,
 
 #define line(...) text_screen_append_line(&screen->text_scr, __VA_ARGS__)
        if (!sysinfo) {
 
 #define line(...) text_screen_append_line(&screen->text_scr, __VA_ARGS__)
        if (!sysinfo) {
-               line("Waiting for system information...");
+               line(_("Waiting for system information..."));
                return;
        }
 
                return;
        }
 
-       line("%-12s %s", "System type:", sysinfo->type ?: "");
-       line("%-12s %s", "System id:",   sysinfo->identifier ?: "");
+       line("%-12s %s", _("System type:"), sysinfo->type ?: "");
+       line("%-12s %s", _("System id:"),   sysinfo->identifier ?: "");
 
        if (sysinfo->n_blockdevs) {
                line(NULL);
 
        if (sysinfo->n_blockdevs) {
                line(NULL);
-               line("Storage devices");
+               line(_("Storage devices"));
        }
 
        for (i = 0; i < sysinfo->n_blockdevs; i++) {
                struct blockdev_info *info = sysinfo->blockdevs[i];
 
                line("%s:", info->name);
        }
 
        for (i = 0; i < sysinfo->n_blockdevs; i++) {
                struct blockdev_info *info = sysinfo->blockdevs[i];
 
                line("%s:", info->name);
-               line(" UUID:       %s", info->uuid);
-               line(" mounted at: %s", info->mountpoint);
+               line(_(" UUID:       %s"), info->uuid);
+               line(_(" mounted at: %s"), info->mountpoint);
                line(NULL);
        }
 
                line(NULL);
        }
 
@@ -89,8 +90,8 @@ static void sysinfo_screen_populate(struct sysinfo_screen *screen,
                if_info_mac_str(info, macbuf, sizeof(macbuf));
 
                line("%s:", info->name);
                if_info_mac_str(info, macbuf, sizeof(macbuf));
 
                line("%s:", info->name);
-               line(" MAC:  %s", macbuf);
-               line(" link: %s", info->link ? "up" : "down");
+               line(_(" MAC:  %s"), macbuf);
+               line(_(" link: %s"), info->link ? "up" : "down");
                line(NULL);
        }
 
                line(NULL);
        }
 
@@ -112,9 +113,9 @@ struct sysinfo_screen *sysinfo_screen_init(struct cui *cui,
 
        screen = talloc_zero(cui, struct sysinfo_screen);
        text_screen_init(&screen->text_scr, cui,
 
        screen = talloc_zero(cui, struct sysinfo_screen);
        text_screen_init(&screen->text_scr, cui,
-                       "Petitboot System Information", on_exit);
+                       _("Petitboot System Information"), on_exit);
        text_screen_set_help(&screen->text_scr,
        text_screen_set_help(&screen->text_scr,
-                       "System Information", sysinfo_help_text);
+                       _("System Information"), sysinfo_help_text);
 
        sysinfo_screen_update(screen, sysinfo);
 
 
        sysinfo_screen_update(screen, sysinfo);
 
index ad91f61e4c14b83cb499c8235cdd737d04232490..4ae0db42dfb989c824a5ddb1e2a036bdb6bcd35d 100644 (file)
@@ -26,6 +26,7 @@
 #include <log/log.h>
 #include <fold/fold.h>
 #include <util/util.h>
 #include <log/log.h>
 #include <fold/fold.h>
 #include <util/util.h>
+#include <i18n/i18n.h>
 
 #include "nc-cui.h"
 #include "nc-textscreen.h"
 
 #include "nc-cui.h"
 #include "nc-textscreen.h"
@@ -177,7 +178,7 @@ void text_screen_set_help(struct text_screen *screen, const char *title,
 {
        screen->help_title = title;
        screen->help_text = text;
 {
        screen->help_title = title;
        screen->help_text = text;
-       screen->scr.frame.help = "x=exit, h=help";
+       screen->scr.frame.help = _("x=exit, h=help");
 }
 
 static int text_screen_post(struct nc_scr *scr)
 }
 
 static int text_screen_post(struct nc_scr *scr)
@@ -204,6 +205,6 @@ void text_screen_init(struct text_screen *screen, struct cui *cui,
 
        screen->scr.frame.ltitle = talloc_strdup(screen, title);
        screen->scr.frame.rtitle = NULL;
 
        screen->scr.frame.ltitle = talloc_strdup(screen, title);
        screen->scr.frame.rtitle = NULL;
-       screen->scr.frame.help = "x=exit";
+       screen->scr.frame.help = _("x=exit");
        scrollok(screen->scr.sub_ncw, true);
 }
        scrollok(screen->scr.sub_ncw, true);
 }