Bug 1397 - Allow localizing the command line help

Clutter has a set of command line options that are added to every
application by means of clutter_init() or by obtaining the Clutter
GOptionGroup and using g_option_context_parse(). Thus, every Clutter
application will automatically have an --help command line switch
showing the list of options and their description.

At the moment, Clutter does not enable localization of the help,
thus making it less than useful on non-English locales.

This patch enables the machinery to create a localization file and
load it when initializing Clutter, by means of the GLib macros and
locale.h API we already use.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
This commit is contained in:
Takao Fujiwara 2009-01-06 12:11:07 +00:00 committed by Emmanuele Bassi
parent e5543a658f
commit 8e6423a1b6
5 changed files with 34 additions and 11 deletions

View File

@ -1142,16 +1142,16 @@ clutter_init_real (GError **error)
static GOptionEntry clutter_args[] = {
{ "clutter-show-fps", 0, 0, G_OPTION_ARG_NONE, &clutter_show_fps,
"Show frames per second", NULL },
N_("Show frames per second"), NULL },
{ "clutter-default-fps", 0, 0, G_OPTION_ARG_INT, &clutter_default_fps,
"Default frame rate", "FPS" },
N_("Default frame rate"), "FPS" },
{ "g-fatal-warnings", 0, 0, G_OPTION_ARG_NONE, &clutter_fatal_warnings,
"Make all warnings fatal", NULL },
N_("Make all warnings fatal"), NULL },
#ifdef CLUTTER_ENABLE_DEBUG
{ "clutter-debug", 0, 0, G_OPTION_ARG_CALLBACK, clutter_arg_debug_cb,
"Clutter debugging flags to set", "FLAGS" },
N_("Clutter debugging flags to set"), "FLAGS" },
{ "clutter-no-debug", 0, 0, G_OPTION_ARG_CALLBACK, clutter_arg_no_debug_cb,
"Clutter debugging flags to unset", "FLAGS" },
N_("Clutter debugging flags to unset"), "FLAGS" },
#endif /* CLUTTER_ENABLE_DEBUG */
{ NULL, },
};
@ -1294,13 +1294,14 @@ clutter_get_option_group (void)
context = clutter_context_get_default ();
group = g_option_group_new ("clutter",
"Clutter Options",
"Show Clutter Options",
_("Clutter Options"),
_("Show Clutter Options"),
NULL,
NULL);
g_option_group_set_parse_hooks (group, pre_parse_hook, post_parse_hook);
g_option_group_add_entries (group, clutter_args);
g_option_group_set_translation_domain (group, GETTEXT_PACKAGE);
/* add backend-specific options */
_clutter_backend_add_options (context->backend, group);
@ -2118,6 +2119,9 @@ clutter_base_init (void)
initialised = TRUE;
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
/* initialise GLib type system */
g_type_init ();

View File

@ -29,6 +29,8 @@
#include <unistd.h>
#endif
#include <glib/gi18n-lib.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
@ -150,7 +152,7 @@ static const GOptionEntry entries[] =
{ "vblank", 0,
0,
G_OPTION_ARG_STRING, &clutter_vblank_name,
"VBlank method to be used (none, dri or glx)", "METHOD"
N_("VBlank method to be used (none, dri or glx)"), "METHOD"
},
{ NULL }
};

View File

@ -23,6 +23,8 @@
#include "config.h"
#endif
#include <glib/gi18n-lib.h>
#include <string.h>
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
@ -235,18 +237,18 @@ static const GOptionEntry entries[] =
"display", 0,
G_OPTION_FLAG_IN_MAIN,
G_OPTION_ARG_STRING, &clutter_display_name,
"X display to use", "DISPLAY"
N_("X display to use"), "DISPLAY"
},
{
"screen", 0,
G_OPTION_FLAG_IN_MAIN,
G_OPTION_ARG_INT, &clutter_screen,
"X screen to use", "SCREEN"
N_("X screen to use"), "SCREEN"
},
{ "synch", 0,
0,
G_OPTION_ARG_NONE, &clutter_synchronise,
"Make X calls synchronous", NULL,
N_("Make X calls synchronous"), NULL,
},
{ NULL }
};

View File

@ -637,6 +637,7 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE",
ALL_LINGUAS=""
AM_GLIB_GNU_GETTEXT
GLIB_DEFINE_LOCALEDIR(LOCALEDIR)
AC_CONFIG_FILES([
Makefile

View File

@ -0,0 +1,14 @@
clutter/clutter-actor.c
clutter/clutter-behaviour.c
clutter/clutter-color.c
clutter/clutter-container.c
clutter/clutter-event.c
clutter/clutter-fixed.c
clutter/clutter-fixed.h
clutter/clutter-main.c
clutter/clutter-stage-window.c
clutter/clutter-stage.c
clutter/clutter-texture.c
clutter/clutter-units.c
clutter/glx/clutter-backend-glx.c
clutter/x11/clutter-backend-x11.c