Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Applications
Tor Browser
Commits
45bb9d2e
Commit
45bb9d2e
authored
Oct 20, 2020
by
Alex Catarineu
Committed by
Matthew Finkel
May 04, 2021
Browse files
Bug 40199: Avoid using system locale for intl.accept_languages in GeckoView
parent
189133d8
Changes
1
Hide whitespace changes
Inline
Side-by-side
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java
View file @
45bb9d2e
...
...
@@ -778,19 +778,25 @@ public final class GeckoRuntimeSettings extends RuntimeSettings {
private
String
computeAcceptLanguages
()
{
final
ArrayList
<
String
>
locales
=
new
ArrayList
<
String
>();
// Explicitly-set app prefs come first:
if
(
mRequestedLocales
!=
null
)
{
for
(
final
String
locale
:
mRequestedLocales
)
{
locales
.
add
(
locale
.
toLowerCase
(
Locale
.
ROOT
));
}
}
// OS prefs come second:
for
(
final
String
locale
:
getDefaultLocales
())
{
final
String
localeLowerCase
=
locale
.
toLowerCase
(
Locale
.
ROOT
);
if
(!
locales
.
contains
(
localeLowerCase
))
{
locales
.
add
(
localeLowerCase
);
// In Desktop, these are defined in the `intl.accept_languages` localized property.
// At some point we should probably use the same values here, but for now we use a simple
// strategy which will hopefully result in reasonable acceptLanguage values.
if
(
mRequestedLocales
!=
null
&&
mRequestedLocales
.
length
>
0
)
{
String
locale
=
mRequestedLocales
[
0
].
toLowerCase
(
Locale
.
ROOT
);
// No need to include `en-us` twice.
if
(!
locale
.
equals
(
"en-us"
))
{
locales
.
add
(
locale
);
if
(
locale
.
contains
(
"-"
))
{
String
lang
=
locale
.
split
(
"-"
)[
0
];
// No need to include `en` twice.
if
(!
lang
.
equals
(
"en"
))
{
locales
.
add
(
lang
);
}
}
}
}
locales
.
add
(
"en-us"
);
locales
.
add
(
"en"
);
return
TextUtils
.
join
(
","
,
locales
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment