1
0
Fork 0

make all strings translatable

This commit is contained in:
Lukas Winkler 2017-08-26 19:13:00 +02:00
parent a4f4133cc1
commit fa4a702156
3 changed files with 37 additions and 17 deletions

View file

@ -3,13 +3,25 @@
"message": "Run custom JavaScript on any website.",
"description": "a short description shown in the extention list"
},
"select_host_title": {
"host_title": {
"message": "List of websites modified by Your custom js",
"description": "title-text of dropdown"
"description": "title-text of host selection dropdown"
},
"select_host_goto": {
"message": "Jump to the selected host",
"description": "message if a currently not opened webpage is opened"
"save": {
"message": "save",
"description": "save-button text"
},
"save_title": {
"message": "Save and apply this script",
"description": "title text of save button"
},
"reset": {
"message": "reset",
"description": "reset-button text"
},
"reset_title": {
"message": "",
"description": "title text of reset button"
},
"placeholder_javascript": {
"message": "// Here You can type your custom JavaScript...",
@ -31,10 +43,18 @@
"message": "remove draft",
"description": "buttontext"
},
"draft_remove_title": {
"message": "This is a draft, click to remove it",
"description": "title text of draft remove button"
},
"goto_host": {
"message": "go to",
"description": "when a host that is currently not opened, a button apears for opening this host in the current tab"
},
"goto_host_title": {
"message": "Jump to the selected host",
"description": "message if a currently not opened webpage is opened"
},
"enable_description": {
"message": "enable injection for this host",
"description": "label for checkbox"

View file

@ -18,19 +18,19 @@ document.addEventListener('DOMContentLoaded', function() {
include: {
textarea: 'Uncomment address of script below or type your own (one per line)',
mask: 'Click to close textarea popup'
},
draft: "This is a draft, click to remove it"
}
},
applyTitles: function() {
this.el.hostSelect.setAttribute('title', chrome.i18n.getMessage("select_host_title"));
this.el.hostGoToLink.setAttribute('title', chrome.i18n.getMessage("select_host_goto"));
var translatableIDs = ["error-message", "error-tip"];
applyi18n: function() {
var translatableIDs = ["error-message", "error-tip", "save", "reset", "goto-host", "enable-description"];
translatableIDs.forEach(function(id) {
var translateKey = id.replace("-", "_");
document.getElementById(id).innerText = chrome.i18n.getMessage(translateKey);
});
this.el.saveBtn.setAttribute('title', this.title.save);
this.el.draftRemoveLink.setAttribute('title', this.title.draft);
var translatableTitles = ["host", "goto_host", "save", "reset", "draft_remove"];
translatableIDs.forEach(function(id) {
var translateKey = id.replace("-", "_") + "_title";
document.getElementById(id).setAttribute('title', chrome.i18n.getMessage(translateKey));
});
},
host: undefined,
emptyDataPattern: {
@ -364,7 +364,7 @@ document.addEventListener('DOMContentLoaded', function() {
* Add titles to elements
*/
popup.applyTitles();
popup.applyi18n();
/**

View file

@ -38,9 +38,9 @@
<div class="pure-g">
<div class="pure-u-3-5 controls">
<input type="submit" id="save" class="controls__save pure-button pure-button-primary"
name="save" value="save">
<input type="submit" id="reset" class="controls__reset pure-button" name="reset" value="reset">
<button id="save" class="controls__save pure-button pure-button-primary"
name="save"></button>
<button id="reset" class="controls__reset pure-button" name="reset"></button>
<a id="draft-remove" class="controls__remove-draft red-text is-hidden" href="#"></a>
</div>
</div><!-- .controls -->