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

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

Issue 20072002: Allow Intl.plural/gender as the top-level, omitting the Intl.message wrapper and the first layer of… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Changes from review Created 7 years, 5 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 ["other", "\${names} étaient allés à la \$place"], 77 ["other", "\${names} étaient allés à la \$place"],
78 ], null) 78 ], null)
79 ], 79 ],
80 ["female", new Plural.from("number", 80 ["female", new Plural.from("number",
81 [ 81 [
82 ["one", "\$names était allée à la \$place"], 82 ["one", "\$names était allée à la \$place"],
83 ["other", "\$names étaient allées à la \$place"], 83 ["other", "\$names étaient allées à la \$place"],
84 ], null) 84 ], null)
85 ] 85 ]
86 ], null 86 ], null
87 )) 87 )),
88 "outerPlural" : writer.write(new Plural.from("n",
89 [
90 ['zero', 'rien'],
91 ['one', 'un'],
92 ['other', 'quelques-uns']
93 ], null)),
94 "outerGender" : writer.write(new Gender.from("g",
95 [
96 ['male', 'homme'],
97 ['female', 'femme'],
98 ['other', 'autre'],
99 ], null)),
100 "nestedOuter" : writer.write ( new Plural.from("number",
101 [
102 ['other', new Gender.from("gen",
103 [["male", "\$number homme"], ["other", "\$number autre"]], null),
104 ]
105 ], null)),
88 }; 106 };
89 107
90 /** A list of the German translations that we will produce. */ 108 /** A list of the German translations that we will produce. */
91 var german = { 109 var german = {
92 "types" : r"$a, $b, $c", 110 "types" : r"$a, $b, $c",
93 "multiLine" : "Dieser String erstreckt sich über mehrere Zeilen erstrecken.", 111 "multiLine" : "Dieser String erstreckt sich über mehrere Zeilen erstrecken.",
94 "message2" : r"Eine weitere Meldung mit dem Parameter $x", 112 "message2" : r"Eine weitere Meldung mit dem Parameter $x",
95 "alwaysTranslated" : "Diese Zeichenkette wird immer übersetzt", 113 "alwaysTranslated" : "Diese Zeichenkette wird immer übersetzt",
96 "message1" : "Dies ist eine Nachricht", 114 "message1" : "Dies ist eine Nachricht",
97 "leadingQuotes" : "\"Sogenannt\"", 115 "leadingQuotes" : "\"Sogenannt\"",
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 ["other", "\${names} gingen zum \$place"], 148 ["other", "\${names} gingen zum \$place"],
131 ], null) 149 ], null)
132 ], 150 ],
133 ["female", new Plural.from("number", 151 ["female", new Plural.from("number",
134 [ 152 [
135 ["one", "\$names ging in dem \$place"], 153 ["one", "\$names ging in dem \$place"],
136 ["other", "\$names gingen zum \$place"], 154 ["other", "\$names gingen zum \$place"],
137 ], null) 155 ], null)
138 ] 156 ]
139 ], null 157 ], null
140 )) 158 )),
159 "outerPlural" : writer.write(new Plural.from("n",
160 [
161 ['zero', 'Null'],
162 ['one', 'ein'],
163 ['other', 'einige']
164 ], null)),
165 "outerGender" : writer.write(new Gender.from("g",
166 [
167 ['male', 'Mann'],
168 ['female', 'Frau'],
169 ['other', 'andere'],
170 ], null)),
171 "nestedOuter" : writer.write (new Plural.from("number",
172 [
173 ['other', new Gender.from("gen",
174 [["male", "\$number Mann"], ["other", "\$number andere"]], null),
175 ]
176 ], null)),
141 }; 177 };
142 178
143 /** The output directory for translated files. */ 179 /** The output directory for translated files. */
144 String targetDir; 180 String targetDir;
145 181
146 /** 182 /**
147 * Generate a translated json version from [originals] in [locale] looking 183 * Generate a translated json version from [originals] in [locale] looking
148 * up the translations in [translations]. 184 * up the translations in [translations].
149 */ 185 */
150 void translate(List originals, String locale, Map translations) { 186 void translate(List originals, String locale, Map translations) {
(...skipping 17 matching lines...) Expand all
168 parser.addOption("output-dir", defaultsTo: '.', 204 parser.addOption("output-dir", defaultsTo: '.',
169 callback: (value) => targetDir = value); 205 callback: (value) => targetDir = value);
170 parser.parse(args); 206 parser.parse(args);
171 207
172 var fileArgs = args.where((x) => x.contains('.json')); 208 var fileArgs = args.where((x) => x.contains('.json'));
173 209
174 var messages = json.parse(new File(fileArgs.first).readAsStringSync()); 210 var messages = json.parse(new File(fileArgs.first).readAsStringSync());
175 translate(messages, "fr", french); 211 translate(messages, "fr", french);
176 translate(messages, "de_DE", german); 212 translate(messages, "de_DE", german);
177 } 213 }
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