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

Side by Side Diff: pkg/intl/test/message_extraction/make_hardcoded_translation.dart

Issue 22286013: Add support for Intl.select (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Changes from review Created 7 years, 4 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 #!/usr/bin/env dart 1 #!/usr/bin/env dart
2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
3 // for details. All rights reserved. Use of this source code is governed by a 3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file. 4 // BSD-style license that can be found in the LICENSE file.
5 5
6 /** 6 /**
7 * This simulates a translation process, reading the messages generated 7 * This simulates a translation process, reading the messages generated
8 * from extract_message.dart for the files sample_with_messages.dart and 8 * from extract_message.dart for the files sample_with_messages.dart and
9 * part_of_sample_with_messages.dart and writing out hard-coded translations for 9 * part_of_sample_with_messages.dart and writing out hard-coded translations for
10 * German and French locales. 10 * German and French locales.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 ['male', 'homme'], 96 ['male', 'homme'],
97 ['female', 'femme'], 97 ['female', 'femme'],
98 ['other', 'autre'], 98 ['other', 'autre'],
99 ], null)), 99 ], null)),
100 "nestedOuter" : writer.write ( new Plural.from("number", 100 "nestedOuter" : writer.write ( new Plural.from("number",
101 [ 101 [
102 ['other', new Gender.from("gen", 102 ['other', new Gender.from("gen",
103 [["male", "\$number homme"], ["other", "\$number autre"]], null), 103 [["male", "\$number homme"], ["other", "\$number autre"]], null),
104 ] 104 ]
105 ], null)), 105 ], null)),
106 "outerSelect" : writer.write(new Select.from("currency",
107 [
108 ['CDN', '\$amount dollars Canadiens'],
109 ['other', '\$amount certaine devise ou autre.'],
110 ], null)),
111 "nestedSelect" : writer.write(new Select.from("currency",
112 [
113 ['CDN', new Plural.from('amount',
114 [
115 ["other", '\$amount dollars Canadiens'],
116 ["one", '\$amount dollar Canadien'],
117 ], null)
118 ],
119 ['other', 'N''importe quoi'],
120 ], null)),
106 }; 121 };
107 122
108 /** A list of the German translations that we will produce. */ 123 /** A list of the German translations that we will produce. */
109 var german = { 124 var german = {
110 "types" : r"$a, $b, $c", 125 "types" : r"$a, $b, $c",
111 "multiLine" : "Dieser String erstreckt sich über mehrere Zeilen erstrecken.", 126 "multiLine" : "Dieser String erstreckt sich über mehrere Zeilen erstrecken.",
112 "message2" : r"Eine weitere Meldung mit dem Parameter $x", 127 "message2" : r"Eine weitere Meldung mit dem Parameter $x",
113 "alwaysTranslated" : "Diese Zeichenkette wird immer übersetzt", 128 "alwaysTranslated" : "Diese Zeichenkette wird immer übersetzt",
114 "message1" : "Dies ist eine Nachricht", 129 "message1" : "Dies ist eine Nachricht",
115 "leadingQuotes" : "\"Sogenannt\"", 130 "leadingQuotes" : "\"Sogenannt\"",
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 ['male', 'Mann'], 182 ['male', 'Mann'],
168 ['female', 'Frau'], 183 ['female', 'Frau'],
169 ['other', 'andere'], 184 ['other', 'andere'],
170 ], null)), 185 ], null)),
171 "nestedOuter" : writer.write (new Plural.from("number", 186 "nestedOuter" : writer.write (new Plural.from("number",
172 [ 187 [
173 ['other', new Gender.from("gen", 188 ['other', new Gender.from("gen",
174 [["male", "\$number Mann"], ["other", "\$number andere"]], null), 189 [["male", "\$number Mann"], ["other", "\$number andere"]], null),
175 ] 190 ]
176 ], null)), 191 ], null)),
192 "outerSelect" : writer.write(new Select.from("currency",
193 [
194 ['CDN', '\$amount Kanadischen dollar'],
195 ['other', '\$amount einige Währung oder anderen.'],
196 ], null)),
197 "nestedSelect" : writer.write(new Select.from("currency",
198 [
199 ['CDN', new Plural.from('amount',
200 [
201 ["other", '\$amount Kanadischen dollar'],
202 ["one", '\$amount Kanadischer dollar'],
203 ], null)
204 ],
205 ['other', 'whatever'],
206 ], null)),
177 }; 207 };
178 208
179 /** The output directory for translated files. */ 209 /** The output directory for translated files. */
180 String targetDir; 210 String targetDir;
181 211
182 /** 212 /**
183 * Generate a translated json version from [originals] in [locale] looking 213 * Generate a translated json version from [originals] in [locale] looking
184 * up the translations in [translations]. 214 * up the translations in [translations].
185 */ 215 */
186 void translate(List originals, String locale, Map translations) { 216 void translate(List originals, String locale, Map translations) {
(...skipping 17 matching lines...) Expand all
204 parser.addOption("output-dir", defaultsTo: '.', 234 parser.addOption("output-dir", defaultsTo: '.',
205 callback: (value) => targetDir = value); 235 callback: (value) => targetDir = value);
206 parser.parse(args); 236 parser.parse(args);
207 237
208 var fileArgs = args.where((x) => x.contains('.json')); 238 var fileArgs = args.where((x) => x.contains('.json'));
209 239
210 var messages = json.parse(new File(fileArgs.first).readAsStringSync()); 240 var messages = json.parse(new File(fileArgs.first).readAsStringSync());
211 translate(messages, "fr", french); 241 translate(messages, "fr", french);
212 translate(messages, "de_DE", german); 242 translate(messages, "de_DE", german);
213 } 243 }
OLDNEW
« no previous file with comments | « pkg/intl/lib/src/intl_message.dart ('k') | pkg/intl/test/message_extraction/message_extraction_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698