/*********************************************************
- * Copyright (C) 2011-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2011-2018 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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <locale.h>
#ifndef _WIN32
#include <unistd.h>
#include <errno.h>
/*
* 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,
/*********************************************************
- * Copyright (C) 2011-2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2011-2018 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
* codeset information.
*/
char *tmp;
-#ifdef VMX86_DEBUG
/*
- * Simple override for testing. Various documented env variables
- * don't seem to properly kick in.
+ * This is useful for testing, and also seems to be used by some
+ * distros (NeoKylin) rather than the setlocale() APIs.
+ * See PR 1672149
*/
char *envLocale = getenv("LANG");
- if (envLocale) {
+ if (envLocale != NULL) {
lang = g_strdup(envLocale);
- g_debug("Using LANG override of '%s'\n", lang);
+ g_debug("%s: Using LANG override of '%s'\n", __FUNCTION__, lang);
return lang;
}
-#endif
tmp = setlocale(LC_MESSAGES, NULL);
if (tmp == NULL) {
lang = g_strdup("C");
ASSERT(localPath != NULL);
stream = g_io_channel_new_file(localPath, "r", &err);
+ g_debug("%s: loading message catalog '%s'\n", __FUNCTION__, localPath);
RELEASE_FILENAME_LOCAL(localPath);
if (err != NULL) {
if (lang == NULL || *lang == '\0') {
usrlang = MsgGetUserLanguage();
lang = usrlang;
+ } else {
+ usrlang = g_strdup(lang);
}
/*
file = g_strdup_printf("%s%smessages%s%s%s%s.vmsg",
catdir, DIRSEPS, DIRSEPS, lang, DIRSEPS, domain);
+ /*
+ * If we couldn't find the catalog file for the user's language, see if
+ * there's an encoding to chop off first, eg zh_CN.UTF-8
+ */
if (!g_file_test(file, G_FILE_TEST_IS_REGULAR)) {
- /*
- * If we couldn't find the catalog file for the user's language, see if
- * we can find a more generic language (e.g., for "en_US", also try "en").
- */
- char *sep = strrchr(lang, '_');
+ const char *sep = strrchr(lang, '.');
+ if (sep != NULL) {
+ usrlang[sep - lang] = '\0';
+ g_free(file);
+ file = g_strdup_printf("%s%smessages%s%s%s%s.vmsg",
+ catdir, DIRSEPS, DIRSEPS, usrlang, DIRSEPS, domain);
+ }
+ }
+
+ /*
+ * If we couldn't find the catalog file for the user's language, see if
+ * we can find a more generic language (e.g., for "en_US", also try "en").
+ */
+ if (!g_file_test(file, G_FILE_TEST_IS_REGULAR)) {
+ const char *sep = strrchr(lang, '_');
if (sep != NULL) {
- if (usrlang == NULL) {
- usrlang = g_strdup(lang);
- }
usrlang[sep - lang] = '\0';
g_free(file);
file = g_strdup_printf("%s%smessages%s%s%s%s.vmsg",
/*********************************************************
- * Copyright (C) 2011-2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2011-2018 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
#define VGAUTH_PREF_DEFAULT_SSPI_HANDSHAKE_TTL (10 * 60)
+/*
+ * Parent directory of 'messages', which has <lang>/<app>.vmsg
+ * below that.
+ */
+#ifdef _WIN32
#define VGAUTH_PREF_DEFAULT_LOCALIZATION_CATALOG "."
+#else
+#define VGAUTH_PREF_DEFAULT_LOCALIZATION_CATALOG "/etc/vmware-tools"
+#endif
#define VGAUTH_PREF_DEFAULT_MAX_DATA_CONNECTIONS_PER_USER 5
/*********************************************************
- * Copyright (C) 2011-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2011-2018 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
* Entry point for the GuestAuth service.
*/
+#include <locale.h>
#include "serviceInt.h"
#include "service.h"
#ifdef _WIN32
VGAUTH_PREF_GROUP_NAME_LOCALIZATION,
VGAUTH_PREF_DEFAULT_LOCALIZATION_CATALOG);
+ setlocale(LC_ALL, "");
I18n_BindTextDomain(VMW_TEXT_DOMAIN, NULL, msgCatalog);
g_free(msgCatalog);