Skip to content
Snippets Groups Projects
Verified Commit 022f6236 authored by Alex Catarineu's avatar Alex Catarineu Committed by Pier Angelo Vendrame
Browse files

Bug 40199: Avoid using system locale for intl.accept_languages in GeckoView

parent 119a9697
1 merge request!641Bug 41759: Rebase Base Browser to 115 Nightly
...@@ -22,7 +22,7 @@ import androidx.annotation.NonNull; ...@@ -22,7 +22,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.util.LinkedHashMap; import java.util.ArrayList;
import java.util.Locale; import java.util.Locale;
import org.mozilla.gecko.EventDispatcher; import org.mozilla.gecko.EventDispatcher;
import org.mozilla.gecko.GeckoSystemStateListener; import org.mozilla.gecko.GeckoSystemStateListener;
...@@ -790,23 +790,29 @@ public final class GeckoRuntimeSettings extends RuntimeSettings { ...@@ -790,23 +790,29 @@ public final class GeckoRuntimeSettings extends RuntimeSettings {
} }
private String computeAcceptLanguages() { private String computeAcceptLanguages() {
final LinkedHashMap<String, String> locales = new LinkedHashMap<>(); final ArrayList<String> locales = new ArrayList<String>();
// Explicitly-set app prefs come first: // In Desktop, these are defined in the `intl.accept_languages` localized property.
if (mRequestedLocales != null) { // At some point we should probably use the same values here, but for now we use a simple
for (final String locale : mRequestedLocales) { // strategy which will hopefully result in reasonable acceptLanguage values.
locales.put(locale.toLowerCase(Locale.ROOT), locale); if (mRequestedLocales != null && mRequestedLocales.length > 0) {
} String locale = mRequestedLocales[0].toLowerCase(Locale.ROOT);
} // No need to include `en-us` twice.
// OS prefs come second: if (!locale.equals("en-us")) {
for (final String locale : getDefaultLocales()) { locales.add(locale);
final String localeLowerCase = locale.toLowerCase(Locale.ROOT); if (locale.contains("-")) {
if (!locales.containsKey(localeLowerCase)) { String lang = locale.split("-")[0];
locales.put(localeLowerCase, locale); // No need to include `en` twice.
if (!lang.equals("en")) {
locales.add(lang);
}
}
} }
} }
locales.add("en-us");
locales.add("en");
return TextUtils.join(",", locales.values()); return TextUtils.join(",", locales);
} }
private static String[] getDefaultLocales() { private static String[] getDefaultLocales() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment