From 5daa6a7ff337784e0a056d54ff7e4701e216550c Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sat, 6 Nov 2021 12:49:27 -0400 Subject: [PATCH] Get current language using extensions API (instead of `navigator.language`) Related feedback: - https://github.com/gorhill/uBlock/pull/3860 --- src/js/storage.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/js/storage.js b/src/js/storage.js index 27c7a3875..66b09c3d1 100644 --- a/src/js/storage.js +++ b/src/js/storage.js @@ -1489,16 +1489,17 @@ self.addEventListener('hiddenSettingsChanged', ( ) => { // https://github.com/gorhill/uBlock/issues/2344 // Support mutliple locales per filter list. - // https://github.com/gorhill/uBlock/issues/3210 // Support ability to auto-enable a filter list based on user agent. +// https://github.com/gorhill/uBlock/pull/3860 +// Get current language using extensions API (instead of `navigator.language`) µb.listMatchesEnvironment = function(details) { // Matches language? if ( typeof details.lang === 'string' ) { let re = this.listMatchesEnvironment.reLang; if ( re === undefined ) { - const match = /^[a-z]+/.exec(self.navigator.language); + const match = /^[a-z]+/.exec(browser.i18n.getUILanguage()); if ( match !== null ) { re = new RegExp('\\b' + match[0] + '\\b'); this.listMatchesEnvironment.reLang = re;