mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00:00
Get current language using extensions API (instead of navigator.language)
Related feedback: - https://github.com/gorhill/uBlock/pull/3860
This commit is contained in:
parent
871f4abd39
commit
5daa6a7ff3
1 changed files with 3 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue