]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Use new i18n infrastructure in vmtoolsd.
authorVMware, Inc <>
Mon, 22 Mar 2010 19:23:45 +0000 (12:23 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Mon, 22 Mar 2010 19:23:45 +0000 (12:23 -0700)
Initialize the user's locale properly, and use the new macros to retrieve
the strings used in the command line help. (Don't localize the command line
switches themselves, though, since that's confusing.)

When initializing plugins, automatically bind them to a text domain based
on their name.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/services/vmtoolsd/cmdLine.c
open-vm-tools/services/vmtoolsd/mainPosix.c
open-vm-tools/services/vmtoolsd/pluginMgr.c
open-vm-tools/services/vmtoolsd/toolsCoreInt.h

index 1771ce7f20f689e2477cf9e8d23932ef462673d0..655579c5e77c05e11ca0a22ee03be6d10a33278a 100644 (file)
@@ -39,6 +39,7 @@
 #include "str.h"
 #include "vmtoolsd_version.h"
 #include "vmware/tools/utils.h"
+#include "vmware/tools/i18n.h"
 
 
 /**
@@ -197,38 +198,53 @@ ToolsCore_ParseCommandLine(ToolsServiceState *state,
 #endif
    GOptionEntry clOptions[] = {
       { "name", 'n', 0, G_OPTION_ARG_STRING, &state->name,
-         N_("Name of the service being started."), N_("svcname") },
+         SU_(cmdline.name, "Name of the service being started."),
+         SU_(cmdline.name.argument, "svcname") },
       { "common-path", '\0', 0, G_OPTION_ARG_FILENAME, &state->commonPath,
-         N_("Path to the common plugin directory."), N_("path") },
+         SU_(cmdline.commonpath, "Path to the common plugin directory."),
+         SU_(cmdline.path, "path") },
       { "plugin-path", 'p', 0, G_OPTION_ARG_FILENAME, &state->pluginPath,
-         N_("Path to the plugin directory."), N_("path") },
+         SU_(cmdline.pluginpath, "Path to the plugin directory."),
+         SU_(cmdline.path, "path") },
       { "cmd", '\0', 0, G_OPTION_ARG_CALLBACK, ToolsCoreRunCommand,
-         N_("Sends an RPC command to the host and exits."), N_("command") },
+         SU_(cmdline.rpc, "Sends an RPC command to the host and exits."),
+         SU_(cmdline.rpc.command, "command") },
 #if defined(G_PLATFORM_WIN32)
       { "dump-state", 's', 0, G_OPTION_ARG_NONE, &dumpState,
-         N_("Dumps the internal state of a running service instance to the logs."), 0 },
+         SU_(cmdline.state, "Dumps the internal state of a running service instance to the logs."),
+         NULL },
       { "kill", 'k', 0, G_OPTION_ARG_NONE, &kill,
-         N_("Stops a running instance of a tools service."), 0 },
+         SU_(cmdline.kill, "Stops a running instance of a tools service."),
+         NULL },
       { "install", 'i', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, ToolsCoreIgnoreArg,
-         N_("Installs the service with the Service Control Manager."), N_("args") },
+         SU_(cmdline.install, "Installs the service with the Service Control Manager."),
+         SU_(cmdline.install.args, "args") },
       { "uninstall", 'u', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, ToolsCoreIgnoreArg,
-         N_("Uninstalls the service from the Service Control Manager."), NULL },
+         SU_(cmdline.uninstall, "Uninstalls the service from the Service Control Manager."),
+         NULL },
       { "displayname", 'd', 0, G_OPTION_ARG_STRING, &state->displayName,
-         N_("Service display name (only used with -i)."), N_("name") },
+         SU_(cmdline.displayname, "Service display name (only used with -i)."),
+         SU_(cmdline.displayname.argument, "name") },
 #else
       { "background", 'b', 0, G_OPTION_ARG_FILENAME, &state->pidFile,
-         N_("Runs in the background and creates a pid file."), N_("pidfile") },
+         SU_(cmdline.background, "Runs in the background and creates a pid file."),
+         SU_(cmdline.background.pidfile, "pidfile") },
       { "blockFd", '\0', 0, G_OPTION_ARG_INT, &state->ctx.blockFD,
-         N_("File descriptor for the VMware blocking fs."), N_("fd") },
+         SU_(cmdline.blockfd, "File descriptor for the VMware blocking fs."),
+         SU_(cmdline.blockfd.fd, "fd") },
 #endif
       { "config", 'c', 0, G_OPTION_ARG_FILENAME, &state->configFile,
-         N_("Uses the config file at the given path."), N_("path") },
+         SU_(cmdline.config, "Uses the config file at the given path."),
+         SU_(cmdline.path, "path") },
       { "debug", 'g', 0, G_OPTION_ARG_FILENAME, &state->debugPlugin,
-         N_("Runs in debug mode, using the given plugin."), N_("path") },
+         SU_(cmdline.debug, "Runs in debug mode, using the given plugin."),
+         SU_(cmdline.path, "path") },
       { "log", 'l', 0, G_OPTION_ARG_NONE, &state->log,
-         N_("Turns on logging. Overrides the config file."), NULL },
+         SU_(cmdline.log, "Turns on logging. Overrides the config file."),
+         NULL },
       { "version", 'v', 0, G_OPTION_ARG_NONE, &version,
-         N_("Prints the daemon version and exits."), NULL },
+         SU_(cmdline.version, "Prints the daemon version and exits."),
+         NULL },
       { NULL }
    };
    GError *error = NULL;
index 9782c33dac46fa066cc5c8a0fc718eb66f45af13..2b36441b300c53d5ef8757c79d57da39d368fc28 100644 (file)
@@ -24,6 +24,7 @@
 
 
 #include "toolsCoreInt.h"
+#include <locale.h>
 #include <signal.h>
 #include <string.h>
 #include <unistd.h>
@@ -34,6 +35,7 @@
 #include "system.h"
 #include "unicode.h"
 #include "util.h"
+#include "vmware/tools/i18n.h"
 #include "vmware/tools/utils.h"
 
 #if !defined(__APPLE__)
@@ -133,6 +135,10 @@ main(int argc,
       argvCopy[i] = argv[i];
    }
 
+   setlocale(LC_ALL, "");
+   VMTools_ConfigLogging(G_LOG_DOMAIN, NULL, FALSE, FALSE);
+   VMTools_BindTextDomain(VMW_TEXT_DOMAIN, NULL, NULL);
+
    if (!ToolsCore_ParseCommandLine(&gState, argc, argvCopy)) {
       g_free(argvCopy);
       goto exit;
index 328fbf7892727ad8a5121e31123a777950b7a376..664e262273757d1174795d1c37ddc0d1375d49e9 100644 (file)
@@ -27,6 +27,7 @@
 #include "guestApp.h"
 #include "toolsCoreInt.h"
 #include "util.h"
+#include "vmware/tools/i18n.h"
 #include "vmware/tools/utils.h"
 
 
@@ -476,6 +477,7 @@ ToolsCoreLoadDirectory(ToolsAppCtx *ctx,
       plugin = g_malloc(sizeof *plugin);
       plugin->module = module;
       plugin->data = data;
+      VMTools_BindTextDomain(data->name, NULL, NULL);
 
       g_ptr_array_add(regs, plugin);
       g_debug("Plugin '%s' initialized.\n", plugin->data->name);
index ecf4c985c673c17878e87477b07cb730fb8a0025..d59d3f40d853edfe9265fe6a3ed755d2c99a2fa7 100644 (file)
@@ -25,7 +25,8 @@
  *    Internal functions for the tools daemon.
  */
 
-#define G_LOG_DOMAIN       "vmtoolsd"
+#define VMW_TEXT_DOMAIN    "vmtoolsd"
+#define G_LOG_DOMAIN       VMW_TEXT_DOMAIN
 #define TOOLSCORE_COMMON   "common"
 
 #include <glib-object.h>