1 # HG changeset patch |
|
2 # User Wolfgang Rosenauer <wr@rosenauer.org> |
|
3 # Parent 5a29924228527f8882c83cf62d470963ea1ce62e |
|
4 # Parent 242f2521ed48bb63b91582956b5e4af80bcb3378 |
|
5 Bug 583793 - Firefox interface language set to LANG, ignores LANGUAGE |
|
6 |
|
7 diff --git a/intl/locale/nsLocaleService.cpp b/intl/locale/nsLocaleService.cpp |
|
8 --- a/intl/locale/nsLocaleService.cpp |
|
9 +++ b/intl/locale/nsLocaleService.cpp |
|
10 @@ -116,16 +116,17 @@ nsLocaleService::nsLocaleService(void) |
|
11 NS_ENSURE_SUCCESS_VOID(rv); |
|
12 #endif |
|
13 #if defined(XP_UNIX) && !defined(XP_MACOSX) |
|
14 RefPtr<nsLocale> resultLocale(new nsLocale()); |
|
15 NS_ENSURE_TRUE_VOID(resultLocale); |
|
16 |
|
17 // Get system configuration |
|
18 const char* lang = getenv("LANG"); |
|
19 + const char* language = getenv("LANGUAGE"); |
|
20 |
|
21 nsAutoString xpLocale, platformLocale; |
|
22 nsAutoString category, category_platform; |
|
23 int i; |
|
24 |
|
25 for( i = 0; i < LocaleListLength; i++ ) { |
|
26 nsresult result; |
|
27 // setlocale( , "") evaluates LC_* and LANG |
|
28 @@ -151,16 +152,37 @@ nsLocaleService::nsLocaleService(void) |
|
29 } else { |
|
30 CopyASCIItoUTF16(lang, platformLocale); |
|
31 result = nsPosixLocale::GetXPLocale(lang, xpLocale); |
|
32 } |
|
33 } |
|
34 if (NS_FAILED(result)) { |
|
35 return; |
|
36 } |
|
37 + // LANGUAGE is overriding LC_MESSAGES |
|
38 + // it can be a colon separated list of preferred languages |
|
39 + // as we do not recognize here if a language is available |
|
40 + // we actually only consider the first entry unless GetXPLocale |
|
41 + // fails completely |
|
42 + if (i == LC_MESSAGES && language && *language) { |
|
43 +#define LANGUAGE_SEP ":" |
|
44 + nsAutoString xpLocale_temp; |
|
45 + char* rawBuffer = (char*) language; |
|
46 + char* token = nsCRT::strtok(rawBuffer, LANGUAGE_SEP, &rawBuffer); |
|
47 + for (; token; |
|
48 + token = nsCRT::strtok(rawBuffer, LANGUAGE_SEP, &rawBuffer)) { |
|
49 + result = nsPosixLocale::GetXPLocale(token, xpLocale_temp); |
|
50 + if (NS_SUCCEEDED(result)) { |
|
51 + CopyASCIItoUTF16(token, platformLocale); |
|
52 + xpLocale = xpLocale_temp; |
|
53 + break; |
|
54 + } |
|
55 + } |
|
56 + } |
|
57 + |
|
58 resultLocale->AddCategory(category, xpLocale); |
|
59 resultLocale->AddCategory(category_platform, platformLocale); |
|
60 } |
|
61 mSystemLocale = do_QueryInterface(resultLocale); |
|
62 mApplicationLocale = do_QueryInterface(resultLocale); |
|
63 |
|
64 #endif // XP_UNIX |
|
65 |
|