diff options
author | simonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-04 20:24:13 +0000 |
---|---|---|
committer | simonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-04 20:24:13 +0000 |
commit | cc908bc8a947ae3b88825b39d76b908c4fee8868 (patch) | |
tree | 6932e5a7e3d9ba9e593b8e423d5a0cd2cefc1b20 /remoting | |
parent | 44e7a2726976be8d6b3f007b844f9bc79703649f (diff) | |
download | chromium_src-cc908bc8a947ae3b88825b39d76b908c4fee8868.zip chromium_src-cc908bc8a947ae3b88825b39d76b908c4fee8868.tar.gz chromium_src-cc908bc8a947ae3b88825b39d76b908c4fee8868.tar.bz2 |
Merge 140061 - [Chromoting] Render host names as text.
BUG=130582
Review URL: https://chromiumcodereview.appspot.com/10459061
TBR=simonmorris@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10513010
git-svn-id: svn://svn.chromium.org/chrome/branches/1132/src@140358 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/webapp/client_screen.js | 2 | ||||
-rw-r--r-- | remoting/webapp/l10n.js | 34 |
2 files changed, 35 insertions, 1 deletions
diff --git a/remoting/webapp/client_screen.js b/remoting/webapp/client_screen.js index 60500c9..f07c54e 100644 --- a/remoting/webapp/client_screen.js +++ b/remoting/webapp/client_screen.js @@ -499,7 +499,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. |