1 # HG changeset patch |
1 # HG changeset patch |
2 # User Wolfgang Rosenauer <wr@rosenauer.org> |
2 # User Wolfgang Rosenauer <wr@rosenauer.org> |
3 # Parent a93100d87cc9841c6e3e4b29a47bb7b91f23415f |
3 # Parent e069ee20084757311e0826e68d5a1fbeb3dcc29f |
4 Bug 583793 - Firefox interface language set to LANG, ignores LANGUAGE |
4 Bug 583793 - Firefox interface language set to LANG, ignores LANGUAGE |
5 |
5 |
6 diff --git a/intl/locale/src/nsLocaleService.cpp b/intl/locale/src/nsLocaleService.cpp |
6 diff --git a/intl/locale/src/nsLocaleService.cpp b/intl/locale/src/nsLocaleService.cpp |
7 --- a/intl/locale/src/nsLocaleService.cpp |
7 --- a/intl/locale/src/nsLocaleService.cpp |
8 +++ b/intl/locale/src/nsLocaleService.cpp |
8 +++ b/intl/locale/src/nsLocaleService.cpp |
9 @@ -55,16 +55,19 @@ |
9 @@ -169,39 +169,48 @@ nsLocaleService::nsLocaleService(void) |
10 # include "nsIOS2Locale.h" |
|
11 #elif defined(XP_MACOSX) |
|
12 # include <Carbon/Carbon.h> |
|
13 # include "nsIMacLocale.h" |
|
14 #elif defined(XP_UNIX) || defined(XP_BEOS) |
|
15 # include <locale.h> |
|
16 # include <stdlib.h> |
|
17 # include "nsIPosixLocale.h" |
|
18 +#if (MOZ_PLATFORM_MAEMO >= 6) |
|
19 +# include "nsIGConfService.h" |
|
20 +#endif |
|
21 #endif |
|
22 |
|
23 // |
|
24 // implementation constants |
|
25 const int LocaleListLength = 6; |
|
26 const char* LocaleList[LocaleListLength] = |
|
27 { |
|
28 NSILOCALE_COLLATE, |
|
29 @@ -169,39 +172,66 @@ nsLocaleService::nsLocaleService(void) |
|
30 nsAutoString category, category_platform; |
10 nsAutoString category, category_platform; |
31 nsLocale* resultLocale; |
11 nsLocale* resultLocale; |
32 int i; |
12 int i; |
33 |
13 |
34 resultLocale = new nsLocale(); |
14 resultLocale = new nsLocale(); |
37 } |
17 } |
38 + |
18 + |
39 + // Get system configuration |
19 + // Get system configuration |
40 + char* language = getenv("LANGUAGE"); |
20 + char* language = getenv("LANGUAGE"); |
41 + char* lang = getenv("LANG"); |
21 + char* lang = getenv("LANG"); |
42 +#if (MOZ_PLATFORM_MAEMO >= 6) |
|
43 + // GConf key is treated as LANG _and_ LANGUAGE |
|
44 + nsCAutoString gconfLocaleString; |
|
45 + nsresult rv; |
|
46 + nsCOMPtr<nsIGConfService> gconf = |
|
47 + do_GetService(NS_GCONFSERVICE_CONTRACTID, &rv); |
|
48 + if (NS_SUCCEEDED(rv)) { |
|
49 + rv = gconf->GetString(NS_LITERAL_CSTRING("/meegotouch/i18n/language"), |
|
50 + gconfLocaleString); |
|
51 + if (NS_SUCCEEDED(rv) && !gconfLocaleString.IsEmpty()) { |
|
52 + lang = gconfLocaleString.get(); |
|
53 + language = gconfLocaleString.get(); |
|
54 + // For setlocale() doing the right thing we need to export |
|
55 + // this as LANG to the environment |
|
56 + setenv("LANG", lang, 1); |
|
57 + } |
|
58 + } |
|
59 +#endif |
|
60 for( i = 0; i < LocaleListLength; i++ ) { |
22 for( i = 0; i < LocaleListLength; i++ ) { |
61 nsresult result; |
23 nsresult result; |
62 + // setlocale( , "") evaluates LC_* and LANG |
24 + // setlocale( , "") evaluates LC_* and LANG |
63 char* lc_temp = setlocale(posix_locale_category[i], ""); |
25 char* lc_temp = setlocale(posix_locale_category[i], ""); |
64 CopyASCIItoUTF16(LocaleList[i], category); |
26 CopyASCIItoUTF16(LocaleList[i], category); |
82 } |
44 } |
83 if (NS_FAILED(result)) { |
45 if (NS_FAILED(result)) { |
84 return; |
46 return; |
85 } |
47 } |
86 + // LANGUAGE is overriding LC_MESSAGES |
48 + // LANGUAGE is overriding LC_MESSAGES |
87 + if (i == LC_MESSAGES && language) { |
49 + if (i == LC_MESSAGES && language && *language) { |
88 + CopyASCIItoUTF16(language, platformLocale); |
50 + CopyASCIItoUTF16(language, platformLocale); |
89 + result = posixConverter->GetXPLocale(language, xpLocale); |
51 + result = posixConverter->GetXPLocale(language, xpLocale); |
90 + } |
52 + } |
91 resultLocale->AddCategory(category, xpLocale); |
53 resultLocale->AddCategory(category, xpLocale); |
92 resultLocale->AddCategory(category_platform, platformLocale); |
54 resultLocale->AddCategory(category_platform, platformLocale); |