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

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

Issue 13898014: Allow suppressing message extraction warnings, providing a prefix for generated files, and format w… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: More fixes Created 7 years, 8 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.
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:pathos/path.dart' as path; 15 import 'package:pathos/path.dart' as path;
16 import 'find_output_directory.dart'; 16 import 'package:args/args.dart';
17 17
18 /** A list of the French translations that we will produce. */ 18 /** A list of the French translations that we will produce. */
19 var french = { 19 var french = {
20 "types" : r"$a, $b, $c", 20 "types" : r"$a, $b, $c",
21 "multiLine" : "Cette message prend plusiers lignes.", 21 "multiLine" : "Cette message prend plusiers lignes.",
22 "message2" : r"Un autre message avec un seul paramètre $x", 22 "message2" : r"Un autre message avec un seul paramètre $x",
23 "alwaysTranslated" : "Cette chaîne est toujours traduit", 23 "alwaysTranslated" : "Cette chaîne est toujours traduit",
24 "message1" : "Il s'agit d'un message", 24 "message1" : "Il s'agit d'un message",
25 "leadingQuotes" : "\"Soi-disant\"", 25 "leadingQuotes" : "\"Soi-disant\"",
26 "trickyInterpolation" : r"L'interpolation est délicate " 26 "trickyInterpolation" : r"L'interpolation est délicate "
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 file.writeAsStringSync(json.stringify(translated)); 88 file.writeAsStringSync(json.stringify(translated));
89 } 89 }
90 90
91 main() { 91 main() {
92 var args = new Options().arguments; 92 var args = new Options().arguments;
93 if (args.length == 0) { 93 if (args.length == 0) {
94 print('Usage: generate_hardcoded_translation [--output-dir=<dir>] ' 94 print('Usage: generate_hardcoded_translation [--output-dir=<dir>] '
95 '[originalFile.dart]'); 95 '[originalFile.dart]');
96 exit(0); 96 exit(0);
97 } 97 }
98 var parser = new ArgParser();
99 parser.addOption("output-dir", defaultsTo: '.',
100 callback: (value) => targetDir = value);
101 parser.parse(args);
98 102
99 targetDir = findOutputDirectory(args);
100 var fileArgs = args.where((x) => x.contains('.json')); 103 var fileArgs = args.where((x) => x.contains('.json'));
101 104
102 var messages = json.parse(new File(fileArgs.first).readAsStringSync()); 105 var messages = json.parse(new File(fileArgs.first).readAsStringSync());
103 translate(messages, "fr", french); 106 translate(messages, "fr", french);
104 translate(messages, "de_DE", german); 107 translate(messages, "de_DE", german);
105 } 108 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698