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

Unified Diff: pkg/intl/test/message_extraction/make_hardcoded_translation.dart

Issue 18543009: Plurals and Genders (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: pkg/intl/test/message_extraction/make_hardcoded_translation.dart
diff --git a/pkg/intl/test/message_extraction/make_hardcoded_translation.dart b/pkg/intl/test/message_extraction/make_hardcoded_translation.dart
index f936f11e7056860d943b116eb1fd858f741fecf4..f0affe0ca0307eb96baa9614872e9ec06dd04ff2 100644
--- a/pkg/intl/test/message_extraction/make_hardcoded_translation.dart
+++ b/pkg/intl/test/message_extraction/make_hardcoded_translation.dart
@@ -14,6 +14,18 @@ import 'dart:io';
import 'dart:json' as json;
import 'package:pathos/path.dart' as path;
import 'package:args/args.dart';
+import 'package:intl/src/intl_message.dart';
+import 'package:serialization/serialization.dart';
+
+get s => new Serialization()
+ ..addRuleFor(new VariableSubstitution(0, null),
Emily Fortuna 2013/07/03 17:52:33 can we have more descriptive names than s and w he
Alan Knight 2013/07/03 18:41:07 Done.
+ constructorFields: ["index", "parent"])
+ ..addRuleFor(new LiteralString("a", null),
+ constructorFields: ["string", "parent"])
+ ..addRuleFor(new CompositeMessage([], null), constructor: "parent",
+ constructorFields: ["parent"]);
+var format = const SimpleFlatFormat();
+get w => s.newWriter(format);
/** A list of the French translations that we will produce. */
var french = {
@@ -35,13 +47,39 @@ var french = {
"notAlwaysTranslated" : "Ce manque certaines traductions",
"thisNameIsNotInTheOriginal" : "Could this lead to something malicious?",
"originalNotInBMP" : "Anciens caractùres grecs jeux du pendu: 𐅆𐅇.",
- "plural" : """Une des choses difficiles est \${Intl.plural(num,
- {
- '0' : 'la forme plurielle',
- '1' : 'la forme plurielle',
- 'other' : 'des formes plurielles'})}""",
- "namedArgs" : "La chose est, \$thing",
- "escapable" : "Escapes: \n\r\f\b\t\v."
+ "escapable" : "Escapes: \n\r\f\b\t\v.",
+ "plurals" : w.write(new Plural.from("num",
+ [
+ ["zero", "Est-ce que nulle est pluriel?"],
+ ["one", "C'est singulier"],
+ ["other", "C'est pluriel (\$num)."]
+ ], null)),
+ // TODO(alanknight): These are pretty horrible to write out manually. Provide
+ // a better way of reading/writing translations. A real format would be good.
+ "whereTheyWent" : w.write(new Gender.from("gender",
+ [
+ ["male", [0, " est allé à sa ", 2]],
+ ["female", [0, " est allée à sa ", 2]],
+ ["other", [0, " est allé à sa ", 2]]
+ ], null)),
+ // Gratuitously different translation for testing. Ignoring gender of place.
+ "nestedMessage" : w.write(new Gender.from("combinedGender",
+ [
+ ["other", new Plural.from("number",
+ [
+ ["zero", "Personne n'avait allé à la \$place"],
+ ["one", "\${names} était allé à la \$place"],
+ ["other", "\${names} étaient allés à la \$place"],
+ ], null)
+ ],
+ ["female", new Plural.from("number",
+ [
+ ["one", "\$names était allée à la \$place"],
+ ["other", "\$names étaient allées à la \$place"],
+ ], null)
+ ]
+ ], null
+ ))
};
/** A list of the German translations that we will produce. */
@@ -61,14 +99,40 @@ var german = {
"nonLambda" : "Diese Methode ist nicht eine Lambda",
"staticMessage" : "Dies ergibt sich aus einer statischen Methode",
"originalNotInBMP" : "Antike griechische GalgenmĂ€nnchen Zeichen: 𐅆𐅇",
- "plurals" : """\${Intl.plural(num,
- {
- '0' : 'Einer der knifflige Dinge ist der Plural',
- '1' : 'Einer der knifflige Dinge ist der Plural',
- 'other' : 'Zu den kniffligen Dinge Pluralformen'
- })}""",
- "namedArgs" : "Die Sache ist, \$thing",
- "escapable" : "Escapes: \n\r\f\b\t\v."
+ "escapable" : "Escapes: \n\r\f\b\t\v.",
+ "plurals" : w.write(new Plural.from("num",
+ [
+ ["zero", "Ist Null Plural?"],
+ ["one", "Dies ist einmalig"],
+ ["other", "Dies ist Plural (\$num)."]
+ ], null)),
+ // TODO(alanknight): These are pretty horrible to write out manually. Provide
+ // a better way of reading/writing translations. A real format would be good.
+ "whereTheyWent" : w.write(new Gender.from("gender",
+ [
+ ["male", [0, " ging zu seinem ", 2]],
+ ["female", [0, " ging zu ihrem ", 2]],
+ ["other", [0, " ging zu seinem ", 2]]
+ ], null)),
+ //Note that we're only using the gender of the people. The gender of the
+ //place also matters, but we're not dealing with that here.
+ "nestedMessage" : w.write(new Gender.from("combinedGender",
+ [
+ ["other", new Plural.from("number",
+ [
+ ["zero", "Niemand ging zu \$place"],
+ ["one", "\${names} ging zum \$place"],
+ ["other", "\${names} gingen zum \$place"],
+ ], null)
+ ],
+ ["female", new Plural.from("number",
+ [
+ ["one", "\$names ging in dem \$place"],
+ ["other", "\$names gingen zum \$place"],
+ ], null)
+ ]
+ ], null
+ ))
};
/** The output directory for translated files. */
@@ -92,7 +156,7 @@ main() {
var args = new Options().arguments;
if (args.length == 0) {
print('Usage: generate_hardcoded_translation [--output-dir=<dir>] '
- '[originalFile.dart]');
+ '[originalFile.json]');
exit(0);
}
var parser = new ArgParser();

Powered by Google App Engine
This is Rietveld 408576698