Add support for i18n of the UI

Add all the boilerplate code required for doing i18n of the UI.
No translations available yet though
This commit is contained in:
Daniel P. Berrange 2010-01-11 16:01:20 +00:00
parent acf61455a3
commit 50f48b4d91
11 changed files with 72 additions and 19 deletions

View File

@ -22,6 +22,7 @@ Makefile\.in$
^src/Makefile$
^stamp-h1$
^virt-viewer\.spec$
^mingw32-virt-viewer\.spec$
^config.h.in$
^man/Makefile$
^man/virt-viewer\.1$
@ -32,3 +33,15 @@ Makefile\.in$
^plugin/.*\.so
^plugin/.*\.lo
^plugin/Makefile$
^m4/libtool\.m4$
^m4/ltoptions\.m4$
^m4/ltsugar\.m4$
^m4/ltversion\.m4$
^m4/lt~obsolete\.m4$
^po/POTFILES$
.*\.orig$
.*\.rej$
^po/Makefile\.in\.in$
^po/Makefile\.in$
^po/Makefile$
^po/stamp-it$

View File

@ -1,6 +1,21 @@
SUBDIRS = src man plugin
ACLOCAL_AMFLAGS = -I m4
EXTRA_DIST = @PACKAGE@.spec
SUBDIRS = src man plugin po
DISTCLEAN_FILES = @PACKAGE@.spec
EXTRA_DIST = @PACKAGE@.spec \
intltool-extract.in \
intltool-merge.in \
intltool-update.in
DISTCLEAN_FILES = @PACKAGE@.spec \
intltool-extract \
intltool-merge \
intltool-update
MAINTAINERCLEANFILES = \
m4/libtool.m4 \
m4/lt~obsolete.m4 \
m4/ltoptions.m4 \
m4/ltsugar.m4 \
m4/ltversion.m4

View File

@ -37,9 +37,10 @@ if test -z "$*"; then
fi
libtoolize --copy --force
aclocal
intltoolize --force
aclocal -I m4
autoheader
automake --add-missing
automake --add-missing --copy
autoconf
cd $THEDIR

View File

@ -16,6 +16,14 @@ AC_DEFINE([_GNU_SOURCE], [], [Enable GNU extensions])
VIRT_VIEWER_COMPILE_WARNINGS(maximum)
GETTEXT_PACKAGE=virt-viewer
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [GETTEXT package name])
IT_PROG_INTLTOOL([0.35.0])
AM_GLIB_GNU_GETTEXT
PKG_CHECK_MODULES(LIBXML2, libxml-2.0 >= 2.6.0)
PKG_CHECK_MODULES(LIBVIRT, libvirt >= 0.6.0)
PKG_CHECK_MODULES(GTK2, gtk+-2.0 >= 2.10.0)
@ -52,6 +60,7 @@ AM_CONDITIONAL(ENABLE_PLUGIN, [test "x$enable_plugin" = "xyes"])
AC_OUTPUT(Makefile
src/Makefile
man/Makefile
po/Makefile.in
plugin/Makefile
virt-viewer.spec
mingw32-virt-viewer.spec)

0
intltool-extract.in Normal file
View File

0
intltool-merge.in Normal file
View File

0
intltool-update.in Normal file
View File

0
po/LINGUAS Normal file
View File

8
po/POTFILES.in Normal file
View File

@ -0,0 +1,8 @@
src/auth.c
src/events.c
src/main.c
src/util.c
src/viewer.c
src/about.glade
src/auth.glade
src/viewer.glade

View File

@ -27,4 +27,5 @@ virt_viewer_CFLAGS = \
@LIBGLADE2_CFLAGS@ \
@LIBVIRT_CFLAGS@ \
@WARN_CFLAGS@ \
-DGLADE_DIR="\"$(gladedir)\""
-DGLADE_DIR="\"$(gladedir)\"" \
-DLOCALE_DIR=\""$(datadir)/locale"\"

View File

@ -21,15 +21,16 @@
*/
#include <config.h>
#include <locale.h>
#include <vncdisplay.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include "viewer.h"
static void viewer_version(FILE *out)
{
fprintf(out, "%s version %s\n", PACKAGE, VERSION);
fprintf(out, _("%s version %s\n"), PACKAGE, VERSION);
}
@ -46,29 +47,34 @@ int main(int argc, char **argv)
gboolean direct = FALSE;
gboolean waitvm = FALSE;
gboolean reconnect = FALSE;
const char *help_msg = "Run '" PACKAGE " --help' to see a full list of available command line options";
const char *help_msg = N_("Run '" PACKAGE " --help' to see a full list of available command line options");
const GOptionEntry options [] = {
{ "version", 'V', 0, G_OPTION_ARG_NONE, &print_version,
"display version information", NULL },
N_("display version information"), NULL },
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
"display verbose information", NULL },
N_("display verbose information"), NULL },
{ "direct", 'd', 0, G_OPTION_ARG_NONE, &direct,
"direct connection with no automatic tunnels", NULL },
N_("direct connection with no automatic tunnels"), NULL },
{ "connect", 'c', 0, G_OPTION_ARG_STRING, &uri,
"connect to hypervisor", "URI"},
N_("connect to hypervisor"), "URI"},
{ "wait", 'w', 0, G_OPTION_ARG_NONE, &waitvm,
"wait for domain to start", NULL },
N_("wait for domain to start"), NULL },
{ "reconnect", 'r', 0, G_OPTION_ARG_NONE, &reconnect,
"reconnect to domain upon restart", NULL },
N_("reconnect to domain upon restart"), NULL },
{ "debug", '\0', 0, G_OPTION_ARG_NONE, &debug,
"display debugging information", NULL },
N_("display debugging information"), NULL },
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &args,
NULL, "DOMAIN-NAME|ID|UUID" },
{ NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
};
setlocale(LC_ALL, "");
bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
textdomain(GETTEXT_PACKAGE);
/* Setup command line options */
context = g_option_context_new ("- Virtual machine graphical console");
context = g_option_context_new (_("- Virtual machine graphical console"));
g_option_context_add_main_entries (context, options, NULL);
g_option_context_add_group (context, gtk_get_option_group (TRUE));
g_option_context_add_group (context, vnc_display_get_option_group ());
@ -76,7 +82,7 @@ int main(int argc, char **argv)
if (error) {
g_print ("%s\n%s\n",
error->message,
help_msg);
gettext(help_msg));
g_error_free (error);
return 1;
}
@ -86,7 +92,7 @@ int main(int argc, char **argv)
}
if (!args || (g_strv_length(args) != 1)) {
fprintf(stderr, "\nUsage: %s [OPTIONS] DOMAIN-NAME|ID|UUID\n\n%s\n\n", argv[0], help_msg);
fprintf(stderr, _("\nUsage: %s [OPTIONS] DOMAIN-NAME|ID|UUID\n\n%s\n\n"), argv[0], help_msg);
return 1;
}