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

Side by Side Diff: ui/base/webui/jstemplate_builder.cc

Issue 2908353003: [i18n] components directory to $i18n{} (Closed)
Patch Set: handle blank cohort name 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // A helper function for using JsTemplate. See jstemplate_builder.h for more 5 // A helper function for using JsTemplate. See jstemplate_builder.h for more
6 // info. 6 // info.
7 7
8 #include "ui/base/webui/jstemplate_builder.h" 8 #include "ui/base/webui/jstemplate_builder.h"
9 9
10 #include "base/json/json_file_value_serializer.h" 10 #include "base/json/json_file_value_serializer.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 AppendLoadTimeData(&output); 114 AppendLoadTimeData(&output);
115 AppendJsonHtml(json, &output); 115 AppendJsonHtml(json, &output);
116 AppendI18nTemplateSourceHtml(&output); 116 AppendI18nTemplateSourceHtml(&output);
117 117
118 return output; 118 return output;
119 } 119 }
120 120
121 std::string GetTemplatesHtml(const base::StringPiece& html_template, 121 std::string GetTemplatesHtml(const base::StringPiece& html_template,
122 const base::DictionaryValue* json, 122 const base::DictionaryValue* json,
123 const base::StringPiece& template_id) { 123 const base::StringPiece& template_id) {
124 std::string output(html_template.data(), html_template.size()); 124 ui::TemplateReplacements replacements;
125 ui::TemplateReplacementsFromDictionaryValue(*json, &replacements);
126 std::string output =
127 ui::ReplaceTemplateExpressions(html_template, replacements);
128
129 // TODO(dschuyler): After the i18n-content and i18n-values are replaced with
130 // $i18n{} replacements, we will be able to return output at this point.
131 // Remove Append*() lines that builds up the i18n replacement work to be done
132 // in JavaScript.
125 AppendLoadTimeData(&output); 133 AppendLoadTimeData(&output);
126 AppendJsonHtml(json, &output); 134 AppendJsonHtml(json, &output);
127 AppendI18nTemplateSourceHtml(&output); 135 AppendI18nTemplateSourceHtml(&output);
128 AppendJsTemplateSourceHtml(&output); 136 AppendJsTemplateSourceHtml(&output);
129 AppendJsTemplateProcessHtml(template_id, &output); 137 AppendJsTemplateProcessHtml(template_id, &output);
130 return output; 138 return output;
131 } 139 }
132 140
133 void AppendJsonJS(const base::DictionaryValue* json, std::string* output) { 141 void AppendJsonJS(const base::DictionaryValue* json, std::string* output) {
134 // Convert the template data to a json string. 142 // Convert the template data to a json string.
135 DCHECK(json) << "must include json data structure"; 143 DCHECK(json) << "must include json data structure";
136 144
137 std::string jstext; 145 std::string jstext;
138 JSONStringValueSerializer serializer(&jstext); 146 JSONStringValueSerializer serializer(&jstext);
139 serializer.Serialize(*json); 147 serializer.Serialize(*json);
140 output->append("loadTimeData.data = "); 148 output->append("loadTimeData.data = ");
141 output->append(jstext); 149 output->append(jstext);
142 output->append(";"); 150 output->append(";");
143 } 151 }
144 152
145 } // namespace webui 153 } // namespace webui
OLDNEW
« chrome/browser/ui/webui/version_ui.cc ('K') | « components/version_ui/resources/about_version.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698