mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 01:05:45 +00:00
Bug 1575555 - Support multiple locales in modern config r=Standard8
Differential Revision: https://phabricator.services.mozilla.com/D45541 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
4e6807391a
commit
e821ea6bdc
@ -101,7 +101,7 @@
|
||||
},
|
||||
"webExtensionId": "amazon@search.mozilla.org",
|
||||
"webExtensionVersion": "1.1",
|
||||
"webExtensionLocale": "au",
|
||||
"webExtensionLocales": ["au"],
|
||||
"engineName": "Amazon.com.au"
|
||||
}, {
|
||||
"included": {
|
||||
@ -117,7 +117,7 @@
|
||||
},
|
||||
"webExtensionId": "amazon@search.mozilla.org",
|
||||
"webExtensionVersion": "1.1",
|
||||
"webExtensionLocale": "ca",
|
||||
"webExtensionLocales": ["ca"],
|
||||
"engineName": "Amazon.ca"
|
||||
}, {
|
||||
"included": {
|
||||
@ -133,7 +133,7 @@
|
||||
},
|
||||
"webExtensionId": "amazon@search.mozilla.org",
|
||||
"webExtensionVersion": "1.1",
|
||||
"webExtensionLocale": "france",
|
||||
"webExtensionLocales": ["france"],
|
||||
"engineName": "Amazon.fr"
|
||||
}, {
|
||||
"included": {
|
||||
@ -149,7 +149,7 @@
|
||||
},
|
||||
"webExtensionId": "amazon@search.mozilla.org",
|
||||
"webExtensionVersion": "1.1",
|
||||
"webExtensionLocale": "en-GB",
|
||||
"webExtensionLocales": ["en-GB"],
|
||||
"engineName": "Amazon.co.uk"
|
||||
}],
|
||||
"aliases": ["amazon"]
|
||||
@ -166,36 +166,36 @@
|
||||
"or", "pa-IN", "ta", "te", "ur"
|
||||
]}
|
||||
},
|
||||
"webExtensionLocale": "in",
|
||||
"webExtensionLocales": ["in"],
|
||||
"engineName": "Amazon.in"
|
||||
}, {
|
||||
"included": {
|
||||
"locales": { "matches": ["br", "ff", "fr", "son", "wo"] }
|
||||
},
|
||||
"webExtensionLocale": "france",
|
||||
"webExtensionLocales": ["france"],
|
||||
"engineName": "Amazon.fr"
|
||||
}, {
|
||||
"included": {
|
||||
"regions": ["ca"],
|
||||
"locales": { "matches": ["br", "ff", "fr", "son", "wo"] }
|
||||
},
|
||||
"webExtensionLocale": "ca",
|
||||
"webExtensionLocales": ["ca"],
|
||||
"engineName": "Amazon.ca"
|
||||
}, {
|
||||
"included": { "locales": { "matches": ["en-CA"] } },
|
||||
"webExtensionLocale": "ca",
|
||||
"webExtensionLocales": ["ca"],
|
||||
"engineName": "Amazon.ca"
|
||||
}, {
|
||||
"included": { "locales": { "matches": ["ja-JP-mac", "ja"] } },
|
||||
"webExtensionLocale": "jp",
|
||||
"webExtensionLocales": ["jp"],
|
||||
"engineName": "Amazon.jp"
|
||||
}, {
|
||||
"included": { "locales": { "matches": ["it", "lij"] } },
|
||||
"webExtensionLocale": "it",
|
||||
"webExtensionLocales": ["it"],
|
||||
"engineName": "Amazon.it"
|
||||
}, {
|
||||
"included": { "locales": { "matches": ["de", "dsb", "hsb"] } },
|
||||
"webExtensionLocale": "de",
|
||||
"webExtensionLocales": ["de"],
|
||||
"engineName": "Amazon.de"
|
||||
}, {
|
||||
"included": {
|
||||
@ -206,7 +206,7 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"webExtensionLocale": "en-GB",
|
||||
"webExtensionLocales": ["en-GB"],
|
||||
"engineName": "Amazon.co.uk"
|
||||
}, {
|
||||
"included": {
|
||||
@ -218,7 +218,7 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"webExtensionLocale": "au",
|
||||
"webExtensionLocales": ["au"],
|
||||
"engineName": "Amazon.au"
|
||||
}],
|
||||
"aliases": ["amazon"]
|
||||
@ -246,96 +246,96 @@
|
||||
"locales": { "matches": ["en-US"] },
|
||||
"regions": ["au"]
|
||||
},
|
||||
"webExtensionLocale": "au"
|
||||
"webExtensionLocales": ["au"]
|
||||
}, {
|
||||
"included": {
|
||||
"locales": { "matches": ["en-US"] },
|
||||
"regions": ["ie"]
|
||||
},
|
||||
"webExtensionLocale": "ie"
|
||||
"webExtensionLocales": ["ie"]
|
||||
}, {
|
||||
"included": {
|
||||
"locales": { "matches": ["en-US"] },
|
||||
"regions": ["be"]
|
||||
},
|
||||
"webExtensionLocale": "be"
|
||||
"webExtensionLocales": ["be"]
|
||||
}, {
|
||||
"included": { "locales": {
|
||||
"matches": ["an", "ast", "ca", "es-ES", "eu", "gl"]
|
||||
}},
|
||||
"webExtensionLocale": "es"
|
||||
"webExtensionLocales": ["es"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": ["br", "fr", "wo"] }},
|
||||
"webExtensionLocale": "fr"
|
||||
"webExtensionLocales": ["fr"]
|
||||
}, {
|
||||
"included": {
|
||||
"locales": { "matches": ["br", "fr", "wo"] },
|
||||
"regions": ["be"]
|
||||
},
|
||||
"webExtensionLocale": "be"
|
||||
"webExtensionLocales": ["be"]
|
||||
}, {
|
||||
"included": {
|
||||
"locales": { "matches": ["br", "fr", "wo"] },
|
||||
"regions": ["ca"]
|
||||
},
|
||||
"webExtensionLocale": "ca"
|
||||
"webExtensionLocales": ["ca"]
|
||||
}, {
|
||||
"included": {
|
||||
"locales": { "matches": ["br", "fr", "wo"] },
|
||||
"regions": ["ch"]
|
||||
},
|
||||
"webExtensionLocale": "ch"
|
||||
"webExtensionLocales": ["ch"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": ["cy", "en-GB", "gd"] }},
|
||||
"webExtensionLocale": "uk"
|
||||
"webExtensionLocales": ["uk"]
|
||||
}, {
|
||||
"included": {
|
||||
"locales": { "matches": ["cy", "en-GB", "gd"] },
|
||||
"regions": ["au"]
|
||||
},
|
||||
"webExtensionLocale": "au"
|
||||
"webExtensionLocales": ["au"]
|
||||
}, {
|
||||
"included": {
|
||||
"locales": { "matches": ["cy", "en-GB", "gd"] },
|
||||
"regions": ["ie"]
|
||||
},
|
||||
"webExtensionLocale": "ie"
|
||||
"webExtensionLocales": ["ie"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": ["de", "dsb", "hsb"] }},
|
||||
"webExtensionLocale": "de"
|
||||
"webExtensionLocales": ["de"]
|
||||
}, {
|
||||
"included": {
|
||||
"locales": { "matches": ["de", "dsb", "hsb"] },
|
||||
"regions": ["at"]
|
||||
},
|
||||
"webExtensionLocale": "at"
|
||||
"webExtensionLocales": ["at"]
|
||||
}, {
|
||||
"included": {
|
||||
"locales": { "matches": ["de", "dsb", "hsb"] },
|
||||
"regions": ["ch"]
|
||||
},
|
||||
"webExtensionLocale": "ch"
|
||||
"webExtensionLocales": ["ch"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": ["en-CA"] }},
|
||||
"webExtensionLocale": "ca"
|
||||
"webExtensionLocales": ["ca"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": ["fy-NL", "nl"] }},
|
||||
"webExtensionLocale": "nl"
|
||||
"webExtensionLocales": ["nl"]
|
||||
}, {
|
||||
"included": {
|
||||
"locales": { "matches": ["fy-NL", "nl"] },
|
||||
"regions": ["be"]
|
||||
},
|
||||
"webExtensionLocale": "be"
|
||||
"webExtensionLocales": ["be"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": ["ga-IE"] }},
|
||||
"webExtensionLocale": "ie"
|
||||
"webExtensionLocales": ["ie"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": ["it", "lij"] }},
|
||||
"webExtensionLocale": "it"
|
||||
"webExtensionLocales": ["it"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": ["rm"] }},
|
||||
"webExtensionLocale": "ch"
|
||||
"webExtensionLocales": ["ch"]
|
||||
}],
|
||||
"aliases": ["@ebay"]
|
||||
},
|
||||
@ -362,25 +362,25 @@
|
||||
"startsWith": ["en"]
|
||||
}
|
||||
},
|
||||
"webExtensionLocale": "en"
|
||||
"webExtensionLocales": ["en"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": ["az"] }},
|
||||
"webExtensionLocale": "az"
|
||||
"webExtensionLocales": ["az"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": ["be"] }},
|
||||
"webExtensionLocale": "by",
|
||||
"webExtensionLocales": ["by"],
|
||||
"engineName": "\u044F\u043D\u0434\u0435\u043A\u0441"
|
||||
}, {
|
||||
"included": { "locales": { "matches": ["kk"] }},
|
||||
"webExtensionLocale": "kk",
|
||||
"webExtensionLocales": ["kk"],
|
||||
"engineName": "\u044F\u043D\u0434\u0435\u043A\u0441"
|
||||
}, {
|
||||
"included": { "locales": { "matches": ["ru"] }},
|
||||
"webExtensionLocale": "ru",
|
||||
"webExtensionLocales": ["ru"],
|
||||
"engineName": "\u044F\u043D\u0434\u0435\u043A\u0441"
|
||||
}, {
|
||||
"included": { "locales": { "matches": ["tr"] }},
|
||||
"webExtensionLocale": "tr"
|
||||
"webExtensionLocales": ["tr"]
|
||||
}],
|
||||
"aliases": ["@\u044F\u043D\u0434\u0435\u043A\u0441", "@yandex"]
|
||||
},
|
||||
@ -434,10 +434,10 @@
|
||||
"webExtensionVersion": "1.0",
|
||||
"appliesTo": [{
|
||||
"included": { "locales": { "matches": ["fy-NL"]}},
|
||||
"webExtensionLocale": "fy-NL"
|
||||
"webExtensionLocales": ["fy-NL"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": ["nl"]}},
|
||||
"webExtensionLocale": "nl"
|
||||
"webExtensionLocales": ["nl"]
|
||||
}]
|
||||
},
|
||||
{
|
||||
@ -574,10 +574,10 @@
|
||||
"webExtensionVersion": "1.0",
|
||||
"appliesTo": [{
|
||||
"included": { "locales": { "matches": ["fy-NL"]}},
|
||||
"webExtensionLocale": "fy-NL"
|
||||
"webExtensionLocales": ["fy-NL"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": ["nl"]}},
|
||||
"webExtensionLocale": "nl"
|
||||
"webExtensionLocales": ["nl"]
|
||||
}]
|
||||
},
|
||||
{
|
||||
@ -586,13 +586,13 @@
|
||||
"webExtensionVersion": "1.0",
|
||||
"appliesTo": [{
|
||||
"included": { "locales": { "matches": ["es-AR"]}},
|
||||
"webExtensionLocale": "ar"
|
||||
"webExtensionLocales": ["ar"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": ["es-CL"]}},
|
||||
"webExtensionLocale": "cl"
|
||||
"webExtensionLocales": ["cl"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": ["es-MX"]}},
|
||||
"webExtensionLocale": "mx"
|
||||
"webExtensionLocales": ["mx"]
|
||||
}]
|
||||
},
|
||||
{
|
||||
@ -758,7 +758,7 @@
|
||||
]}}
|
||||
}, {
|
||||
"included": { "locales": { "matches": ["ja-JP-mac", "ja"]}},
|
||||
"webExtensionLocale": "ja"
|
||||
"webExtensionLocales": ["ja"]
|
||||
}]
|
||||
},
|
||||
{
|
||||
@ -779,10 +779,10 @@
|
||||
"webExtensionVersion": "1.0",
|
||||
"appliesTo": [{
|
||||
"included": { "locales": { "matches": ["te"]}},
|
||||
"webExtensionLocale": "te"
|
||||
"webExtensionLocales": ["te"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": ["oc"]}},
|
||||
"webExtensionLocale": "oc"
|
||||
"webExtensionLocales": ["oc"]
|
||||
}]
|
||||
},
|
||||
{
|
||||
@ -826,59 +826,65 @@
|
||||
"th", "tl", "tr", "uk", "ur", "uz", "vi", "wo",
|
||||
"zh-CN", "zh-TW"
|
||||
]}},
|
||||
"webExtensionLocale": "$USER_LOCALE"
|
||||
"webExtensionLocales": ["$USER_LOCALE"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": [
|
||||
"en-CA", "en-GB", "en-US", "en-ZA", "ach", "xh"
|
||||
]}},
|
||||
"webExtensionLocale": "en"
|
||||
"webExtensionLocales": ["en"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": [ "be" ] } },
|
||||
"webExtensionLocales": ["be", "be-tarask"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": [ "bn", "bn-BD", "bn-IN" ] } },
|
||||
"webExtensionLocale": "bn"
|
||||
"webExtensionLocales": ["bn"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": [
|
||||
"cak", "es-AR", "es-CL", "es-ES", "es-MX", "trs"
|
||||
]}},
|
||||
"webExtensionLocale": "es"
|
||||
"webExtensionLocales": ["es"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": [ "cs" ] } },
|
||||
"webExtensionLocale": "cz"
|
||||
"webExtensionLocales": ["cz"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": [ "ff", "fr", "son" ] } },
|
||||
"webExtensionLocale": "fr"
|
||||
"webExtensionLocales": ["fr"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": [ "gu-IN" ] } },
|
||||
"webExtensionLocale": "gu"
|
||||
"webExtensionLocales": ["gu"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": [ "hi-IN" ] } },
|
||||
"webExtensionLocale": "hi"
|
||||
"webExtensionLocales": ["hi"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": [ "hy-AM" ] } },
|
||||
"webExtensionLocale": "hy"
|
||||
"webExtensionLocales": ["hy"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": [ "ja-JP-macos", "ja" ] } },
|
||||
"webExtensionLocale": "ja"
|
||||
"webExtensionLocales": ["ja"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": [ "ko" ] } },
|
||||
"webExtensionLocale": "kr"
|
||||
"webExtensionLocales": ["kr"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": [ "mai" ] } },
|
||||
"webExtensionLocale": "hi"
|
||||
"webExtensionLocales": ["hi"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": [ "ml" ] } },
|
||||
"webExtensionLocales": ["en", "ml"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": [ "nb-NO" ] } },
|
||||
"webExtensionLocale": "NO"
|
||||
"webExtensionLocales": ["NO"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": [ "ne-NP" ] } },
|
||||
"webExtensionLocale": "ne"
|
||||
"webExtensionLocales": ["ne"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": [ "nn-NO" ] } },
|
||||
"webExtensionLocale": "NN"
|
||||
"webExtensionLocales": ["NN"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": [ "pa-IN" ] } },
|
||||
"webExtensionLocale": "pa"
|
||||
"webExtensionLocales": ["pa"]
|
||||
}, {
|
||||
"included": { "locales": { "matches": [ "pt-BR", "pt-PT" ] } },
|
||||
"webExtensionLocale": "pt"
|
||||
"webExtensionLocales": ["pt"]
|
||||
}]
|
||||
}
|
||||
]
|
||||
|
@ -84,8 +84,10 @@ class SearchEngineSelector {
|
||||
this._copyObject(baseConfig, section);
|
||||
}
|
||||
|
||||
if (baseConfig.webExtensionLocale == USER_LOCALE) {
|
||||
baseConfig.webExtensionLocale = locale;
|
||||
if ("webExtensionLocales" in baseConfig) {
|
||||
baseConfig.webExtensionLocales = baseConfig.webExtensionLocales.map(
|
||||
val => (val == USER_LOCALE ? locale : val)
|
||||
);
|
||||
}
|
||||
|
||||
engines.push(baseConfig);
|
||||
|
@ -1151,12 +1151,10 @@ SearchService.prototype = {
|
||||
|
||||
async _loadEnginesFromConfig(engineConfigs) {
|
||||
for (let config of engineConfigs) {
|
||||
// TODO: Support multiple locales per engine
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1575555
|
||||
SearchUtils.log("_loadEnginesFromConfig: " + JSON.stringify(config));
|
||||
let locales =
|
||||
"webExtensionLocale" in config
|
||||
? [config.webExtensionLocale]
|
||||
"webExtensionLocales" in config
|
||||
? config.webExtensionLocales
|
||||
: [DEFAULT_TAG];
|
||||
await this.ensureBuiltinExtension(config.webExtensionId, locales);
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ with identifier ``webext-engine1``, version 1.1. GB region users would get
|
||||
Special Attributes
|
||||
------------------
|
||||
|
||||
If a ``webExtensionLocale`` attribute is specified with the value
|
||||
If a ``webExtensionLocales`` attribute contains an element with the value
|
||||
``"$USER_LOCALE"`` then the special value will be replaced in the
|
||||
configuration object with the users locale. For example:
|
||||
|
||||
@ -126,10 +126,10 @@ configuration object with the users locale. For example:
|
||||
"locales": {
|
||||
"matches": ["us", "gb"]
|
||||
},
|
||||
"webExtensionLocale": "$USER_LOCALE",
|
||||
"webExtensionLocales": ["$USER_LOCALE"],
|
||||
},
|
||||
|
||||
Will report either ``us`` or ``gb`` as the ``webExtensionLocale``
|
||||
Will report either ``[us]`` or ``[gb]`` as the ``webExtensionLocales``
|
||||
depending on the user.
|
||||
|
||||
Experiments
|
||||
|
@ -188,7 +188,13 @@ class SearchConfigTest {
|
||||
code: config.searchUrlGetExtraCodes,
|
||||
};
|
||||
|
||||
let locale = config.webExtensionLocale || "default";
|
||||
// Currently wikipedia is the only engine that uses multiple
|
||||
// locales and that isn't a tested engine so for now pick
|
||||
// the first (only) locale.
|
||||
let locale =
|
||||
"webExtensionLocales" in config
|
||||
? config.webExtensionLocales[0]
|
||||
: "default";
|
||||
// On startup the extension may have not finished parsing the
|
||||
// manifest, wait for that here.
|
||||
await policy.readyPromise;
|
||||
|
@ -14,14 +14,14 @@ const CONFIG_URL =
|
||||
{
|
||||
engineName: "aol",
|
||||
orderHint: 500,
|
||||
webExtensionLocale: "default",
|
||||
webExtensionLocales: ["default"],
|
||||
appliesTo: [
|
||||
{
|
||||
included: { everywhere: true },
|
||||
},
|
||||
{
|
||||
included: { regions: ["us"] },
|
||||
webExtensionLocale: "$USER_LOCALE",
|
||||
webExtensionLocales: ["$USER_LOCALE"],
|
||||
},
|
||||
],
|
||||
},
|
||||
@ -82,9 +82,9 @@ add_task(async function() {
|
||||
);
|
||||
let names = engines.map(obj => obj.engineName);
|
||||
Assert.deepEqual(names, ["lycos", "altavista", "aol"], "Correct order");
|
||||
Assert.equal(
|
||||
engines[2].webExtensionLocale,
|
||||
"en-US",
|
||||
Assert.deepEqual(
|
||||
engines[2].webExtensionLocales,
|
||||
["en-US"],
|
||||
"Subsequent matches in applies to can override default"
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user