From 2d629c4a435c81936c53ec8ed577a42f86a4f07f Mon Sep 17 00:00:00 2001 From: idk Date: Tue, 19 Feb 2019 14:56:55 -0500 Subject: [PATCH] Started some internationalization stuff --- README.md | 7 ++----- _locales/en/messages.json | 31 +++++++++++++++++++++++++++++++ background.js | 11 +++++++---- manifest.json | 11 ++++++----- options/options.html | 6 +++--- options/options.js | 11 +++++++++-- 6 files changed, 58 insertions(+), 19 deletions(-) create mode 100644 _locales/en/messages.json diff --git a/README.md b/README.md index 7e916f5..1da23d2 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/_locales/en/messages.json b/_locales/en/messages.json new file mode 100644 index 0000000..6d55363 --- /dev/null +++ b/_locales/en/messages.json @@ -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" + } +} diff --git a/background.js b/background.js index 0451e04..b74a78d 100644 --- a/background.js +++ b/background.js @@ -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 }); } } diff --git a/manifest.json b/manifest.json index 2c2bb4d..43f3b9c 100644 --- a/manifest.json +++ b/manifest.json @@ -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" } diff --git a/options/options.html b/options/options.html index 2e4a51d..0f107c7 100644 --- a/options/options.html +++ b/options/options.html @@ -10,7 +10,7 @@
Proxy Scheme:
@@ -18,9 +18,9 @@
Proxy Options
- +
- +
diff --git a/options/options.js b/options/options.js index 30dfad8..23e7e9a 100644 --- a/options/options.js +++ b/options/options.js @@ -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); -