From: Oliver Kurth Date: Wed, 1 Apr 2020 18:31:35 +0000 (-0700) Subject: Fix localization issue of vmware-vgauth-cmd X-Git-Tag: stable-11.2.0~281 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=74351e2121e866ca0b28644a6fc545c97e8bfbda;p=thirdparty%2Fopen-vm-tools.git Fix localization issue of vmware-vgauth-cmd 1. default msg catalog folder is wrong, add correct msgCatalog in vgauth.conf 2. rename vmsg file name to "VGAuthCli" since file name used in main is "VGAuthCli" 3. Move I18n init up to fix variable localization issue --- diff --git a/open-vm-tools/vgauth/cli/Makefile.am b/open-vm-tools/vgauth/cli/Makefile.am index bea91390b..69bb10047 100644 --- a/open-vm-tools/vgauth/cli/Makefile.am +++ b/open-vm-tools/vgauth/cli/Makefile.am @@ -1,5 +1,5 @@ ################################################################################ -### Copyright (C) 2014-2016 VMware, Inc. All rights reserved. +### Copyright (C) 2014-2016, 2020 VMware, Inc. All rights reserved. ### ### This program is free software; you can redistribute it and/or modify ### it under the terms of version 2 of the GNU General Public License as @@ -47,5 +47,6 @@ else endif # Message catalogs. +# rename file name to "VGAuthCli" which used in main install-data-hook: - @INSTVMSG@ vmware-vgauth-cmd $(srcdir)/l10n $(DESTDIR)$(datadir) + @INSTVMSG@ VGAuthCli $(srcdir)/l10n $(DESTDIR)$(datadir) \ No newline at end of file diff --git a/open-vm-tools/vgauth/cli/main.c b/open-vm-tools/vgauth/cli/main.c index 25fbde7f2..7561699a6 100644 --- a/open-vm-tools/vgauth/cli/main.c +++ b/open-vm-tools/vgauth/cli/main.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2011-2019 VMware, Inc. All rights reserved. + * Copyright (C) 2011-2020 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -380,6 +380,44 @@ CliListMapped(VGAuthContext *ctx) } +/* + ****************************************************************************** + * InitMsgCatalog -- */ /** + * + * Initialize language setting according to machine locale + * + ****************************************************************************** + */ + +static void +InitMsgCatalog(void) +{ + PrefHandle prefs; + gchar *msgCatalog; + + /* + * Do this first, so any noise from the locale setup is properly filtered. + */ + VGAuth_SetLogHandler(CliLog, NULL, 0, NULL); + + /* + * Find the location of the i18n catalogs. + */ + setlocale(LC_ALL, ""); + prefs = Pref_Init(VGAUTH_PREF_CONFIG_FILENAME); + msgCatalog = Pref_GetString(prefs, + VGAUTH_PREF_LOCALIZATION_DIR, + VGAUTH_PREF_GROUP_NAME_LOCALIZATION, + VGAUTH_PREF_DEFAULT_LOCALIZATION_CATALOG); + + I18n_BindTextDomain(VMW_TEXT_DOMAIN, // domain -- base name of vmsg files + NULL, // locale -- let it figure it out + msgCatalog); // path to message catalogs + g_free(msgCatalog); + Pref_Shutdown(prefs); +} + + /* ****************************************************************************** * mainRun -- */ /** @@ -422,14 +460,14 @@ mainRun(int argc, const gchar *lSubject = SU_(cmdline.summary.subject, "subject"); const gchar *lPEMfile = SU_(cmdline.summary.pemfile, "PEM-file"); const gchar *lComm = SU_(cmdline.summary.comm, "comment"); + #if (use_glib_parser == 0) int i; GOptionEntry *cmdOptions; #else GError *gErr = NULL; #endif - PrefHandle prefs; - gchar *msgCatalog = NULL; + GOptionEntry listOptions[] = { { "username", 'u', 0, G_OPTION_ARG_STRING, &userName, SU_(listoptions.username, @@ -479,26 +517,6 @@ mainRun(int argc, argcCopy = argc; argvCopy = argv; - /* - * Do this first, so any noise form the locale setup is properly filtered. - */ - VGAuth_SetLogHandler(CliLog, NULL, 0, NULL); - - /* - * Find the location of the i18n catalogs. - */ - setlocale(LC_ALL, ""); - prefs = Pref_Init(VGAUTH_PREF_CONFIG_FILENAME); - msgCatalog = Pref_GetString(prefs, - VGAUTH_PREF_LOCALIZATION_DIR, - VGAUTH_PREF_GROUP_NAME_LOCALIZATION, - VGAUTH_PREF_DEFAULT_LOCALIZATION_CATALOG); - - I18n_BindTextDomain(VMW_TEXT_DOMAIN, // domain -- base name of vmsg files - NULL, // locale -- let it figure it out - msgCatalog); // path to message catalogs - g_free(msgCatalog); - /* * Set up the option parser */ @@ -660,7 +678,6 @@ next: } VGAuth_Shutdown(ctx); - Pref_Shutdown(prefs); g_free(appName); return (err == VGAUTH_E_OK) ? 0 : -1; } @@ -696,6 +713,8 @@ wmain(int argc, CHK_UTF16_TO_UTF8(argvUtf8[i], argv[i], goto end); } + InitMsgCatalog(); + retval = mainRun(argc, argvUtf8); end: @@ -731,6 +750,7 @@ int main(int argc, char *argv[]) { + InitMsgCatalog(); return mainRun(argc, argv); } diff --git a/open-vm-tools/vgauth/service/Makefile.am b/open-vm-tools/vgauth/service/Makefile.am index 774808e1c..240f73eb5 100644 --- a/open-vm-tools/vgauth/service/Makefile.am +++ b/open-vm-tools/vgauth/service/Makefile.am @@ -1,5 +1,5 @@ ################################################################################ -### Copyright (C) 2014-2019 VMware, Inc. All rights reserved. +### Copyright (C) 2014-2020 VMware, Inc. All rights reserved. ### ### This program is free software; you can redistribute it and/or modify ### it under the terms of version 2 of the GNU General Public License as @@ -102,7 +102,10 @@ else VGAuthService_LINK = $(LINK) endif +VGAuthMsgDir = $(datadir)/open-vm-tools + # Message catalogs. install-data-hook: @INSTVMSG@ VGAuthService $(srcdir)/l10n $(DESTDIR)$(datadir) - cat vgauth.conf | sed -e"s!@@VGAUTHSCHEMADIR@@!$(VGAuthServicedir)!" > $(DESTDIR)/etc/vmware-tools/vgauth.conf + cat vgauth.conf | sed -e"s!@@VGAUTHSCHEMADIR@@!$(VGAuthServicedir)!" \ + | sed -e"s!@@VGAUTHMSGDIR@@!$(VGAuthMsgDir)!" > $(DESTDIR)/etc/vmware-tools/vgauth.conf diff --git a/open-vm-tools/vgauth/service/vgauth.conf b/open-vm-tools/vgauth/service/vgauth.conf index 3c758873b..c79f9f9bf 100644 --- a/open-vm-tools/vgauth/service/vgauth.conf +++ b/open-vm-tools/vgauth/service/vgauth.conf @@ -1,3 +1,5 @@ [service] samlSchemaDir = @@VGAUTHSCHEMADIR@@ +[localization] +msgCatalog = @@VGAUTHMSGDIR@@