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

Side by Side Diff: ui/webui/resources/js/i18n_behavior.js

Issue 2930833004: [MD settings] use regex replace all nbsp (Closed)
Patch Set: review changes Created 3 years, 6 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
« no previous file with comments | « chrome/test/data/webui/i18n_behavior_test.html ('k') | 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 * @fileoverview 6 * @fileoverview
7 * 'I18nBehavior' is a behavior to mix in loading of internationalization 7 * 'I18nBehavior' is a behavior to mix in loading of internationalization
8 * strings. 8 * strings.
9 */ 9 */
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 * @param {string} id The ID of the string to translate. 42 * @param {string} id The ID of the string to translate.
43 * @param {...string} var_args Values to replace the placeholders $1 to $9 43 * @param {...string} var_args Values to replace the placeholders $1 to $9
44 * in the string. 44 * in the string.
45 * @return {string} A translated, sanitized, substituted string. 45 * @return {string} A translated, sanitized, substituted string.
46 */ 46 */
47 i18n: function(id, var_args) { 47 i18n: function(id, var_args) {
48 var rawString = this.i18nRaw_.apply(this, arguments); 48 var rawString = this.i18nRaw_.apply(this, arguments);
49 var htmlStr = 49 var htmlStr =
50 parseHtmlSubset('<b>' + rawString + '</b>').firstChild.innerHTML; 50 parseHtmlSubset('<b>' + rawString + '</b>').firstChild.innerHTML;
51 // TODO(dschuyler): use textContent rather than innerHTML; remove replace(). 51 // TODO(dschuyler): use textContent rather than innerHTML; remove replace().
52 return htmlStr.replace('&nbsp;', '\u00a0'); 52 return htmlStr.replace(/&nbsp;/g, '\u00a0');
53 }, 53 },
54 54
55 /** 55 /**
56 * Similar to 'i18n', returns a translated, sanitized, substituted string. 56 * Similar to 'i18n', returns a translated, sanitized, substituted string.
57 * It receives the string ID and a dictionary containing the substitutions 57 * It receives the string ID and a dictionary containing the substitutions
58 * as well as optional additional allowed tags and attributes. 58 * as well as optional additional allowed tags and attributes.
59 * @param {string} id The ID of the string to translate. 59 * @param {string} id The ID of the string to translate.
60 * @param {{substitutions: (Array<string>|undefined), 60 * @param {{substitutions: (Array<string>|undefined),
61 * attrs: (Object<function(Node, string):boolean>|undefined), 61 * attrs: (Object<function(Node, string):boolean>|undefined),
62 * tags: (Array<string>|undefined)}} opts 62 * tags: (Array<string>|undefined)}} opts
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 * @typedef {{ 104 * @typedef {{
105 * i18n: function(string, ...string): string}}, 105 * i18n: function(string, ...string): string}},
106 * i18nAdvanced: function({ 106 * i18nAdvanced: function({
107 * substitutions: (Array<string>|undefined), 107 * substitutions: (Array<string>|undefined),
108 * attrs: (Object<function(Node, string):boolean>|undefined), 108 * attrs: (Object<function(Node, string):boolean>|undefined),
109 * tags: (Array<string>|undefined)}, opts), 109 * tags: (Array<string>|undefined)}, opts),
110 * i18nExists: function(string) 110 * i18nExists: function(string)
111 * }} 111 * }}
112 */ 112 */
113 I18nBehavior.Proto; 113 I18nBehavior.Proto;
OLDNEW
« no previous file with comments | « chrome/test/data/webui/i18n_behavior_test.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698