Work-around for browser.i18n.getMessage() API in content scripts giving away browser's real locale (Tor issue #31287).
This commit is contained in:
parent
6ef9b4e232
commit
125a1a2937
|
@ -1,6 +1,16 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
// debug = () => {}; // REL_ONLY
|
// debug = () => {}; // REL_ONLY
|
||||||
var _ = browser.i18n.getMessage;
|
function _(...args) {
|
||||||
|
let fakeLang = navigator.language === "en-US" &&
|
||||||
|
browser.i18n.getUILanguage() !== "en-US";
|
||||||
|
return (_ = (template, ...substitutions) => {
|
||||||
|
let [key, defTemplate] = template.split("|");
|
||||||
|
return fakeLang
|
||||||
|
? (defTemplate || key).replace(/\$([1-9])/g,
|
||||||
|
(m, p) => substitutions[parseInt(p) - 1] || "$" + p)
|
||||||
|
: browser.i18n.getMessage(template, ...substitutions);
|
||||||
|
})(...args);
|
||||||
|
}
|
||||||
|
|
||||||
function createHTMLElement(name) {
|
function createHTMLElement(name) {
|
||||||
return document.createElementNS("http://www.w3.org/1999/xhtml", name);
|
return document.createElementNS("http://www.w3.org/1999/xhtml", name);
|
||||||
|
|
|
@ -4,6 +4,8 @@ body {
|
||||||
font-family: sans-serif;
|
font-family: sans-serif;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: #222;
|
color: #222;
|
||||||
|
margin: 0px;
|
||||||
|
padding: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#header {
|
#header {
|
||||||
|
@ -84,6 +86,7 @@ body {
|
||||||
.choices label {
|
.choices label {
|
||||||
display: block;
|
display: block;
|
||||||
padding-bottom: .5em;
|
padding-bottom: .5em;
|
||||||
|
word-break: break-all;
|
||||||
}
|
}
|
||||||
|
|
||||||
#buttons {
|
#buttons {
|
||||||
|
|
Loading…
Reference in New Issue