diff --git a/_locales/en/messages.json b/_locales/en/messages.json new file mode 100644 index 0000000..82afa5d --- /dev/null +++ b/_locales/en/messages.json @@ -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." + } +} diff --git a/_locales/eo/messages.json b/_locales/eo/messages.json new file mode 100644 index 0000000..e626f97 --- /dev/null +++ b/_locales/eo/messages.json @@ -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." + } +} diff --git a/background.js b/background.js index 1e415de..8906b13 100644 --- a/background.js +++ b/background.js @@ -12,12 +12,10 @@ function initShellfoxProgram() { // Given the name of an array saved to localStorage, return it (if possible). function savedArray(name) { - let saved = []; try { - saved = JSON.parse(localStorage.getItem(name)); + let saved = JSON.parse(localStorage.getItem(name)); return saved; - } catch { }; - return saved; + } catch { return []; }; } @@ -113,7 +111,7 @@ function createCommandMenuItems() { browser.menus.create( { id: actionId, - title: "Run command “" + name + "”", + title: browser.i18n.getMessage("pageCommandContextMenu", name), contexts: ["page_action"] }); @@ -122,7 +120,7 @@ function createCommandMenuItems() { browser.menus.create( { id: pageId, - title: "Run command “" + name + "”", + title: browser.i18n.getMessage("pageCommandContextMenu", name), contexts: ["page"] }); @@ -131,7 +129,7 @@ function createCommandMenuItems() { browser.menus.create( { id: linkId, - title: "Run “" + name + "” on link", + title: browser.i18n.getMessage("linkCommandContextMenu", name), contexts: ["link"] }); } @@ -143,7 +141,7 @@ function createCommandMenuItems() { browser.menus.create( { id: "run-page-command", - title: "Run default shell command", + title: browser.i18n.getMessage("pageCommandDefaultContextMenu"), contexts: ["page"] } ); @@ -153,7 +151,7 @@ browser.menus.create( browser.menus.create( { id: "run-link-command", - title: "Run default command on link", + title: browser.i18n.getMessage("linkCommandDefaultContextMenu"), contexts: ["link"] } ); @@ -168,8 +166,6 @@ browser.pageAction.onClicked.addListener((tab) => { // When a context-menu (right-click menu) is opened, only display the SHellfox // item if there is a configured command for that page. browser.menus.onShown.addListener(info => { - console.log(info); - console.log(info.modifiers); if (info.contexts.includes("link") && getUrlCommands(info.linkUrl)) { showLinkContextMenuItem(); } else if (info.contexts.includes("page") && getUrlCommands(info.pageUrl)) { diff --git a/manifest.json b/manifest.json index 877c142..8cfa522 100644 --- a/manifest.json +++ b/manifest.json @@ -1,11 +1,13 @@ { "manifest_version": 2, - "name": "Shellfox", + "name": "__MSG_extensionName__", "version": "0.1", - "description": "Run command-line programs from Firefox, easily.", + "description": "__MSG_extensionDescription__", "homepage_url": "https://hak.xwx.moe/jadedctrl/shellfox", + "default_locale": "en", + "icons": { "250": "res/shellfox.png", "38": "res/shellfox-38.png", @@ -17,7 +19,7 @@ "19": "res/shellfox-19.png", "38": "res/shellfox-38.png" }, - "default_title": "Shellfox" + "default_title": "__MSG_pageActionName__" }, "permissions": [ diff --git a/options.html b/options.html index d172235..55bc6ce 100644 --- a/options.html +++ b/options.html @@ -5,12 +5,12 @@
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.
+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.
Name | -Shell command | +Name | +Shell command |
---|
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.
+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.
URL regex | -Shell command | +URL regex | +Shell command |
---|