OLD | NEW |
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 /** | |
7 * Localize the document by replacing innerText of nodes with an i18n-content | |
8 * attribute with the corresponding localized string. | |
9 */ | |
10 | |
11 var l10n = l10n || {}; | 6 var l10n = l10n || {}; |
12 | 7 |
13 /** | 8 /** |
14 * Localize an element by setting its innerText according to its i18n-content | 9 * Localize an element by setting its innerText according to its i18n-content |
15 * attribute, and an optional set of substitutions. | 10 * attribute, and an optional set of substitutions. |
16 * @param {Element} element The element to localize. | 11 * @param {Element} element The element to localize. |
17 * @param {string=} opt_substitutions An optional set of substitution strings | 12 * @param {string=} opt_substitutions An optional set of substitution strings |
18 * corresponding to the "placeholders"attributes in messages.json. | 13 * corresponding to the "placeholders"attributes in messages.json. |
19 * @return {boolean} True if the localization was successful; false otherwise. | 14 * @return {boolean} True if the localization was successful; false otherwise. |
20 */ | 15 */ |
(...skipping 11 matching lines...) Expand all Loading... |
32 /** | 27 /** |
33 * Localize all tags with the i18n-content attribute. | 28 * Localize all tags with the i18n-content attribute. |
34 */ | 29 */ |
35 l10n.localize = function() { | 30 l10n.localize = function() { |
36 var elements = document.querySelectorAll('[i18n-content]'); | 31 var elements = document.querySelectorAll('[i18n-content]'); |
37 for (var i = 0; i < elements.length; ++i) { | 32 for (var i = 0; i < elements.length; ++i) { |
38 var element = elements[i]; | 33 var element = elements[i]; |
39 l10n.localizeElement(element); | 34 l10n.localizeElement(element); |
40 } | 35 } |
41 }; | 36 }; |
OLD | NEW |