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

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

Issue 2926573003: [MD settings] allow unicode nbsp in i18n behavior strings (Closed)
Patch Set: reduced comment 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 28 matching lines...) Expand all
39 /** 39 /**
40 * Returns a translated string where $1 to $9 are replaced by the given 40 * Returns a translated string where $1 to $9 are replaced by the given
41 * values. Also sanitizes the output to filter out dangerous HTML/JS. 41 * values. Also sanitizes the output to filter out dangerous HTML/JS.
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 return parseHtmlSubset('<b>' + rawString + '</b>').firstChild.innerHTML; 49 var htmlStr =
50 parseHtmlSubset('<b>' + rawString + '</b>').firstChild.innerHTML;
51 // TODO(dschuyler): use textContent rather than innerHTML; remove replace().
52 return htmlStr.replace('&nbsp;', '\u00a0');
50 }, 53 },
51 54
52 /** 55 /**
53 * Similar to 'i18n', returns a translated, sanitized, substituted string. 56 * Similar to 'i18n', returns a translated, sanitized, substituted string.
54 * It receives the string ID and a dictionary containing the substitutions 57 * It receives the string ID and a dictionary containing the substitutions
55 * as well as optional additional allowed tags and attributes. 58 * as well as optional additional allowed tags and attributes.
56 * @param {string} id The ID of the string to translate. 59 * @param {string} id The ID of the string to translate.
57 * @param {{substitutions: (Array<string>|undefined), 60 * @param {{substitutions: (Array<string>|undefined),
58 * attrs: (Object<function(Node, string):boolean>|undefined), 61 * attrs: (Object<function(Node, string):boolean>|undefined),
59 * tags: (Array<string>|undefined)}} opts 62 * tags: (Array<string>|undefined)}} opts
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 * @typedef {{ 104 * @typedef {{
102 * i18n: function(string, ...string): string}}, 105 * i18n: function(string, ...string): string}},
103 * i18nAdvanced: function({ 106 * i18nAdvanced: function({
104 * substitutions: (Array<string>|undefined), 107 * substitutions: (Array<string>|undefined),
105 * attrs: (Object<function(Node, string):boolean>|undefined), 108 * attrs: (Object<function(Node, string):boolean>|undefined),
106 * tags: (Array<string>|undefined)}, opts), 109 * tags: (Array<string>|undefined)}, opts),
107 * i18nExists: function(string) 110 * i18nExists: function(string)
108 * }} 111 * }}
109 */ 112 */
110 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