]> git.ozlabs.org Git - petitboot/blobdiff - ui/ncurses/nc-cui.c
ui/ncurses: Use a separate type for help text
[petitboot] / ui / ncurses / nc-cui.c
index 9d788fe551aebbd1aebdf4a9a02a3b284e0e74e8..cd7952f860545e90cdf1245035b0b7b69868a57a 100644 (file)
@@ -24,7 +24,6 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <string.h>
-#include <locale.h>
 #include <sys/ioctl.h>
 
 #include "log/log.h"
@@ -32,6 +31,7 @@
 #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"
@@ -117,7 +117,7 @@ int cui_run_cmd(struct pmenu_item *item)
        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();
 
@@ -128,7 +128,8 @@ int cui_run_cmd(struct pmenu_item *item)
 
        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;
@@ -148,13 +149,13 @@ static int cui_boot(struct pmenu_item *item)
 
        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,
-                               "Failed: boot %s", cod->bd->image);
+                               _("Failed: boot %s"), cod->bd->image);
        }
 
        return 0;
@@ -181,7 +182,7 @@ static void cui_boot_editor_on_exit(struct cui *cui,
                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) {
@@ -269,7 +270,8 @@ static void cui_help_exit(struct cui *cui)
        cui->help_screen = NULL;
 }
 
-void cui_show_help(struct cui *cui, const char *title, const char *text)
+void cui_show_help(struct cui *cui, const char *title,
+               const struct help_text *text)
 {
        if (!cui->current)
                return;
@@ -573,7 +575,8 @@ static void cui_update_status(struct boot_status *status, void *arg)
 
        nc_scr_status_printf(cui->current,
                        "%s: %s",
-                       status->type == BOOT_STATUS_ERROR ? "Error" : "Info",
+                       status->type == BOOT_STATUS_ERROR ?
+                               _("Error") : _("Info"),
                        status->message);
 
 }
@@ -667,7 +670,7 @@ struct cui *cui_init(void* platform_info,
 
        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;
        }
 
@@ -677,8 +680,6 @@ struct cui *cui_init(void* platform_info,
 
        process_init(cui, cui->waitset, false);
 
-       setlocale(LC_ALL, "");
-
        /* Loop here for scripts that just started the server. */
 
 retry_start:
@@ -702,19 +703,19 @@ retry_start:
                        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__);
-               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__);
-               fprintf(stderr, "%s: error: discover_client_init failed.\n",
+               fprintf(stderr, _("%s: error: discover_client_init failed.\n"),
                        __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;
        }