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

Unified Diff: packages/intl/test/message_extraction/part_of_sample_with_messages.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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: packages/intl/test/message_extraction/part_of_sample_with_messages.dart
diff --git a/packages/intl/test/message_extraction/part_of_sample_with_messages.dart b/packages/intl/test/message_extraction/part_of_sample_with_messages.dart
new file mode 100644
index 0000000000000000000000000000000000000000..31cddccd12257bf3d27306be795638f0bcb40217
--- /dev/null
+++ b/packages/intl/test/message_extraction/part_of_sample_with_messages.dart
@@ -0,0 +1,76 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.part of sample;
+
+part of sample;
+
+class Person {
+ String name;
+ String gender;
+ Person(this.name, this.gender);
+}
+
+class YouveGotMessages {
+
+ // A static message, rather than a standalone function.
+ static staticMessage() =>
+ Intl.message("This comes from a static method", name: 'staticMessage');
+
+ // An instance method, rather than a standalone function.
+ method() => Intl.message("This comes from a method",
+ name: 'YouveGotMessages_method', desc: 'This is a method with a '
+ 'long description which spans '
+ 'multiple lines.');
+
+ // A non-lambda, i.e. not using => syntax, and with an additional statement
+ // before the Intl.message call.
+ nonLambda() {
+ var aTrueValue = true;
+ var msg = Intl.message("This method is not a lambda", name: 'nonLambda');
+ expect(aTrueValue, isTrue,
+ reason: 'Parser should not fail with additional code.');
+ return msg;
+ }
+
+ plurals(num) => Intl.message("""${Intl.plural(num,
+ zero : 'Is zero plural?',
+ one : 'This is singular.',
+ other : 'This is plural ($num).')
+ }""", name: "plurals", args: [num], desc: "Basic plurals");
+
+ whereTheyWent(Person person, String place) =>
+ whereTheyWentMessage(person.name, person.gender, place);
+
+ whereTheyWentMessage(String name, String gender, String place) {
+ return Intl.message("${Intl.gender(gender,
+ male: '$name went to his $place',
+ female: '$name went to her $place',
+ other: '$name went to its $place')
+ }",
+ name: "whereTheyWentMessage",
+ args: [name, gender, place],
+ desc: 'A person went to some place that they own, e.g. their room');
+ }
+
+ // English doesn't do enough with genders, so this example is French.
+ nested(List people, String place) {
+ var names = people.map((x) => x.name).join(", ");
+ var number = people.length;
+ var combinedGender =
+ people.every((x) => x.gender == "female") ? "female" : "other";
+ if (number == 0) combinedGender = "other";
+
+ nestedMessage(names, number, combinedGender, place) => Intl.message(
+ '''${Intl.gender(combinedGender,
+ other: '${Intl.plural(number,
+ zero: "Personne n'est allé au $place",
+ one: "${names} est allé au $place",
+ other: "${names} sont allés au $place")}',
+ female: '${Intl.plural(number,
+ one: "$names est allée au $place",
+ other: "$names sont allées au $place")}'
+ )}''',
+ name: "nestedMessage", args: [names, number, combinedGender, place]);
+ return nestedMessage(names, number, combinedGender, place);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698