OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file.part of sample; | 3 // BSD-style license that can be found in the LICENSE file.part of sample; |
4 | 4 |
5 part of sample; | 5 part of sample; |
6 | 6 |
7 class Person { | 7 class Person { |
8 String name; | 8 String name; |
9 String gender; | 9 String gender; |
10 Person(this.name, this.gender); | 10 Person(this.name, this.gender); |
(...skipping 26 matching lines...) Expand all Loading... |
37 whereTheyWent(Person person, String place) => | 37 whereTheyWent(Person person, String place) => |
38 whereTheyWentMessage(person.name, person.gender, place); | 38 whereTheyWentMessage(person.name, person.gender, place); |
39 | 39 |
40 whereTheyWentMessage(String name, String gender, String place) { | 40 whereTheyWentMessage(String name, String gender, String place) { |
41 return Intl.message( | 41 return Intl.message( |
42 "${Intl.gender(gender, | 42 "${Intl.gender(gender, |
43 male: '$name went to his $place', | 43 male: '$name went to his $place', |
44 female: '$name went to her $place', | 44 female: '$name went to her $place', |
45 other: '$name went to its $place') | 45 other: '$name went to its $place') |
46 }", | 46 }", |
47 name: "whereTheyWent", | 47 name: "whereTheyWentMessage", |
48 args: [name, gender, place], | 48 args: [name, gender, place], |
49 desc: 'A person went to some place that they own, e.g. their room' | 49 desc: 'A person went to some place that they own, e.g. their room' |
50 ); | 50 ); |
51 } | 51 } |
52 | 52 |
53 // English doesn't do enough with genders, so this example is French. | 53 // English doesn't do enough with genders, so this example is French. |
54 nested(List people, String place) { | 54 nested(List people, String place) { |
55 var names = people.map((x) => x.name).join(", "); | 55 var names = people.map((x) => x.name).join(", "); |
56 var number = people.length; | 56 var number = people.length; |
57 var combinedGender = people.every( | 57 var combinedGender = people.every( |
58 (x) => x.gender == "female") ? "female" : "other"; | 58 (x) => x.gender == "female") ? "female" : "other"; |
59 if (number == 0) combinedGender = "other"; | 59 if (number == 0) combinedGender = "other"; |
60 | 60 |
61 nestedMessage(names, number, combinedGender, place) => Intl.message( | 61 nestedMessage(names, number, combinedGender, place) => Intl.message( |
62 '''${Intl.gender(combinedGender, | 62 '''${Intl.gender(combinedGender, |
63 other: '${Intl.plural(number, | 63 other: '${Intl.plural(number, |
64 zero: "Personne n'est allé au $place", | 64 zero: "Personne n'est allé au $place", |
65 one: "${names} est allé au $place", | 65 one: "${names} est allé au $place", |
66 other: "${names} sont allés au $place")}', | 66 other: "${names} sont allés au $place")}', |
67 female: '${Intl.plural(number, | 67 female: '${Intl.plural(number, |
68 one: "$names est allée au $place", | 68 one: "$names est allée au $place", |
69 other: "$names sont allées au $place")}' | 69 other: "$names sont allées au $place")}' |
70 )}''', | 70 )}''', |
71 name: "nestedMessage", | 71 name: "nestedMessage", |
72 args: [names, number, combinedGender, place]); | 72 args: [names, number, combinedGender, place]); |
73 return nestedMessage(names, number, combinedGender, place); | 73 return nestedMessage(names, number, combinedGender, place); |
74 } | 74 } |
75 } | 75 } |
OLD | NEW |