summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--remoting/webapp/client_screen.js2
-rw-r--r--remoting/webapp/l10n.js34
2 files changed, 35 insertions, 1 deletions
diff --git a/remoting/webapp/client_screen.js b/remoting/webapp/client_screen.js
index baa7e56..2bc2d3d 100644
--- a/remoting/webapp/client_screen.js
+++ b/remoting/webapp/client_screen.js
@@ -477,7 +477,7 @@ remoting.connectMe2Me = function(hostId, retryIfOffline) {
return;
}
var message = document.getElementById('pin-message');
- l10n.localizeElement(message, host.hostName);
+ l10n.localizeElementToText(message, host.hostName);
remoting.setMode(remoting.AppMode.CLIENT_PIN_PROMPT);
};
diff --git a/remoting/webapp/l10n.js b/remoting/webapp/l10n.js
index 2ec2b82..9756b87 100644
--- a/remoting/webapp/l10n.js
+++ b/remoting/webapp/l10n.js
@@ -37,6 +37,40 @@ l10n.localizeElement = function(element, opt_substitutions) {
return l10n.localizeElementFromTag(element, tag, opt_substitutions);
};
+// TODO(simonmorris): To simplify a merge, the next two methods were
+// cut-and-pasted from the previous two. Refactor.
+/**
+ * Localize an element by setting its innerText according to the specified tag
+ * and an optional set of substitutions.
+ * @param {Element} element The element to localize.
+ * @param {string} tag The localization tag.
+ * @param {(string|Array)=} opt_substitutions An optional set of substitution
+ * strings corresponding to the "placeholders" attributes in messages.json.
+ * @return {boolean} True if the localization was successful; false otherwise.
+ */
+l10n.localizeElementToTextFromTag = function(element, tag, opt_substitutions) {
+ var translation = chrome.i18n.getMessage(tag, opt_substitutions);
+ if (translation) {
+ element.innerText = translation;
+ } else {
+ console.error('Missing translation for "' + tag + '":', element);
+ }
+ return translation != null;
+};
+
+/**
+ * Localize an element by setting its innerText according to its i18n-content
+ * attribute, and an optional set of substitutions.
+ * @param {Element} element The element to localize.
+ * @param {(string|Array)=} opt_substitutions An optional set of substitution
+ * strings corresponding to the "placeholders" attributes in messages.json.
+ * @return {boolean} True if the localization was successful; false otherwise.
+ */
+l10n.localizeElementToText = function(element, opt_substitutions) {
+ var tag = element.getAttribute('i18n-content');
+ return l10n.localizeElementToTextFromTag(element, tag, opt_substitutions);
+};
+
/**
* Localize all tags with the i18n-content attribute, using i18n-data-n
* attributes to specify any placeholder substitutions.