🌐 Modify i18n

This commit is contained in:
Clement Desmidt 2018-10-17 08:15:10 +02:00
parent a9ad1533c9
commit 0f449be68d
2 changed files with 9 additions and 10 deletions

View File

@ -16,17 +16,17 @@ storage.get('token', function(resp) {
urlInput.addEventListener("blur", function(e) {
var value = this.value;
storage.set({ url: value }, function() {
message.innerHTML = ext.browser.i18n.getMessage("URLChanged");
message.innerHTML = ext.i18n.getMessage("URLChanged");
});
});
tokenInput.addEventListener("blur", function(e) {
var value = this.value;
storage.set({ token: value }, function() {
message.innerHTML = ext.browser.i18n.getMessage("tokenSaved");
message.innerHTML = ext.i18n.getMessage("tokenSaved");
});
});
document.querySelectorAll("[data-message]").forEach(function(elt) {
elt.innerHTML = ext.browser.i18n.getMessage(elt.dataset.message);
elt.innerHTML = ext.i18n.getMessage(elt.dataset.message);
});

View File

@ -40,12 +40,12 @@ var renderMessage = (message) => {
};
var renderBookmark = (data) => {
var displayContainer = document.getElementById("display-container")
var displayContainer = document.getElementById("display-container");
if(data) {
page_data = data;
displayContainer.innerHTML = template(data);
} else {
renderMessage(ext.browser.i18n.getMessage("cantExtractTitle"));
renderMessage(ext.i18n.getMessage("cantExtractTitle"));
}
};
@ -57,13 +57,12 @@ ext.tabs.query({active: true, currentWindow: true}, function(tabs) {
popup.addEventListener("click", function(e) {
if(e.target && e.target.matches("#save-btn")) {
e.preventDefault();
page_data.comment = document.getElementById("comment").innerText;
// var data = e.target.getAttribute("data-bookmark");
page_data.comment = document.getElementById("comment").value;
ext.runtime.sendMessage({action: "perform-save", data: page_data}, function (response) {
if (response && response.action === "saved") {
renderMessage(ext.browser.i18n.getMessage("savedSuccessfully"));
renderMessage(ext.i18n.getMessage("savedSuccessfully"));
} else {
renderMessage(ext.browser.i18n.getMessage("unknownError"));
renderMessage(ext.i18n.getMessage("unknownError"));
}
});
}
@ -72,7 +71,7 @@ popup.addEventListener("click", function(e) {
var dataMessages = document.querySelectorAll("[data-message]");
[].forEach.call(dataMessages, function(elt) {
console.log(elt.dataset.message);
elt.innerHTML = ext.browser.i18n.getMessage(elt.dataset.message);
elt.innerHTML = ext.i18n.getMessage(elt.dataset.message);
});
var optionsLink = document.querySelector(".js-options");