File mozilla-language.patch of Package seamonkey

# HG changeset patch
# User Wolfgang Rosenauer <wr@rosenauer.org>
# Parent 5a29924228527f8882c83cf62d470963ea1ce62e
# Parent  4f39ed617c2f151a3a15903c7ae4471b66774e9e
Bug 583793 - Firefox interface language set to LANG, ignores LANGUAGE

diff -ruN seamonkey/mozilla/intl/locale/nsLocaleService.cpp seamonkey.new/mozilla/intl/locale/nsLocaleService.cpp
--- seamonkey/mozilla/intl/locale/nsLocaleService.cpp	2020-02-18 00:37:52.000000000 +0100
+++ seamonkey.new/mozilla/intl/locale/nsLocaleService.cpp	2020-03-02 12:50:24.804429601 +0100
@@ -121,6 +121,7 @@
 
     // Get system configuration
     const char* lang = getenv("LANG");
+    const char* language = getenv("LANGUAGE");
 
     nsAutoString xpLocale, platformLocale;
     nsAutoString category, category_platform;
@@ -156,6 +157,26 @@
         if (NS_FAILED(result)) {
             return;
         }
+        // LANGUAGE is overriding LC_MESSAGES
+        // it can be a colon separated list of preferred languages
+        // as we do not recognize here if a language is available
+        // we actually only consider the first entry unless GetXPLocale
+        // fails completely
+        if (i == LC_MESSAGES && language && *language) {
+#define LANGUAGE_SEP ":"
+          nsAutoString xpLocale_temp;
+          char* rawBuffer = (char*) language;
+          char* token = nsCRT::strtok(rawBuffer, LANGUAGE_SEP, &rawBuffer);
+          for (; token;
+              token = nsCRT::strtok(rawBuffer, LANGUAGE_SEP, &rawBuffer)) {
+            result = nsPosixLocale::GetXPLocale(token, xpLocale_temp);
+            if (NS_SUCCEEDED(result)) {
+              CopyASCIItoUTF16(token, platformLocale);
+              xpLocale = xpLocale_temp;
+              break;
+            }
+          }
+        }
         resultLocale->AddCategory(category, xpLocale);
         resultLocale->AddCategory(category_platform, platformLocale);
     }
openSUSE Build Service is sponsored by