From 21f8468708c6b4459a44c93e543e7a10884ab4c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Mon, 9 Jul 2012 15:11:43 +0200 Subject: [PATCH] nm-online: internationalize nm-online tool --- po/POTFILES.in | 1 + test/Makefile.am | 3 ++- test/nm-online.c | 31 +++++++++++++++++++++---------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index cce778fb1..71a07aa62 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -32,4 +32,5 @@ src/nm-manager.c src/nm-netlink-monitor.c src/settings/plugins/ifcfg-rh/reader.c src/settings/nm-settings-utils.c +test/nm-online.c diff --git a/test/Makefile.am b/test/Makefile.am index b62853676..34b69aad3 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -10,7 +10,8 @@ AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ -DBINDIR=\"$(bindir)\" \ -DNM_RUN_DIR=\"$(rundir)\" \ - -DDATADIR=\"$(datadir)\" + -DDATADIR=\"$(datadir)\" \ + -DNMLOCALEDIR=\"$(datadir)/locale\" bin_PROGRAMS = nm-tool nm-online diff --git a/test/nm-online.c b/test/nm-online.c index 985cc774f..77f74638f 100644 --- a/test/nm-online.c +++ b/test/nm-online.c @@ -30,14 +30,16 @@ * Robert Love */ -#define PROGRESS_STEPS 15 +#include #include #include #include #include +#include #include +#include #include #include #include @@ -45,6 +47,8 @@ #include "NetworkManager.h" #include "nm-glib-compat.h" +#define PROGRESS_STEPS 15 + typedef struct { int value; @@ -105,7 +109,7 @@ static gboolean handle_timeout (gpointer data) Timeout *timeout = (Timeout *) data; if (!timeout->quiet) { - g_print ("\rConnecting"); + g_print (_("\rConnecting")); for (; i > 0; i--) putchar ((timeout->value >= (i * timeout->norm)) ? ' ' : '.'); if (timeout->value) @@ -136,26 +140,33 @@ int main (int argc, char *argv[]) gboolean success; GOptionEntry options[] = { - {"timeout", 't', 0, G_OPTION_ARG_INT, &t_secs, "Time to wait for a connection, in seconds (default is 30)", NULL}, - {"exit", 'x', 0, G_OPTION_ARG_NONE, &exit_no_nm, "Exit immediately if NetworkManager is not running or connecting", NULL}, - {"quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet, "Don't print anything", NULL}, + {"timeout", 't', 0, G_OPTION_ARG_INT, &t_secs, N_("Time to wait for a connection, in seconds (default is 30)"), NULL}, + {"exit", 'x', 0, G_OPTION_ARG_NONE, &exit_no_nm, N_("Exit immediately if NetworkManager is not running or connecting"), NULL}, + {"quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet, N_("Don't print anything"), NULL}, {NULL} }; - opt_ctx = g_option_context_new (""); - g_option_context_set_translation_domain (opt_ctx, "UTF-8"); + /* Set locale to be able to use environment variables */ + setlocale (LC_ALL, ""); + + bindtextdomain (GETTEXT_PACKAGE, NMLOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + textdomain (GETTEXT_PACKAGE); + + opt_ctx = g_option_context_new (NULL); + g_option_context_set_translation_domain (opt_ctx, GETTEXT_PACKAGE); g_option_context_set_ignore_unknown_options (opt_ctx, FALSE); g_option_context_set_help_enabled (opt_ctx, TRUE); g_option_context_add_main_entries (opt_ctx, options, NULL); g_option_context_set_summary (opt_ctx, - "Waits for a successful connection in NetworkManager."); + _("Waits for a successful connection in NetworkManager.")); success = g_option_context_parse (opt_ctx, &argc, &argv, NULL); g_option_context_free (opt_ctx); if (!success) { - g_warning ("Invalid option. Please use --help to see a list of valid options."); + g_warning (_("Invalid option. Please use --help to see a list of valid options.")); return 2; } @@ -164,7 +175,7 @@ int main (int argc, char *argv[]) else timeout.value = 30; if (timeout.value < 0 || timeout.value > 3600) { - g_warning ("Invalid option. Please use --help to see a list of valid options."); + g_warning (_("Invalid option. Please use --help to see a list of valid options.")); return 2; }