mozilla-locale.patch
author Wolfgang Rosenauer <wr@rosenauer.org>
Thu, 26 Aug 2010 07:41:34 +0200
branchmozilla-1.9.2
changeset 143 e110d182e5ee
parent 122 4270a8c31485
child 184 e398c79b1668
permissions -rw-r--r--
update to 1.9.29/3.6.9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
122
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     1
# HG changeset patch
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     2
# User Wolfgang Rosenauer <wr@rosenauer.org>
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     3
# Parent a93100d87cc9841c6e3e4b29a47bb7b91f23415f
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     4
Bug 583793 - Firefox interface language set to LANG, ignores LANGUAGE
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     5
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     6
diff --git a/intl/locale/src/nsLocaleService.cpp b/intl/locale/src/nsLocaleService.cpp
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     7
--- a/intl/locale/src/nsLocaleService.cpp
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     8
+++ b/intl/locale/src/nsLocaleService.cpp
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     9
@@ -55,16 +55,19 @@
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    10
 #  include "nsIOS2Locale.h"
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    11
 #elif defined(XP_MACOSX)
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    12
 #  include <Carbon/Carbon.h>
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    13
 #  include "nsIMacLocale.h"
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    14
 #elif defined(XP_UNIX) || defined(XP_BEOS)
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    15
 #  include <locale.h>
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    16
 #  include <stdlib.h>
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    17
 #  include "nsIPosixLocale.h"
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    18
+#if (MOZ_PLATFORM_MAEMO >= 6)
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    19
+#  include "nsIGConfService.h"
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    20
+#endif
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    21
 #endif
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    22
 
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    23
 //
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    24
 // implementation constants
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    25
 const int LocaleListLength = 6;
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    26
 const char* LocaleList[LocaleListLength] = 
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    27
 {
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    28
 	NSILOCALE_COLLATE,
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    29
@@ -169,39 +172,66 @@ nsLocaleService::nsLocaleService(void)
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    30
         nsAutoString category, category_platform;
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    31
         nsLocale* resultLocale;
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    32
         int i;
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    33
 
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    34
         resultLocale = new nsLocale();
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    35
         if ( resultLocale == NULL ) { 
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    36
             return; 
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    37
         }
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    38
+
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    39
+        // Get system configuration
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    40
+        char* language = getenv("LANGUAGE");
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    41
+        char* lang = getenv("LANG");
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    42
+#if (MOZ_PLATFORM_MAEMO >= 6)
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    43
+        // GConf key is treated as LANG _and_ LANGUAGE
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    44
+        nsCAutoString gconfLocaleString;
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    45
+        nsresult rv;
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    46
+        nsCOMPtr<nsIGConfService> gconf =
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    47
+            do_GetService(NS_GCONFSERVICE_CONTRACTID, &rv);
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    48
+        if (NS_SUCCEEDED(rv)) {
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    49
+            rv = gconf->GetString(NS_LITERAL_CSTRING("/meegotouch/i18n/language"),
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    50
+                                  gconfLocaleString);
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    51
+            if (NS_SUCCEEDED(rv) && !gconfLocaleString.IsEmpty()) {
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    52
+                lang = gconfLocaleString.get();
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    53
+                language = gconfLocaleString.get();
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    54
+                // For setlocale() doing the right thing we need to export
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    55
+                // this as LANG to the environment
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    56
+                setenv("LANG", lang, 1);
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    57
+            }
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    58
+        }
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    59
+#endif
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    60
         for( i = 0; i < LocaleListLength; i++ ) {
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    61
             nsresult result;
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    62
+            // setlocale( , "") evaluates LC_* and LANG
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    63
             char* lc_temp = setlocale(posix_locale_category[i], "");
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    64
             CopyASCIItoUTF16(LocaleList[i], category);
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    65
-            category_platform = category; 
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    66
+            category_platform = category;
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    67
             category_platform.AppendLiteral("##PLATFORM");
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    68
             if (lc_temp != nsnull) {
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    69
                 result = posixConverter->GetXPLocale(lc_temp, xpLocale);
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    70
                 CopyASCIItoUTF16(lc_temp, platformLocale);
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    71
             } else {
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    72
-                char* lang = getenv("LANG");
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    73
                 if ( lang == nsnull ) {
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    74
                     platformLocale.AssignLiteral("en_US");
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    75
                     result = posixConverter->GetXPLocale("en-US", xpLocale);
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    76
                 }
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    77
                 else {
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    78
                     CopyASCIItoUTF16(lang, platformLocale);
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    79
-                    result = posixConverter->GetXPLocale(lang, xpLocale); 
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    80
+                    result = posixConverter->GetXPLocale(lang, xpLocale);
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    81
                 }
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    82
             }
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    83
             if (NS_FAILED(result)) {
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    84
                 return;
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    85
             }
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    86
+            // LANGUAGE is overriding LC_MESSAGES
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    87
+            if (i == LC_MESSAGES && language) {
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    88
+                CopyASCIItoUTF16(language, platformLocale);
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    89
+                result = posixConverter->GetXPLocale(language, xpLocale);
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    90
+            }
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    91
             resultLocale->AddCategory(category, xpLocale);
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    92
             resultLocale->AddCategory(category_platform, platformLocale);
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    93
         }
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    94
         mSystemLocale = do_QueryInterface(resultLocale);
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    95
         mApplicationLocale = do_QueryInterface(resultLocale);
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    96
     }  // if ( NS_SUCCEEDED )...
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    97
        
4270a8c31485 honor LANGUAGE environment variable for UI locale (bmo#583793)
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    98
 #endif // XP_UNIX || XP_BEOS