Localization In Chrome Extensions
Solution 1:
I would just use <input type="button">
and set the value
property of the button:
<inputtype="button" name="buttonSave"id="buttonSave" style="width: 100px; float: right;">
....
document.getElementById("buttonSave").value = chrome.i18n.getMessage("SaveButton");
By the way, I'm fairly certain having a <label>
nested inside of a <button>
is not valid HTML. Use a <div>
or <span>
instead.
EDIT:
I just did a test, and using either .innerHTML
or .innerText
should work fine. Are you sure that:
the return value of
chrome.i18n.getMessage("SaveButton")
is non-empty?you are running
document.getElementById("buttonSave")
after the DOM is built (i.e.,document.getElementById("buttonSave")
is not null or throwing an error)?
Also, understand that overwriting the innerText
or innerHTML
of the button will destroy the elements you have inside the button already. Perhaps you actually want to do document.querySelector("#buttonSave .buttonTextStyle").innerText
to write the the element nested inside the button?
Post a Comment for "Localization In Chrome Extensions"