Skip to content

Commit

Permalink
Add more languages for list selection at install/reset time
Browse files Browse the repository at this point in the history
Related issue:
- uBlockOrigin/uBlock-issues#501

Also, the handling of 3-letter language codes has been fixed.
  • Loading branch information
gorhill committed Apr 14, 2019
1 parent 7652808 commit c9c21f9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
14 changes: 7 additions & 7 deletions assets/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
"group": "regions",
"off": true,
"title": "BGR: Bulgarian Adblock list",
"lang": "bg",
"lang": "bg mk",
"contentURL": "https://stanev.org/abp/adblock_bg.txt",
"supportURL": "https://stanev.org/abp/"
},
Expand Down Expand Up @@ -387,7 +387,7 @@
"group": "regions",
"off": true,
"title": "FRA: EasyList Liste FR",
"lang": "ar fr",
"lang": "ar br fr oc",
"contentURL": "https://easylist-downloads.adblockplus.org/liste_fr.txt",
"supportURL": "https://forums.lanik.us/viewforum.php?f=91"
},
Expand Down Expand Up @@ -514,7 +514,7 @@
"group": "regions",
"off": true,
"title": "NLD: EasyList Dutch",
"lang": "nl",
"lang": "af fy nl",
"contentURL": "https://easylist-downloads.adblockplus.org/easylistdutch.txt",
"supportURL": "https://forums.lanik.us/viewforum.php?f=100"
},
Expand Down Expand Up @@ -566,7 +566,7 @@
"group": "regions",
"off": true,
"title": "RUS: RU AdList",
"lang": "be ru uk",
"lang": "be kk ru uk uz",
"contentURL": "https://easylist-downloads.adblockplus.org/advblock+cssfixes.txt",
"supportURL": "https://forums.lanik.us/viewforum.php?f=102",
"instructionURL": "https://forums.lanik.us/viewtopic.php?f=102&t=22512"
Expand All @@ -576,7 +576,7 @@
"group": "regions",
"off": true,
"title": "RUS: AdGuard Russian filter",
"lang": "be ru uk",
"lang": "be kk ru uk uz",
"contentURL": "https://filters.adtidy.org/extension/ublock/filters/1.txt",
"supportURL": "https://forum.adguard.com/forumdisplay.php?69-%D0%A4%D0%B8%D0%BB%D1%8C%D1%82%D1%80%D1%8B-Adguard",
"instructionURL": "https://kb.adguard.com/ru/general/adguard-ad-filters#russian"
Expand All @@ -586,7 +586,7 @@
"group": "regions",
"off": true,
"title": "spa: EasyList Spanish",
"lang": "es",
"lang": "an ast ca es eu gl",
"contentURL": "https://easylist-downloads.adblockplus.org/easylistspanish.txt",
"supportURL": "https://forums.lanik.us/viewforum.php?f=103"
},
Expand All @@ -595,7 +595,7 @@
"group": "regions",
"off": true,
"title": "spa, por: AdGuard Spanish/Portuguese filter",
"lang": "es pt",
"lang": "an ast ca es eu gl pt",
"contentURL": "https://filters.adtidy.org/extension/ublock/filters/9.txt",
"supportURL": "https://github.com/AdguardTeam/AdguardFilters#adguard-filters",
"instructionURL": "https://kb.adguard.com/en/general/adguard-ad-filters"
Expand Down
14 changes: 8 additions & 6 deletions src/js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -1248,19 +1248,21 @@
// Support ability to auto-enable a filter list based on user agent.

µBlock.listMatchesEnvironment = function(details) {
var re;
// Matches language?
if ( typeof details.lang === 'string' ) {
re = this.listMatchesEnvironment.reLang;
let re = this.listMatchesEnvironment.reLang;
if ( re === undefined ) {
re = new RegExp('\\b' + self.navigator.language.slice(0, 2) + '\\b');
this.listMatchesEnvironment.reLang = re;
const match = /^[a-z]+/.exec(self.navigator.language);
if ( match !== null ) {
re = new RegExp('\\b' + match[0] + '\\b');
this.listMatchesEnvironment.reLang = re;
}
}
if ( re.test(details.lang) ) { return true; }
if ( re !== undefined && re.test(details.lang) ) { return true; }
}
// Matches user agent?
if ( typeof details.ua === 'string' ) {
re = new RegExp('\\b' + this.escapeRegex(details.ua) + '\\b', 'i');
let re = new RegExp('\\b' + this.escapeRegex(details.ua) + '\\b', 'i');
if ( re.test(self.navigator.userAgent) ) { return true; }
}
return false;
Expand Down

0 comments on commit c9c21f9

Please sign in to comment.