Add localization support + Esperanto translation
This commit is contained in:
parent
b9f997ce36
commit
b1ce996246
|
@ -0,0 +1,108 @@
|
||||||
|
{
|
||||||
|
"extensionName": {
|
||||||
|
"message": "Shellfox",
|
||||||
|
"description": "Name of the extension."
|
||||||
|
},
|
||||||
|
|
||||||
|
"extensionDescription": {
|
||||||
|
"message": "Run command-line programs from Firefox, easily.",
|
||||||
|
"description": "Description of the extension."
|
||||||
|
},
|
||||||
|
|
||||||
|
"pageActionName": {
|
||||||
|
"message": "Run shell command",
|
||||||
|
"description": "Name of address-bar button for running the default command on current page."
|
||||||
|
},
|
||||||
|
|
||||||
|
"pageCommandContextMenu": {
|
||||||
|
"message": "Run command “$COMMAND$”",
|
||||||
|
"description": "Menu-item to run a specific command on the current page.",
|
||||||
|
"placeholders": {
|
||||||
|
"command": {
|
||||||
|
"content": "$1",
|
||||||
|
"example": "Curl"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"pageCommandDefaultContextMenu": {
|
||||||
|
"message": "Run default shell command",
|
||||||
|
"description": "Menu-item to run the default command on the current page."
|
||||||
|
},
|
||||||
|
|
||||||
|
"linkCommandContextMenu": {
|
||||||
|
"message": "Run “$COMMAND$” on link",
|
||||||
|
"description": "Menu-item to run a specific command on a link’s URL.",
|
||||||
|
"placeholders": {
|
||||||
|
"command": {
|
||||||
|
"content": "$1",
|
||||||
|
"example": "Curl"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"linkCommandDefaultContextMenu": {
|
||||||
|
"message": "Run default command on link",
|
||||||
|
"description": "Menu-item to run the default command on a link’s URL."
|
||||||
|
},
|
||||||
|
|
||||||
|
"optionsTitleShell": {
|
||||||
|
"message": "Shell commands",
|
||||||
|
"description": "Title of options-page section for commands."
|
||||||
|
},
|
||||||
|
|
||||||
|
"optionsDescShell": {
|
||||||
|
"message": "Add shell commands, to be executed with a page’s URL as its argument. In a command, $URL will be replaced with the target page’s URL.",
|
||||||
|
"description": "Description of options-page section for commands."
|
||||||
|
},
|
||||||
|
|
||||||
|
"optionsHeadShellName": {
|
||||||
|
"message": "Name",
|
||||||
|
"description": "Header of table-element for options-page section for commands."
|
||||||
|
},
|
||||||
|
|
||||||
|
"optionsHeadShellCommand": {
|
||||||
|
"message": "Shell command",
|
||||||
|
"description": "Header of table-element for options-page section for commands."
|
||||||
|
},
|
||||||
|
|
||||||
|
"optionsPlaceholderName": {
|
||||||
|
"message": "Curl",
|
||||||
|
"description": "Displayed placeholder for options-page input for command-name."
|
||||||
|
},
|
||||||
|
|
||||||
|
"optionsPlaceholderCommand": {
|
||||||
|
"message": "curl $URL > /tmp/downloaded.html",
|
||||||
|
"description": "Displayed placeholder for options-page input for command."
|
||||||
|
},
|
||||||
|
|
||||||
|
"optionsTitleRule": {
|
||||||
|
"message": "URL/Page rules",
|
||||||
|
"description": "Title of options-page section for regex."
|
||||||
|
},
|
||||||
|
|
||||||
|
"optionsDescRule": {
|
||||||
|
"message": "Associate the above commands with URLs, based on regex rules. When a URL is tied to a command, a button will appear in context-menus and the address bar to run said command.",
|
||||||
|
"description": "Description of options-page section for regex."
|
||||||
|
},
|
||||||
|
|
||||||
|
"optionsHeadRuleName": {
|
||||||
|
"message": "URL regex",
|
||||||
|
"description": "Header of table-element for options-page section for regex."
|
||||||
|
},
|
||||||
|
|
||||||
|
"optionsHeadRuleCommand": {
|
||||||
|
"message": "Shell command",
|
||||||
|
"description": "Header of table-element for options-page section for regex."
|
||||||
|
},
|
||||||
|
|
||||||
|
"optionsPlaceholderRule": {
|
||||||
|
"message": "https://example.com/.*",
|
||||||
|
"description": "Displayed placeholder for options-page input for regex."
|
||||||
|
},
|
||||||
|
|
||||||
|
"optionsSaveButton": {
|
||||||
|
"message": "Apply",
|
||||||
|
"description": "Name of button in options-page to save changes."
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,108 @@
|
||||||
|
{
|
||||||
|
"extensionName": {
|
||||||
|
"message": "Ŝelvulpo",
|
||||||
|
"description": "Nomo de la aldonaĵo."
|
||||||
|
},
|
||||||
|
|
||||||
|
"extensionDescription": {
|
||||||
|
"message": "Ruli ŝel-ordonojn de Firefox, facile.",
|
||||||
|
"description": "Priskribo de la aldonaĵo."
|
||||||
|
},
|
||||||
|
|
||||||
|
"pageActionName": {
|
||||||
|
"message": "Ruli ŝel-ordonon",
|
||||||
|
"description": "Nomo de butono por ruli la implicitan ordonon de la nuna paĝo."
|
||||||
|
},
|
||||||
|
|
||||||
|
"pageCommandContextMenu": {
|
||||||
|
"message": "Ruli ordonon «$COMMAND$»",
|
||||||
|
"description": "Menuero por ruli specifan ordonon je la nuna paĝo.",
|
||||||
|
"placeholders": {
|
||||||
|
"command": {
|
||||||
|
"content": "$1",
|
||||||
|
"example": "Curl"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"pageCommandDefaultContextMenu": {
|
||||||
|
"message": "Ruli implicitan ŝel-ordonon",
|
||||||
|
"description": "Menuero por ruli la implicitan ordonon je la nuna paĝo."
|
||||||
|
},
|
||||||
|
|
||||||
|
"linkCommandContextMenu": {
|
||||||
|
"message": "Ruli «$COMMAND$» je ligilo",
|
||||||
|
"description": "Menuero por ruli specifan ordonon je ligilo.",
|
||||||
|
"placeholders": {
|
||||||
|
"command": {
|
||||||
|
"content": "$1",
|
||||||
|
"example": "Curl"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"linkCommandDefaultContextMenu": {
|
||||||
|
"message": "Ruli implicitan ordonon je ligilo",
|
||||||
|
"description": "Menuero por ruli la implicitan ordonon je ligilo."
|
||||||
|
},
|
||||||
|
|
||||||
|
"optionsTitleShell": {
|
||||||
|
"message": "Ŝel-ordonoj",
|
||||||
|
"description": "Titolo de agordo-parto por ordonoj."
|
||||||
|
},
|
||||||
|
|
||||||
|
"optionsDescShell": {
|
||||||
|
"message": "Alondi ŝel-ordonojn kiuj ruliĝas kun la URL de paĝo kiel parametro. En ordono, «$URL» anstataŭiĝos per tiu URL.",
|
||||||
|
"description": "Priskribo de agordo-parto por ordonoj."
|
||||||
|
},
|
||||||
|
|
||||||
|
"optionsHeadShellName": {
|
||||||
|
"message": "Nomo",
|
||||||
|
"description": "Titolo de tabelo-kolumno por agordo-parto por ordonoj."
|
||||||
|
},
|
||||||
|
|
||||||
|
"optionsHeadShellCommand": {
|
||||||
|
"message": "Ŝel-ordono",
|
||||||
|
"description": "Titolo de tabelo-kolumno por agordo-parto por ordonoj."
|
||||||
|
},
|
||||||
|
|
||||||
|
"optionsPlaceholderName": {
|
||||||
|
"message": "Curl",
|
||||||
|
"description": "Provizora valoro ĉe agordopaĝo por enigo de ordononomo."
|
||||||
|
},
|
||||||
|
|
||||||
|
"optionsPlaceholderCommand": {
|
||||||
|
"message": "curl $URL > /tmp/elŝutite.html",
|
||||||
|
"description": "Provizora valoro ĉe agordopaĝo por enigo de ordono."
|
||||||
|
},
|
||||||
|
|
||||||
|
"optionsTitleRule": {
|
||||||
|
"message": "URL/Paĝo-reguloj",
|
||||||
|
"description": "Titolo de agordo-parto por regulaj esprimoj."
|
||||||
|
},
|
||||||
|
|
||||||
|
"optionsDescRule": {
|
||||||
|
"message": "Ligi la suprajn ŝel-ordonojn al URLoj, laŭ regulaj esprimoj. Se URL estas ligita al ordono, butono aperiĝos en la supra breto por ruli ĝin.",
|
||||||
|
"description": "Priskribo de agordo-parto por regulaj esprimoj."
|
||||||
|
},
|
||||||
|
|
||||||
|
"optionsHeadRuleName": {
|
||||||
|
"message": "URL regula esprimo",
|
||||||
|
"description": "Titolo de tabelo-kolumno ĉe agordo-parto por regulaj esprimoj."
|
||||||
|
},
|
||||||
|
|
||||||
|
"optionsHeadRuleCommand": {
|
||||||
|
"message": "Ŝel-ordonoj",
|
||||||
|
"description": "Titolo de tabelo-kolumno ĉe agordo-parto por regulaj esprimoj."
|
||||||
|
},
|
||||||
|
|
||||||
|
"optionsPlaceholderRule": {
|
||||||
|
"message": "https://ekzemplo.org/.*",
|
||||||
|
"description": "Provizora valoro ĉe agordopaĝo por enigo de reteja regula esprimo."
|
||||||
|
},
|
||||||
|
|
||||||
|
"optionsSaveButton": {
|
||||||
|
"message": "Konservi",
|
||||||
|
"description": "Nomo de butono ĉe agordopaĝo por konservi ŝanĝojn."
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,12 +12,10 @@ function initShellfoxProgram() {
|
||||||
|
|
||||||
// Given the name of an array saved to localStorage, return it (if possible).
|
// Given the name of an array saved to localStorage, return it (if possible).
|
||||||
function savedArray(name) {
|
function savedArray(name) {
|
||||||
let saved = [];
|
|
||||||
try {
|
try {
|
||||||
saved = JSON.parse(localStorage.getItem(name));
|
let saved = JSON.parse(localStorage.getItem(name));
|
||||||
return saved;
|
return saved;
|
||||||
} catch { };
|
} catch { return []; };
|
||||||
return saved;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -113,7 +111,7 @@ function createCommandMenuItems() {
|
||||||
browser.menus.create(
|
browser.menus.create(
|
||||||
{
|
{
|
||||||
id: actionId,
|
id: actionId,
|
||||||
title: "Run command “" + name + "”",
|
title: browser.i18n.getMessage("pageCommandContextMenu", name),
|
||||||
contexts: ["page_action"]
|
contexts: ["page_action"]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -122,7 +120,7 @@ function createCommandMenuItems() {
|
||||||
browser.menus.create(
|
browser.menus.create(
|
||||||
{
|
{
|
||||||
id: pageId,
|
id: pageId,
|
||||||
title: "Run command “" + name + "”",
|
title: browser.i18n.getMessage("pageCommandContextMenu", name),
|
||||||
contexts: ["page"]
|
contexts: ["page"]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -131,7 +129,7 @@ function createCommandMenuItems() {
|
||||||
browser.menus.create(
|
browser.menus.create(
|
||||||
{
|
{
|
||||||
id: linkId,
|
id: linkId,
|
||||||
title: "Run “" + name + "” on link",
|
title: browser.i18n.getMessage("linkCommandContextMenu", name),
|
||||||
contexts: ["link"]
|
contexts: ["link"]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -143,7 +141,7 @@ function createCommandMenuItems() {
|
||||||
browser.menus.create(
|
browser.menus.create(
|
||||||
{
|
{
|
||||||
id: "run-page-command",
|
id: "run-page-command",
|
||||||
title: "Run default shell command",
|
title: browser.i18n.getMessage("pageCommandDefaultContextMenu"),
|
||||||
contexts: ["page"]
|
contexts: ["page"]
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -153,7 +151,7 @@ browser.menus.create(
|
||||||
browser.menus.create(
|
browser.menus.create(
|
||||||
{
|
{
|
||||||
id: "run-link-command",
|
id: "run-link-command",
|
||||||
title: "Run default command on link",
|
title: browser.i18n.getMessage("linkCommandDefaultContextMenu"),
|
||||||
contexts: ["link"]
|
contexts: ["link"]
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -168,8 +166,6 @@ browser.pageAction.onClicked.addListener((tab) => {
|
||||||
// When a context-menu (right-click menu) is opened, only display the SHellfox
|
// When a context-menu (right-click menu) is opened, only display the SHellfox
|
||||||
// item if there is a configured command for that page.
|
// item if there is a configured command for that page.
|
||||||
browser.menus.onShown.addListener(info => {
|
browser.menus.onShown.addListener(info => {
|
||||||
console.log(info);
|
|
||||||
console.log(info.modifiers);
|
|
||||||
if (info.contexts.includes("link") && getUrlCommands(info.linkUrl)) {
|
if (info.contexts.includes("link") && getUrlCommands(info.linkUrl)) {
|
||||||
showLinkContextMenuItem();
|
showLinkContextMenuItem();
|
||||||
} else if (info.contexts.includes("page") && getUrlCommands(info.pageUrl)) {
|
} else if (info.contexts.includes("page") && getUrlCommands(info.pageUrl)) {
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "Shellfox",
|
"name": "__MSG_extensionName__",
|
||||||
"version": "0.1",
|
"version": "0.1",
|
||||||
|
|
||||||
"description": "Run command-line programs from Firefox, easily.",
|
"description": "__MSG_extensionDescription__",
|
||||||
"homepage_url": "https://hak.xwx.moe/jadedctrl/shellfox",
|
"homepage_url": "https://hak.xwx.moe/jadedctrl/shellfox",
|
||||||
|
|
||||||
|
"default_locale": "en",
|
||||||
|
|
||||||
"icons": {
|
"icons": {
|
||||||
"250": "res/shellfox.png",
|
"250": "res/shellfox.png",
|
||||||
"38": "res/shellfox-38.png",
|
"38": "res/shellfox-38.png",
|
||||||
|
@ -17,7 +19,7 @@
|
||||||
"19": "res/shellfox-19.png",
|
"19": "res/shellfox-19.png",
|
||||||
"38": "res/shellfox-38.png"
|
"38": "res/shellfox-38.png"
|
||||||
},
|
},
|
||||||
"default_title": "Shellfox"
|
"default_title": "__MSG_pageActionName__"
|
||||||
},
|
},
|
||||||
|
|
||||||
"permissions": [
|
"permissions": [
|
||||||
|
|
16
options.html
16
options.html
|
@ -5,12 +5,12 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<section>
|
<section>
|
||||||
<h3>Shell commands</h3>
|
<h3 id="commandTitle">Shell commands</h3>
|
||||||
<p>Add shell commands, to be executed with a page’s URL as its argument. In a command, $URL will be replaced with the target page’s URL.</p>
|
<p id="commandP">Add shell commands, to be executed with a page’s URL as its argument. In a command, $URL will be replaced with the target page’s URL.</p>
|
||||||
<table id="commandTable">
|
<table id="commandTable">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th id="commandNameTh">Name</th>
|
||||||
<th>Shell command</th>
|
<th id="commandShellTh">Shell command</th>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<button style="width: 5em;" id="save-cmd">Apply</button>
|
<button style="width: 5em;" id="save-cmd">Apply</button>
|
||||||
|
@ -18,12 +18,12 @@
|
||||||
|
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<h3>URL/Page rules</h3>
|
<h3 id="ruleTitle">URL/Page rules</h3>
|
||||||
<p>Associate the above commands with URLs, based on regex rules. When a URL is tied to a command, a button will appear in context-menus and the address bar to run said command.</p>
|
<p id="ruleP">Associate the above commands with URLs, based on regex rules. When a URL is tied to a command, a button will appear in context-menus and the address bar to run said command.</p>
|
||||||
<table id="regexTable">
|
<table id="regexTable">
|
||||||
<tr>
|
<tr>
|
||||||
<th>URL regex</th>
|
<th id="ruleRegexTh">URL regex</th>
|
||||||
<th>Shell command</th>
|
<th id="ruleShellTh">Shell command</th>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<button style="width: 5em;" id="save-regex">Apply</button>
|
<button style="width: 5em;" id="save-regex">Apply</button>
|
||||||
|
|
32
options.js
32
options.js
|
@ -1,11 +1,9 @@
|
||||||
// Given the name of an array saved to localStorage, return it (if possible).
|
// Given the name of an array saved to localStorage, return it (if possible).
|
||||||
function savedArray(name) {
|
function savedArray(name) {
|
||||||
let saved = [];
|
|
||||||
try {
|
try {
|
||||||
saved = JSON.parse(localStorage.getItem(name));
|
let saved = JSON.parse(localStorage.getItem(name));
|
||||||
return saved;
|
return saved;
|
||||||
} catch { };
|
} catch { return []; };
|
||||||
return saved;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,7 +91,7 @@ function createRegexTr(regex, command_i, commandMenu) {
|
||||||
let regexInput = document.createElement("INPUT");
|
let regexInput = document.createElement("INPUT");
|
||||||
regexInput.setAttribute("class", "regex");
|
regexInput.setAttribute("class", "regex");
|
||||||
regexInput.setAttribute("type", "text");
|
regexInput.setAttribute("type", "text");
|
||||||
regexInput.setAttribute("placeholder", "https://example.org/.*");
|
regexInput.setAttribute("placeholder", browser.i18n.getMessage("optionsPlaceholderRule"));
|
||||||
if (regex && command_i)
|
if (regex && command_i)
|
||||||
regexInput.setAttribute("value", regex);
|
regexInput.setAttribute("value", regex);
|
||||||
|
|
||||||
|
@ -119,7 +117,7 @@ function createCommandTr(name, command) {
|
||||||
let nameInput = document.createElement("INPUT");
|
let nameInput = document.createElement("INPUT");
|
||||||
nameInput.setAttribute("class", "name");
|
nameInput.setAttribute("class", "name");
|
||||||
nameInput.setAttribute("type", "text");
|
nameInput.setAttribute("type", "text");
|
||||||
nameInput.setAttribute("placeholder", "Curl");
|
nameInput.setAttribute("placeholder", browser.i18n.getMessage("optionsPlaceholderName"));
|
||||||
if (name && command)
|
if (name && command)
|
||||||
nameInput.setAttribute("value", name);
|
nameInput.setAttribute("value", name);
|
||||||
|
|
||||||
|
@ -129,7 +127,7 @@ function createCommandTr(name, command) {
|
||||||
let commandInput = document.createElement("INPUT");
|
let commandInput = document.createElement("INPUT");
|
||||||
commandInput.setAttribute("class", "command");
|
commandInput.setAttribute("class", "command");
|
||||||
commandInput.setAttribute("type", "text");
|
commandInput.setAttribute("type", "text");
|
||||||
commandInput.setAttribute("placeholder", "curl $URL > /tmp/downloaded");
|
commandInput.setAttribute("placeholder", browser.i18n.getMessage("optionsPlaceholderCommand"));
|
||||||
if (name && command)
|
if (name && command)
|
||||||
commandInput.setAttribute("value", command);
|
commandInput.setAttribute("value", command);
|
||||||
|
|
||||||
|
@ -144,6 +142,25 @@ function createCommandTr(name, command) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Replace the HTML elements’ text with the extension’s translations.
|
||||||
|
function i18nPage() {
|
||||||
|
document.getElementsByTagName("html")[0].setAttribute("lang", browser.i18n.getMessage("@@ui_locale"));
|
||||||
|
|
||||||
|
document.getElementById("commandTitle").innerText = browser.i18n.getMessage("optionsTitleShell");
|
||||||
|
document.getElementById("commandP").innerText = browser.i18n.getMessage("optionsDescShell");
|
||||||
|
document.getElementById("commandNameTh").innerText = browser.i18n.getMessage("optionsHeadShellName");
|
||||||
|
document.getElementById("commandShellTh").innerText = browser.i18n.getMessage("optionsHeadShellCommand");
|
||||||
|
|
||||||
|
document.getElementById("ruleTitle").innerText = browser.i18n.getMessage("optionsTitleRule");
|
||||||
|
document.getElementById("ruleP").innerText = browser.i18n.getMessage("optionsDescRule");
|
||||||
|
document.getElementById("ruleRegexTh").innerText = browser.i18n.getMessage("optionsHeadRuleName");
|
||||||
|
document.getElementById("ruleShellTh").innerText = browser.i18n.getMessage("optionsHeadRuleCommand");
|
||||||
|
|
||||||
|
document.getElementById("save-cmd").innerText = browser.i18n.getMessage("optionsSaveButton");
|
||||||
|
document.getElementById("save-regex").innerText = browser.i18n.getMessage("optionsSaveButton");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
document.addEventListener("click", e => {
|
document.addEventListener("click", e => {
|
||||||
if (e.target.id == ("save-cmd")) {
|
if (e.target.id == ("save-cmd")) {
|
||||||
saveCommands();
|
saveCommands();
|
||||||
|
@ -157,3 +174,4 @@ document.addEventListener("click", e => {
|
||||||
|
|
||||||
populateCommandTable();
|
populateCommandTable();
|
||||||
populateRegexTable();
|
populateRegexTable();
|
||||||
|
i18nPage();
|
||||||
|
|
Ŝarĝante…
Reference in New Issue