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

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

Issue 22286013: Add support for Intl.select (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Changes from review 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 | « pkg/intl/test/message_extraction/message_extraction_test.dart ('k') | 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 // 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * This is a program with various [Intl.message] messages. It just prints 6 * This is a program with various [Intl.message] messages. It just prints
7 * all of them, and is used for testing of message extraction, translation, 7 * all of them, and is used for testing of message extraction, translation,
8 * and code generation. 8 * and code generation.
9 */ 9 */
10 library sample; 10 library sample;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 outerPlural(n) => Intl.plural(n, zero: 'none', one: 'one', other: 'some', 68 outerPlural(n) => Intl.plural(n, zero: 'none', one: 'one', other: 'some',
69 name: 'outerPlural', desc: 'A plural with no enclosing message', args: [n]); 69 name: 'outerPlural', desc: 'A plural with no enclosing message', args: [n]);
70 70
71 outerGender(g) => Intl.gender(g, male: 'm', female: 'f', other: 'o', 71 outerGender(g) => Intl.gender(g, male: 'm', female: 'f', other: 'o',
72 name: 'outerGender', desc: 'A gender with no enclosing message', args: [g]); 72 name: 'outerGender', desc: 'A gender with no enclosing message', args: [g]);
73 73
74 // A standalone gender message where we don't provide name or args. This should 74 // A standalone gender message where we don't provide name or args. This should
75 // be rejected by validation code. 75 // be rejected by validation code.
76 invalidOuterGender(g) => Intl.gender(g, other: 'o'); 76 invalidOuterGender(g) => Intl.gender(g, other: 'o');
77 77
78 // A general select
79 outerSelect(currency, amount) => Intl.select(currency,
80 {
81 "CDN" : "$amount Canadian dollars",
82 "other" : "$amount some currency or other."
83 },
84 name: "outerSelect",
85 args: [currency, amount]);
86
87 // A select with a plural inside the expressions.
88 nestedSelect(currency, amount) => Intl.select(currency,
89 {
90 "CDN" : """${Intl.plural(amount, one: '$amount Canadian dollar',
91 other: '$amount Canadian dollars')}""",
92 "other" : "Whatever",
93 },
94 name: "nestedSelect",
95 args: [currency, amount]);
96
78 // A trivial nested plural/gender where both are done directly rather than 97 // A trivial nested plural/gender where both are done directly rather than
79 // in interpolations. 98 // in interpolations.
80 nestedOuter(number, gen) => Intl.plural(number, 99 nestedOuter(number, gen) => Intl.plural(number,
81 other: Intl.gender(gen, male: "$number male", other: "$number other"), 100 other: Intl.gender(gen, male: "$number male", other: "$number other"),
82 name: 'nestedOuter', 101 name: 'nestedOuter',
83 args: [number, gen]); 102 args: [number, gen]);
84 103
85 printStuff(Intl locale) { 104 printStuff(Intl locale) {
86 105
87 // Use a name that's not a literal so this will get skipped. Then we have 106 // Use a name that's not a literal so this will get skipped. Then we have
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 print(thing.nested([alice], "magasin")); 158 print(thing.nested([alice], "magasin"));
140 print(thing.nested([], "magasin")); 159 print(thing.nested([], "magasin"));
141 print(thing.nested([bob, bob], "magasin")); 160 print(thing.nested([bob, bob], "magasin"));
142 print(thing.nested([alice, alice], "magasin")); 161 print(thing.nested([alice, alice], "magasin"));
143 162
144 print(outerPlural(0)); 163 print(outerPlural(0));
145 print(outerPlural(1)); 164 print(outerPlural(1));
146 print(outerGender("male")); 165 print(outerGender("male"));
147 print(outerGender("female")); 166 print(outerGender("female"));
148 print(nestedOuter(7, "male")); 167 print(nestedOuter(7, "male"));
168 print(outerSelect("CDN", 7));
169 print(outerSelect("EUR", 5));
170 print(nestedSelect("CDN", 1));
171 print(nestedSelect("CDN", 2));
149 }); 172 });
150 } 173 }
151 174
152 var localeToUse = 'en_US'; 175 var localeToUse = 'en_US';
153 176
154 main() { 177 main() {
155 var fr = new Intl("fr"); 178 var fr = new Intl("fr");
156 var english = new Intl("en_US"); 179 var english = new Intl("en_US");
157 var de = new Intl("de_DE"); 180 var de = new Intl("de_DE");
158 initializeMessages(fr.locale).then((_) => printStuff(fr)); 181 initializeMessages(fr.locale).then((_) => printStuff(fr));
159 initializeMessages(de.locale).then((_) => printStuff(de)); 182 initializeMessages(de.locale).then((_) => printStuff(de));
160 printStuff(english); 183 printStuff(english);
161 } 184 }
OLDNEW
« no previous file with comments | « pkg/intl/test/message_extraction/message_extraction_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698