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

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

Issue 22928010: Fix message_extraction test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « no previous file | 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 #!/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.
11 */ 11 */
12 12
13 import 'dart:io'; 13 import 'dart:io';
14 import 'dart:json' as json; 14 import 'dart:json' as json;
15 import 'package:path/path.dart' as path; 15 import 'package:path/path.dart' as path;
16 import 'package:args/args.dart'; 16 import 'package:args/args.dart';
17 import 'package:intl/src/intl_message.dart'; 17 import 'package:intl/src/intl_message.dart';
18 import 'package:serialization/serialization.dart'; 18 import 'package:serialization/serialization.dart';
19 19
20 /** 20 /**
21 * A serialization so that we can write out the more complex plural and 21 * A serialization so that we can write out the more complex plural and
22 * gender examples to JSON easily. This is a stopgap and should be replaced 22 * gender examples to JSON easily. This is a stopgap and should be replaced
23 * with a commonly used translation file format. 23 * with a commonly used translation file format.
24 */ 24 */
25 get serialization => new Serialization() 25 get serialization => new Serialization()
26 ..addRuleFor(new VariableSubstitution(0, null), 26 ..addRuleFor(new VariableSubstitution(0, null),
27 constructorFields: ["index", "parent"]) 27 constructorFields: ["index", "parent"])
28 ..addRuleFor(new LiteralString("a", null), 28 ..addRuleFor(new LiteralString("a", null),
29 constructorFields: ["string", "parent"]) 29 constructorFields: ["string", "parent"])
30 ..addRuleFor(new CompositeMessage([], null), constructor: "parent", 30 ..addRuleFor(new CompositeMessage([], null), constructor: "withParent",
31 constructorFields: ["parent"]); 31 constructorFields: ["parent"]);
32 var format = const SimpleFlatFormat(); 32 var format = const SimpleFlatFormat();
33 get writer => serialization.newWriter(format); 33 get writer => serialization.newWriter(format);
34 34
35 /** A list of the French translations that we will produce. */ 35 /** A list of the French translations that we will produce. */
36 var french = { 36 var french = {
37 "types" : r"$a, $b, $c", 37 "types" : r"$a, $b, $c",
38 "multiLine" : "Cette message prend plusiers lignes.", 38 "multiLine" : "Cette message prend plusiers lignes.",
39 "message2" : r"Un autre message avec un seul paramètre $x", 39 "message2" : r"Un autre message avec un seul paramètre $x",
40 "alwaysTranslated" : "Cette chaîne est toujours traduit", 40 "alwaysTranslated" : "Cette chaîne est toujours traduit",
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 var parser = new ArgParser(); 233 var parser = new ArgParser();
234 parser.addOption("output-dir", defaultsTo: '.', 234 parser.addOption("output-dir", defaultsTo: '.',
235 callback: (value) => targetDir = value); 235 callback: (value) => targetDir = value);
236 parser.parse(args); 236 parser.parse(args);
237 237
238 var fileArgs = args.where((x) => x.contains('.json')); 238 var fileArgs = args.where((x) => x.contains('.json'));
239 239
240 var messages = json.parse(new File(fileArgs.first).readAsStringSync()); 240 var messages = json.parse(new File(fileArgs.first).readAsStringSync());
241 translate(messages, "fr", french); 241 translate(messages, "fr", french);
242 translate(messages, "de_DE", german); 242 translate(messages, "de_DE", german);
243 } 243 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698