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

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

Issue 8336004: Improve web-app type safety. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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
OLDNEW
1 /* Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 /* Copyright (c) 2011 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 26 matching lines...) Expand all
37 return l10n.localizeElementFromTag(element, tag, opt_substitutions); 37 return l10n.localizeElementFromTag(element, tag, opt_substitutions);
38 }; 38 };
39 39
40 /** 40 /**
41 * Localize all tags with the i18n-content attribute, using i18n-data-n 41 * Localize all tags with the i18n-content attribute, using i18n-data-n
42 * attributes to specify any placeholder substitutions. 42 * attributes to specify any placeholder substitutions.
43 */ 43 */
44 l10n.localize = function() { 44 l10n.localize = function() {
45 var elements = document.querySelectorAll('[i18n-content]'); 45 var elements = document.querySelectorAll('[i18n-content]');
46 for (var i = 0; i < elements.length; ++i) { 46 for (var i = 0; i < elements.length; ++i) {
47 var element = elements[i]; 47 /** @type {Element} */ var element = elements[i];
Jamie 2011/10/18 00:19:27 Not sure why this is needed, since the compiler kn
48 var substitutions = null; 48 var substitutions = null;
49 for (var j = 1; j < 9; ++j) { 49 for (var j = 1; j < 9; ++j) {
50 var attr = 'i18n-value-' + j; 50 var attr = 'i18n-value-' + j;
51 if (element.hasAttribute(attr)) { 51 if (element.hasAttribute(attr)) {
52 if (!substitutions) { 52 if (!substitutions) {
53 substitutions = []; 53 substitutions = [];
54 } 54 }
55 substitutions.push(element.getAttribute(attr)); 55 substitutions.push(element.getAttribute(attr));
56 } else { 56 } else {
57 break; 57 break;
58 } 58 }
59 } 59 }
60 l10n.localizeElement(element, substitutions); 60 l10n.localizeElement(element, substitutions);
61 } 61 }
62 }; 62 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698