Started some internationalization stuff

This commit is contained in:
idk
2019-02-19 14:56:55 -05:00
parent a03fe658ef
commit 2d629c4a43
6 changed files with 58 additions and 19 deletions

View File

@@ -1,15 +1,12 @@
i2psetproxy.js
==============
WebExtension that automatically sets up a browser to use the proxy into i2p.
This extension shouldn't be used on it's own, and the extension it should be
used with aren't quite done yet. In conjunction with a hardened user.js or
installed in a TBB, it's probably pretty safe. It doesn't contain any
fingerprintable resources.
WebExtension that does extended configuration of a dedicated i2p browser.
Features
--------
* [done] **Indicate** the i2p browser is in use verbally and symbolically.
* [done] **Set** the http proxy to use the local i2p proxy
* [done] **Disable** risky webRTC features
* [done] **Change** the color of the browser window to indicate that i2p is in use

31
_locales/en/messages.json Normal file
View File

@@ -0,0 +1,31 @@
{
"extensionName": {
"message": "i2psetproxy.js",
"description": "Name of the extension."
},
"extensionDescription": {
"message": "Set up a browser to use the i2p http proxy automatically",
"description": "Description of the extension."
},
"titlePreface": {
"message": "I2P Browser - ",
"description": "Preface for the browser titlebar"
},
"titlePrefacePrivate": {
"message": "I2P Browser (Private) - ",
"description": "Preface for the browser titlebar"
},
"resetMessage": {
"message": "Reset Tunnel",
"description": "Message for the Reset Tunnel button"
},
"hostText": {
"message": "Host: ",
"description": "Message for the Reset Tunnel button"
},
"portText": {
"message": "Port: ",
"description": "Message for the Reset Tunnel button"
}
}

View File

@@ -3,6 +3,9 @@ browser.windows.onCreated.addListener(themeWindow);
// Theme all currently open windows
browser.windows.getAll().then(wins => wins.forEach(themeWindow));
var titlepref = browser.i18n.getMessage("titlePreface");
var titleprefpriv = browser.i18n.getMessage("titlePrefacePrivate");
function themeWindow(window) {
// Check if the window is in private browsing
if (window.incognito) {
@@ -18,7 +21,7 @@ function themeWindow(window) {
}
});
browser.windows.update(window.id, {
titlePreface: "I2P Browser (Private Browsing) - "
titlePreface: titleprefpriv
});
}
else {
@@ -34,7 +37,7 @@ function themeWindow(window) {
}
});
browser.windows.update(window.id, {
titlePreface: "I2P Browser - "
titlePreface: titlepref
});
}
}
@@ -42,12 +45,12 @@ function themeWindow(window) {
function setTitle(window){
if (window.incognito) {
browser.windows.update(window.id, {
titlePreface: "I2P Browser (Private Browsing) - "
titlePreface: titleprefpriv
});
}
else {
browser.windows.update(window.id, {
titlePreface: "I2P Browser - "
titlePreface: titlepref
});
}
}

View File

@@ -7,20 +7,21 @@
},
"permissions": ["theme", "proxy", "privacy", "storage"],
"manifest_version": 2,
"name": "i2psetproxy.js",
"version": "1.12",
"description": "Set up a browser to use the i2p http proxy automatically",
"name": "__MSG_extensionName__",
"version": "1.13",
"description": "__MSG_extensionDescription__",
"icons": {
"48": "icons/toopie.png"
},
"browser_action": {
"default_icon": "icons/toopie.png",
"default_title": "Reset Tunnel"
"default_title": "__MSG_resetMessage__"
},
"options_ui": {
"page": "options/options.html"
},
"background": {
"scripts": ["background.js", "proxy.js"]
}
},
"default_locale": "en"
}

View File

@@ -10,7 +10,7 @@
<section class="scheme-options">
<span class="title">Proxy Scheme:</span>
<select id="proxy_scheme">
<option value="http" selected>HTTP</option>
<option value="http" selected="selected">HTTP</option>
<option value="socks5">SOCKS5</option>
</select>
</section>
@@ -18,9 +18,9 @@
<section class="scheme-options proxy-options">
<div class="title" >Proxy Options</div>
<label>Host: <input type="text" data="host" id="host" value="127.0.0.1"/></label>
<label id="portText">Host: <input type="text" data="host" id="host" value="127.0.0.1"/></label>
<br>
<label>Port: <input type="text" data="port" id="port" value="4444"/></label>
<label id="hostText">Port: <input type="text" data="port" id="port" value="4444"/></label>
</section>

View File

@@ -1,4 +1,7 @@
var hosttext = browser.i18n.getMessage("hostText");
var porttext = browser.i18n.getMessage("portText");
function getScheme() {
const proxy_scheme = document.querySelector("#proxy_scheme");
console.log("Got i2p proxy scheme:", proxy_scheme.value);
@@ -122,11 +125,16 @@ function updateUI(restoredSettings) {
const hostitem = document.getElementById("host")
hostitem.value = restoredSettings.proxy_host.getAttribute("value")
console.log("showing proxy host:", hostitem.value)
var hostid = document.getElementById('hostText');
var hostlabel = usersec.getElementsByTagName('label')[0];
hostlabel.innerHTML = hosttext;
const portitem = document.getElementById("port")
portitem.value = restoredSettings.proxy_port.getAttribute("value")
console.log("showing proxy port:", portitem.value)
var portid = document.getElementById('portText');
var portlabel = usersec.getElementsByTagName('label')[0];
portlabel.innerHTML = porttext;
}
@@ -142,4 +150,3 @@ gettingStoredSettings.then(updateUI, onError);
const saveButton = document.querySelector("#save-button");
saveButton.addEventListener("click", storeSettings);