Bug 1572470 - Add wikipedia to engines.json r=Standard8

Differential Revision: https://phabricator.services.mozilla.com/D43768

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dale Harvey 2019-08-30 15:02:47 +00:00
Родитель 1793f8666d
Коммит 5cfefa7835
4 изменённых файлов: 103 добавлений и 2 удалений

Просмотреть файл

@ -808,6 +808,78 @@
"webExtensionId": "zoznam-sk@search.mozilla.org",
"webExtensionVersion": "1.2",
"appliesTo": [{ "included": { "locales": { "matches": ["sk"]}}}]
},
{
"engineName": "wikipedia",
"webExtensionId": "wikipedia@search.mozilla.org",
"webExtensionVersion": "1.0",
"appliesTo": [ {
"included": { "locales": { "matches": [
"af", "an", "ar", "as", "ast", "az", "be", "bg",
"br", "bs", "ca", "crh", "cy", "da", "de", "dsb",
"el", "eo", "et", "eu", "fa", "fi", "fy-NL", "ga-IE",
"gd", "gl", "gn", "he", "hr", "hsb", "hu", "ia",
"id", "is", "it", "ka", "kab", "kk", "km", "kn",
"lij", "lo", "lt", "ltg", "lv", "mk", "ml", "mr",
"ms", "my", "nl", "oc", "or", "pl", "rm", "ro", "ru",
"si", "sk", "sl", "sq", "sr", "sv-SE", "ta", "te",
"th", "tl", "tr", "uk", "ur", "uz", "vi", "wo",
"zh-CN", "zh-TW"
]}},
"webExtensionLocale": "$USER_LOCALE"
}, {
"included": { "locales": { "matches": [
"en-CA", "en-GB", "en-US", "en-ZA", "ach", "xh"
]}},
"webExtensionLocale": "en"
}, {
"included": { "locales": { "matches": [ "bn", "bn-BD", "bn-IN" ] } },
"webExtensionLocale": "bn"
}, {
"included": { "locales": { "matches": [
"cak", "es-AR", "es-CL", "es-ES", "es-MX", "trs"
]}},
"webExtensionLocale": "es"
}, {
"included": { "locales": { "matches": [ "cs" ] } },
"webExtensionLocale": "cz"
}, {
"included": { "locales": { "matches": [ "ff", "fr", "son" ] } },
"webExtensionLocale": "fr"
}, {
"included": { "locales": { "matches": [ "gu-IN" ] } },
"webExtensionLocale": "gu"
}, {
"included": { "locales": { "matches": [ "hi-IN" ] } },
"webExtensionLocale": "hi"
}, {
"included": { "locales": { "matches": [ "hy-AM" ] } },
"webExtensionLocale": "hy"
}, {
"included": { "locales": { "matches": [ "ja-JP-macos", "ja" ] } },
"webExtensionLocale": "ja"
}, {
"included": { "locales": { "matches": [ "ko" ] } },
"webExtensionLocale": "kr"
}, {
"included": { "locales": { "matches": [ "mai" ] } },
"webExtensionLocale": "hi"
}, {
"included": { "locales": { "matches": [ "nb-NO" ] } },
"webExtensionLocale": "NO"
}, {
"included": { "locales": { "matches": [ "ne-NP" ] } },
"webExtensionLocale": "ne"
}, {
"included": { "locales": { "matches": [ "nn-NO" ] } },
"webExtensionLocale": "NN"
}, {
"included": { "locales": { "matches": [ "pa-IN" ] } },
"webExtensionLocale": "pa"
}, {
"included": { "locales": { "matches": [ "pt-BR", "pt-PT" ] } },
"webExtensionLocale": "pt"
}]
}
]
}

Просмотреть файл

@ -18,6 +18,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
const EXT_SEARCH_PREFIX = "resource://search-extensions/";
const ENGINE_CONFIG_URL = `${EXT_SEARCH_PREFIX}engines.json`;
const USER_LOCALE = "$USER_LOCALE";
function log(str) {
SearchUtils.log("SearchEngineSelector " + str + "\n");
@ -77,6 +78,11 @@ class SearchEngineSelector {
for (let section of applies) {
this._copyObject(baseConfig, section);
}
if (baseConfig.webExtensionLocale == USER_LOCALE) {
baseConfig.webExtensionLocale = locale;
}
engines.push(baseConfig);
}
}

Просмотреть файл

@ -109,6 +109,29 @@ In this case users identified as being in the US region would use the WebExtensi
with identifier ``webext-engine1``, version 1.1. GB region users would get
``webext-gb`` version 1.2, and all other users would get ``webext`` version 1.0.
Special Attributes
------------------
If a ``webExtensionLocale`` attribute is specified with the value
``"$USER_LOCALE"`` then the special value will be replaced in the
configuration object with the users locale. For example:
.. code-block:: js
"engine1": {
"webExtensionId": "webext",
"webExtensionVersion": "1.0",
"appliesTo": [{
"included": {
"locales": {
"matches": ["us", "gb"]
},
"webExtensionLocale": "$USER_LOCALE",
},
Will report either ``us`` or ``gb`` as the ``webExtensionLocale``
depending on the user.
Engine Defaults
---------------

Просмотреть файл

@ -21,7 +21,7 @@ const CONFIG_URL =
},
{
included: { regions: ["us"] },
webExtensionLocale: "us",
webExtensionLocale: "$USER_LOCALE",
},
],
},
@ -80,7 +80,7 @@ add_task(async function() {
Assert.deepEqual(names, ["lycos", "altavista", "aol"], "Correct order");
Assert.equal(
engines[2].webExtensionLocale,
"us",
"en-US",
"Subsequent matches in applies to can override default"
);