summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorsimonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-01 18:22:25 +0000
committersimonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-01 18:22:25 +0000
commitc5983c61c5c4a0383161883775ec2cfeb44d4a3c (patch)
tree9a6a9d293a68421978bfd5a26dbee0a8e551889c /remoting
parent128bf266d1a880fa93ec1ef2581d591d79d795a7 (diff)
downloadchromium_src-c5983c61c5c4a0383161883775ec2cfeb44d4a3c.zip
chromium_src-c5983c61c5c4a0383161883775ec2cfeb44d4a3c.tar.gz
chromium_src-c5983c61c5c4a0383161883775ec2cfeb44d4a3c.tar.bz2
[Chromoting] Render host names as text.
BUG=130582 Review URL: https://chromiumcodereview.appspot.com/10459061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140061 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-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.