mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-05 18:32:30 +01: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
@ -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 New Issue
Block a user