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

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

Issue 10879108: Use the i18n tag for strings that can't be translated. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | « no previous file | no next file » | 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.
11 * @param {Element} element The element to localize. 11 * @param {Element} element The element to localize.
12 * @param {string} tag The localization tag. 12 * @param {string} tag The localization tag.
13 * @param {(string|Array)=} opt_substitutions An optional set of substitution 13 * @param {(string|Array)=} opt_substitutions An optional set of substitution
14 * strings corresponding to the "placeholders" attributes in messages.json. 14 * strings corresponding to the "placeholders" attributes in messages.json.
15 * @param {boolean=} opt_asHtml If true, set innerHTML instead of innerText. 15 * @param {boolean=} opt_asHtml If true, set innerHTML instead of innerText.
16 * This parameter should be used with caution. 16 * This parameter should be used with caution.
17 * @return {boolean} True if the localization was successful; false otherwise. 17 * @return {boolean} True if the localization was successful; false otherwise.
18 */ 18 */
19 l10n.localizeElementFromTag = function(element, tag, opt_substitutions, 19 l10n.localizeElementFromTag = function(element, tag, opt_substitutions,
20 opt_asHtml) { 20 opt_asHtml) {
21 var translation = chrome.i18n.getMessage(tag, opt_substitutions); 21 var translation = chrome.i18n.getMessage(tag, opt_substitutions);
22 if (translation) { 22 if (!translation) {
23 if (opt_asHtml) { 23 console.error('Missing translation for "' + tag + '":', element);
24 element.innerHTML = translation; 24 translation = tag; // Make errors more obvious
25 } else { 25 }
26 element.innerText = translation; 26 if (opt_asHtml) {
27 } 27 element.innerHTML = translation;
28 } else { 28 } else {
29 console.error('Missing translation for "' + tag + '":', element); 29 element.innerText = translation;
30 } 30 }
31 return translation != null; 31 return translation != null;
32 }; 32 };
33 33
34 /** 34 /**
35 * Localize an element by setting its innerText according to its i18n-content 35 * Localize an element by setting its innerText according to its i18n-content
36 * attribute, and an optional set of substitutions. 36 * attribute, and an optional set of substitutions.
37 * @param {Element} element The element to localize. 37 * @param {Element} element The element to localize.
38 * @param {(string|Array)=} opt_substitutions An optional set of substitution 38 * @param {(string|Array)=} opt_substitutions An optional set of substitution
39 * strings corresponding to the "placeholders" attributes in messages.json. 39 * strings corresponding to the "placeholders" attributes in messages.json.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 break; 78 break;
79 } 79 }
80 } 80 }
81 l10n.localizeElement(element, substitutions, substitutions.length != 0); 81 l10n.localizeElement(element, substitutions, substitutions.length != 0);
82 // Localize tool-tips 82 // Localize tool-tips
83 // TODO(jamiewalch): Move this logic to the html document. 83 // TODO(jamiewalch): Move this logic to the html document.
84 var editButton = document.getElementById('this-host-rename'); 84 var editButton = document.getElementById('this-host-rename');
85 editButton.title = chrome.i18n.getMessage(/*i18n-content*/'TOOLTIP_RENAME'); 85 editButton.title = chrome.i18n.getMessage(/*i18n-content*/'TOOLTIP_RENAME');
86 } 86 }
87 }; 87 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698