Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(616)

Side by Side Diff: remoting/webapp/l10n.js

Issue 10703034: Remove 'Enable' button on unsupported platforms. Added 'No hosts' message. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated after UX input. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/webapp/host_list.js ('k') | remoting/webapp/main.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 */ 4 */
5 5
6 var l10n = l10n || {}; 6 var l10n = l10n || {};
7 7
8 /** 8 /**
9 * Localize an element by setting its innerText according to the specified tag 9 * Localize an element by setting its innerText according to the specified tag
10 * and an optional set of substitutions. 10 * and an optional set of substitutions.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 * attributes to specify any placeholder substitutions. 52 * attributes to specify any placeholder substitutions.
53 * 53 *
54 * Because we use i18n-value attributes to implement translations of rich 54 * Because we use i18n-value attributes to implement translations of rich
55 * content (including paragraphs with hyperlinks), we localize these as 55 * content (including paragraphs with hyperlinks), we localize these as
56 * HTML iff there are any substitutions. 56 * HTML iff there are any substitutions.
57 */ 57 */
58 l10n.localize = function() { 58 l10n.localize = function() {
59 var elements = document.querySelectorAll('[i18n-content]'); 59 var elements = document.querySelectorAll('[i18n-content]');
60 for (var i = 0; i < elements.length; ++i) { 60 for (var i = 0; i < elements.length; ++i) {
61 /** @type {Element} */ var element = elements[i]; 61 /** @type {Element} */ var element = elements[i];
62 var substitutions = null; 62 var substitutions = [];
63 for (var j = 1; j < 9; ++j) { 63 for (var j = 1; j < 9; ++j) {
64 var attr = 'i18n-value-' + j; 64 var value = 'i18n-value-' + j;
65 if (element.hasAttribute(attr)) { 65 var valueName = 'i18n-value-name-' + j;
66 if (!substitutions) { 66 if (element.hasAttribute(value)) {
67 substitutions = []; 67 substitutions.push(element.getAttribute(value));
68 } else if (element.hasAttribute(valueName)) {
69 var name = element.getAttribute(valueName);
70 var translation = chrome.i18n.getMessage(name);
71 if (translation) {
72 substitutions.push(translation);
73 } else {
74 console.error('Missing translation for substitution: ' + name);
75 substitutions.push(name);
68 } 76 }
69 substitutions.push(element.getAttribute(attr));
70 } else { 77 } else {
71 break; 78 break;
72 } 79 }
73 } 80 }
74 l10n.localizeElement(element, substitutions, !!substitutions); 81 l10n.localizeElement(element, substitutions, substitutions.length != 0);
75 // Localize tool-tips 82 // Localize tool-tips
76 // TODO(jamiewalch): Move this logic to the html document. 83 // TODO(jamiewalch): Move this logic to the html document.
77 var editButton = document.getElementById('this-host-rename'); 84 var editButton = document.getElementById('this-host-rename');
78 editButton.title = chrome.i18n.getMessage(/*i18n-content*/'TOOLTIP_RENAME'); 85 editButton.title = chrome.i18n.getMessage(/*i18n-content*/'TOOLTIP_RENAME');
79 } 86 }
80 }; 87 };
OLDNEW
« no previous file with comments | « remoting/webapp/host_list.js ('k') | remoting/webapp/main.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698