Make gsettings-tool translatable again

This regression was caused by the recent rewrite.
This commit is contained in:
Matthias Clasen 2010-10-29 23:12:07 -04:00
parent cb64773002
commit d619216686

View File

@ -19,7 +19,11 @@
* Author: Ryan Lortie <desrt@desrt.ca> * Author: Ryan Lortie <desrt@desrt.ca>
*/ */
#include "config.h"
#include <gio/gio.h> #include <gio/gio.h>
#include <gi18n.h>
#include <locale.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
@ -53,12 +57,12 @@ check_relocatable_schema (const gchar *schema)
return TRUE; return TRUE;
if (is_schema (schema)) if (is_schema (schema))
g_printerr ("Schema '%s' is not relocatable " g_printerr (_("Schema '%s' is not relocatable "
"(path must not be specified)\n", "(path must not be specified)\n"),
schema); schema);
else else
g_printerr ("No such schema '%s'\n", schema); g_printerr (_("No such schema '%s'\n"), schema);
return FALSE; return FALSE;
} }
@ -70,12 +74,12 @@ check_schema (const gchar *schema)
return TRUE; return TRUE;
if (is_relocatable_schema (schema)) if (is_relocatable_schema (schema))
g_printerr ("Schema '%s' is relocatable " g_printerr (_("Schema '%s' is relocatable "
"(path must be specified)\n", "(path must be specified)\n"),
schema); schema);
else else
g_printerr ("No such schema '%s'\n", schema); g_printerr (_("No such schema '%s'\n"), schema);
return FALSE; return FALSE;
} }
@ -85,25 +89,25 @@ check_path (const gchar *path)
{ {
if (path[0] == '\0') if (path[0] == '\0')
{ {
g_printerr ("Empty path given.\n"); g_printerr (_("Empty path given.\n"));
return FALSE; return FALSE;
} }
if (path[0] != '/') if (path[0] != '/')
{ {
g_printerr ("Path must begin with a slash (/)\n"); g_printerr (_("Path must begin with a slash (/)\n"));
return FALSE; return FALSE;
} }
if (!g_str_has_suffix (path, "/")) if (!g_str_has_suffix (path, "/"))
{ {
g_printerr ("Path must end with a slash (/)\n"); g_printerr (_("Path must end with a slash (/)\n"));
return FALSE; return FALSE;
} }
if (strstr (path, "//")) if (strstr (path, "//"))
{ {
g_printerr ("Path must not contain two adjacent slashes (//)\n"); g_printerr (_("Path must not contain two adjacent slashes (//)\n"));
return FALSE; return FALSE;
} }
@ -124,7 +128,7 @@ check_key (GSettings *settings,
if (good) if (good)
return TRUE; return TRUE;
g_printerr ("No such key '%s'\n", key); g_printerr (_("No such key '%s'\n"), key);
return FALSE; return FALSE;
} }
@ -348,7 +352,7 @@ gsettings_set (GSettings *settings,
if (!g_settings_range_check (settings, key, new)) if (!g_settings_range_check (settings, key, new))
{ {
g_printerr ("The provided value is outside of the valid range\n"); g_printerr (_("The provided value is outside of the valid range\n"));
g_variant_unref (new); g_variant_unref (new);
exit (1); exit (1);
} }
@ -375,68 +379,68 @@ gsettings_help (gboolean requested,
else if (strcmp (command, "list-schemas") == 0) else if (strcmp (command, "list-schemas") == 0)
{ {
description = "List the installed (non-relocatable) schemas"; description = _("List the installed (non-relocatable) schemas");
synopsis = ""; synopsis = "";
} }
else if (strcmp (command, "list-relocatable-schemas") == 0) else if (strcmp (command, "list-relocatable-schemas") == 0)
{ {
description = "List the installed relocatable schemas"; description = _("List the installed relocatable schemas");
synopsis = ""; synopsis = "";
} }
else if (strcmp (command, "list-keys") == 0) else if (strcmp (command, "list-keys") == 0)
{ {
description = "Lists the keys in SCHEMA"; description = _("Lists the keys in SCHEMA");
synopsis = "SCHEMA[:PATH]"; synopsis = N_("SCHEMA[:PATH]");
} }
else if (strcmp (command, "list-children") == 0) else if (strcmp (command, "list-children") == 0)
{ {
description = "Lists the children of SCHEMA"; description = _("Lists the children of SCHEMA");
synopsis = "SCHEMA[:PATH]"; synopsis = N_("SCHEMA[:PATH]");
} }
else if (strcmp (command, "get") == 0) else if (strcmp (command, "get") == 0)
{ {
description = "Gets the value of KEY"; description = _("Gets the value of KEY");
synopsis = "SCHEMA[:PATH] KEY"; synopsis = N_("SCHEMA[:PATH] KEY");
} }
else if (strcmp (command, "range") == 0) else if (strcmp (command, "range") == 0)
{ {
description = "Queries the range of valid values for KEY"; description = _("Queries the range of valid values for KEY");
synopsis = "SCHEMA[:PATH] KEY"; synopsis = N_("SCHEMA[:PATH] KEY");
} }
else if (strcmp (command, "set") == 0) else if (strcmp (command, "set") == 0)
{ {
description = "Sets the value of KEY to VALUE"; description = _("Sets the value of KEY to VALUE");
synopsis = "SCHEMA[:PATH] KEY VALUE"; synopsis = N_("SCHEMA[:PATH] KEY VALUE");
} }
else if (strcmp (command, "reset") == 0) else if (strcmp (command, "reset") == 0)
{ {
description = "Resets KEY to its default value"; description = _("Resets KEY to its default value");
synopsis = "SCHEMA[:PATH] KEY"; synopsis = N_("SCHEMA[:PATH] KEY");
} }
else if (strcmp (command, "writable") == 0) else if (strcmp (command, "writable") == 0)
{ {
description = "Checks if KEY is writable"; description = _("Checks if KEY is writable");
synopsis = "SCHEMA[:PATH] KEY"; synopsis = N_("SCHEMA[:PATH] KEY");
} }
else if (strcmp (command, "monitor") == 0) else if (strcmp (command, "monitor") == 0)
{ {
description = "Monitors KEY for changes.\n" description = _("Monitors KEY for changes.\n"
"If no KEY is specified, monitor all keys in SCHEMA.\n" "If no KEY is specified, monitor all keys in SCHEMA.\n"
"Use ^C to stop monitoring.\n"; "Use ^C to stop monitoring.\n");
synopsis = "SCHEMA[:PATH] [KEY]"; synopsis = N_("SCHEMA[:PATH] [KEY]");
} }
else else
{ {
g_string_printf (string, "Unknown command %s\n\n", command); g_string_printf (string, _("Unknown command %s\n\n"), command);
requested = FALSE; requested = FALSE;
command = NULL; command = NULL;
} }
@ -444,7 +448,7 @@ gsettings_help (gboolean requested,
if (command == NULL) if (command == NULL)
{ {
g_string_append (string, g_string_append (string,
"Usage:\n" _("Usage:\n"
" gsettings COMMAND [ARGS...]\n" " gsettings COMMAND [ARGS...]\n"
"\n" "\n"
"Commands:\n" "Commands:\n"
@ -460,33 +464,33 @@ gsettings_help (gboolean requested,
" writable Check if a key is writable\n" " writable Check if a key is writable\n"
" monitor Watch for changes\n" " monitor Watch for changes\n"
"\n" "\n"
"Use 'gsettings help COMMAND' to get detailed help.\n\n"); "Use 'gsettings help COMMAND' to get detailed help.\n\n"));
} }
else else
{ {
g_string_append_printf (string, "Usage:\n gsettings %s %s\n\n%s\n\n", g_string_append_printf (string, _("Usage:\n gsettings %s %s\n\n%s\n\n"),
command, synopsis, description); command, _(synopsis), description);
if (synopsis[0]) if (synopsis[0])
{ {
g_string_append (string, "Arguments:\n"); g_string_append (string, _("Arguments:\n"));
if (strstr (synopsis, "SCHEMA")) if (strstr (synopsis, "SCHEMA"))
g_string_append (string, g_string_append (string,
" SCHEMA The name of the schema\n" _(" SCHEMA The name of the schema\n"
" PATH The path, for relocatable schemas\n"); " PATH The path, for relocatable schemas\n"));
if (strstr (synopsis, "[KEY]")) if (strstr (synopsis, "[KEY]"))
g_string_append (string, g_string_append (string,
" KEY The (optional) key within the schema\n"); _(" KEY The (optional) key within the schema\n"));
else if (strstr (synopsis, "KEY")) else if (strstr (synopsis, "KEY"))
g_string_append (string, g_string_append (string,
" KEY The key within the schema\n"); _(" KEY The key within the schema\n"));
if (strstr (synopsis, "VALUE")) if (strstr (synopsis, "VALUE"))
g_string_append (string, g_string_append (string,
" VALUE The value to set\n"); _(" VALUE The value to set\n"));
g_string_append (string, "\n"); g_string_append (string, "\n");
} }
@ -510,6 +514,8 @@ main (int argc, char **argv)
GSettings *settings; GSettings *settings;
const gchar *key; const gchar *key;
setlocale (LC_ALL, "");
if (argc < 2) if (argc < 2)
return gsettings_help (FALSE, NULL); return gsettings_help (FALSE, NULL);
@ -557,7 +563,7 @@ main (int argc, char **argv)
if (argv[2][0] == '\0') if (argv[2][0] == '\0')
{ {
g_printerr ("Empty schema name given"); g_printerr (_("Empty schema name given"));
return 1; return 1;
} }