]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Change to common source files not applicable to open-vm-tools.
authorKruti Pendharkar <kp025370@broadcom.com>
Fri, 17 Oct 2025 04:25:49 +0000 (21:25 -0700)
committerKruti Pendharkar <kp025370@broadcom.com>
Fri, 17 Oct 2025 04:25:49 +0000 (21:25 -0700)
open-vm-tools/libvmtools/i18n.c
open-vm-tools/vgauth/common/i18n.c

index 3085f72d7a937e64815345309d61f0088486aeb7..bbed57ed40b2736cce7e65f9324c594478873fb4 100644 (file)
@@ -1,5 +1,6 @@
 /*********************************************************
- * Copyright (C) 2010-2020 VMware, Inc. All rights reserved.
+ * Copyright (c) 2010-2025 Broadcom. All Rights Reserved.
+ * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
  *
  * 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
@@ -216,12 +217,22 @@ MsgGetUserLanguage(void)
     * Windows implementation. Derive the ISO names from the user's current
     * locale.
     */
+   LCID locale;
+   DWORD sessionId = 0;
    wchar_t ctryName[10]; /* MSDN says: max is nine characters + terminator. */
    wchar_t langName[10]; /* MSDN says: max is nine characters + terminator. */
 
-   if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME,
+   if (ProcessIdToSessionId(GetCurrentProcessId(), &sessionId) && sessionId == 0) {
+      locale = LOCALE_SYSTEM_DEFAULT;
+      g_debug("%s: get SYSTEM default locale.\n", __FUNCTION__);
+   } else {
+      locale = LOCALE_USER_DEFAULT;
+      g_debug("%s: get USER default locale.\n", __FUNCTION__);
+   }
+
+   if (GetLocaleInfo(locale, LOCALE_SISO3166CTRYNAME,
                      ctryName, ARRAYSIZE(ctryName)) == 0 ||
-       GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME,
+       GetLocaleInfo(locale, LOCALE_SISO639LANGNAME,
                      langName, ARRAYSIZE(langName)) == 0) {
       g_warning("Couldn't retrieve user locale data, error = %u.", GetLastError());
       lang = g_strdup("C");
@@ -675,7 +686,7 @@ VMTools_BindTextDomain(const char *domain,
       lang = usrlang;
    }
 
-   g_debug("%s: user locale=%s\n", __FUNCTION__, lang);
+   g_debug("%s: using locale=%s\n", __FUNCTION__, lang);
 
    /*
     * Use the default install directory if none is provided.
index 6d1292d62e68283b799f793dfc447c6ae31ba0df..59ee3858cbe8832a95f0ae25de4ffc8b21b346be 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (c) 2011-2019,2024 Broadcom. All Rights Reserved.
+ * Copyright (c) 2010-2025 Broadcom. All Rights Reserved.
  * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -448,12 +448,22 @@ MsgGetUserLanguage(void)
     * Windows implementation. Derive the ISO names from the user's current
     * locale.
     */
+   LCID locale;
+   DWORD sessionId = 0;
    wchar_t ctryName[10]; /* MSDN says: max is nine characters + terminator. */
    wchar_t langName[10]; /* MSDN says: max is nine characters + terminator. */
 
-   if (GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME,
+   if (ProcessIdToSessionId(GetCurrentProcessId(), &sessionId) && sessionId == 0) {
+      locale = LOCALE_SYSTEM_DEFAULT;
+      g_debug("%s: get SYSTEM default locale.\n", __FUNCTION__);
+   } else {
+      locale = LOCALE_USER_DEFAULT;
+      g_debug("%s: get USER default locale.\n", __FUNCTION__);
+   }
+
+   if (GetLocaleInfoW(locale, LOCALE_SISO3166CTRYNAME,
                       ctryName, (sizeof(ctryName)/sizeof(langName[0]))) == 0 ||
-       GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME,
+       GetLocaleInfoW(locale, LOCALE_SISO639LANGNAME,
                       langName, (sizeof(langName)/sizeof(langName[0]))) == 0) {
       g_warning("Couldn't retrieve user locale data, error = %u.", GetLastError());
       lang = g_strdup("C");
@@ -709,7 +719,7 @@ I18n_BindTextDomain(const char *domain,
     * to the installed location.
     */
 
-   g_debug("%s: user locale=%s\n", __FUNCTION__, lang);
+   g_debug("%s: using locale=%s\n", __FUNCTION__, lang);
 
    file = g_strdup_printf("%s%smessages%s%s%s%s.vmsg",
                           catdir, DIRSEPS, DIRSEPS, lang, DIRSEPS, domain);