2011-06-28 20:42:13 +02:00
|
|
|
# HG changeset patch
|
|
|
|
# User Wolfgang Rosenauer <wr@rosenauer.org>
|
2015-06-21 13:26:59 +02:00
|
|
|
# Parent 5a29924228527f8882c83cf62d470963ea1ce62e
|
2017-03-18 22:27:55 +01:00
|
|
|
# Parent 4f39ed617c2f151a3a15903c7ae4471b66774e9e
|
2011-06-28 20:42:13 +02:00
|
|
|
Bug 583793 - Firefox interface language set to LANG, ignores LANGUAGE
|
|
|
|
|
2015-06-21 13:26:59 +02:00
|
|
|
diff --git a/intl/locale/nsLocaleService.cpp b/intl/locale/nsLocaleService.cpp
|
|
|
|
--- a/intl/locale/nsLocaleService.cpp
|
|
|
|
+++ b/intl/locale/nsLocaleService.cpp
|
2017-03-18 22:27:55 +01:00
|
|
|
@@ -114,16 +114,17 @@ nsLocaleService::nsLocaleService(void)
|
|
|
|
NS_ENSURE_SUCCESS_VOID(rv);
|
|
|
|
#endif
|
|
|
|
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
2016-04-30 15:53:52 +02:00
|
|
|
RefPtr<nsLocale> resultLocale(new nsLocale());
|
2013-09-16 11:26:56 +02:00
|
|
|
NS_ENSURE_TRUE_VOID(resultLocale);
|
2011-06-28 20:42:13 +02:00
|
|
|
|
2011-09-26 15:57:38 +02:00
|
|
|
// Get system configuration
|
|
|
|
const char* lang = getenv("LANG");
|
|
|
|
+ const char* language = getenv("LANGUAGE");
|
2011-06-28 20:42:13 +02:00
|
|
|
|
2011-09-26 15:57:38 +02:00
|
|
|
nsAutoString xpLocale, platformLocale;
|
|
|
|
nsAutoString category, category_platform;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for( i = 0; i < LocaleListLength; i++ ) {
|
|
|
|
nsresult result;
|
2017-03-18 22:27:55 +01:00
|
|
|
// setlocale( , "") evaluates LC_* and LANG
|
|
|
|
@@ -149,16 +150,36 @@ nsLocaleService::nsLocaleService(void)
|
2011-09-26 15:57:38 +02:00
|
|
|
} else {
|
|
|
|
CopyASCIItoUTF16(lang, platformLocale);
|
|
|
|
result = nsPosixLocale::GetXPLocale(lang, xpLocale);
|
2011-06-28 20:42:13 +02:00
|
|
|
}
|
|
|
|
}
|
2011-09-26 15:57:38 +02:00
|
|
|
if (NS_FAILED(result)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
+ // LANGUAGE is overriding LC_MESSAGES
|
2017-03-18 22:27:55 +01:00
|
|
|
+ // 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
|
2011-09-26 15:57:38 +02:00
|
|
|
+ if (i == LC_MESSAGES && language && *language) {
|
2017-03-18 22:27:55 +01:00
|
|
|
+#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;
|
|
|
|
+ }
|
|
|
|
+ }
|
2011-09-26 15:57:38 +02:00
|
|
|
+ }
|
|
|
|
resultLocale->AddCategory(category, xpLocale);
|
|
|
|
resultLocale->AddCategory(category_platform, platformLocale);
|
|
|
|
}
|
|
|
|
mSystemLocale = do_QueryInterface(resultLocale);
|
|
|
|
mApplicationLocale = do_QueryInterface(resultLocale);
|
2011-06-28 20:42:13 +02:00
|
|
|
|
|
|
|
#endif // XP_UNIX
|
2014-07-28 15:29:31 +02:00
|
|
|
|