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

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

Issue 165873005: Do not overwrite values on plurals/genders with the results of constant evaluation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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 // 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 // This is unremarkable in English, but the translated versions will contain 66 // This is unremarkable in English, but the translated versions will contain
67 // characters that ought to be escaped during code generation. 67 // characters that ought to be escaped during code generation.
68 escapable() => Intl.message("Escapable characters here: ", name: "escapable"); 68 escapable() => Intl.message("Escapable characters here: ", name: "escapable");
69 69
70 outerPlural(n) => Intl.plural(n, zero: 'none', one: 'one', other: 'some', 70 outerPlural(n) => Intl.plural(n, zero: 'none', one: 'one', other: 'some',
71 name: 'outerPlural', desc: 'A plural with no enclosing message', args: [n]); 71 name: 'outerPlural', desc: 'A plural with no enclosing message', args: [n]);
72 72
73 outerGender(g) => Intl.gender(g, male: 'm', female: 'f', other: 'o', 73 outerGender(g) => Intl.gender(g, male: 'm', female: 'f', other: 'o',
74 name: 'outerGender', desc: 'A gender with no enclosing message', args: [g]); 74 name: 'outerGender', desc: 'A gender with no enclosing message', args: [g]);
75 75
76 pluralThatFailsParsing(noOfThings) => Intl.plural(noOfThings,
77 one: "1 thing:",
78 other: "$noOfThings things:",
79 name: "pluralThatFailsParsing",
80 args: [noOfThings],
81 desc: "How many things are there?");
82
76 // A standalone gender message where we don't provide name or args. This should 83 // A standalone gender message where we don't provide name or args. This should
77 // be rejected by validation code. 84 // be rejected by validation code.
78 invalidOuterGender(g) => Intl.gender(g, other: 'o'); 85 invalidOuterGender(g) => Intl.gender(g, other: 'o');
79 86
80 // A general select 87 // A general select
81 outerSelect(currency, amount) => Intl.select(currency, 88 outerSelect(currency, amount) => Intl.select(currency,
82 { 89 {
83 "CDN" : "$amount Canadian dollars", 90 "CDN" : "$amount Canadian dollars",
84 "other" : "$amount some currency or other." 91 "other" : "$amount some currency or other."
85 }, 92 },
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 171
165 printOut(outerPlural(0)); 172 printOut(outerPlural(0));
166 printOut(outerPlural(1)); 173 printOut(outerPlural(1));
167 printOut(outerGender("male")); 174 printOut(outerGender("male"));
168 printOut(outerGender("female")); 175 printOut(outerGender("female"));
169 printOut(nestedOuter(7, "male")); 176 printOut(nestedOuter(7, "male"));
170 printOut(outerSelect("CDN", 7)); 177 printOut(outerSelect("CDN", 7));
171 printOut(outerSelect("EUR", 5)); 178 printOut(outerSelect("EUR", 5));
172 printOut(nestedSelect("CDN", 1)); 179 printOut(nestedSelect("CDN", 1));
173 printOut(nestedSelect("CDN", 2)); 180 printOut(nestedSelect("CDN", 2));
181 printOut(pluralThatFailsParsing(1));
182 printOut(pluralThatFailsParsing(2));
174 }); 183 });
175 } 184 }
176 185
177 var localeToUse = 'en_US'; 186 var localeToUse = 'en_US';
178 187
179 main() { 188 main() {
180 var fr = new Intl("fr"); 189 var fr = new Intl("fr");
181 var english = new Intl("en_US"); 190 var english = new Intl("en_US");
182 var de = new Intl("de_DE"); 191 var de = new Intl("de_DE");
183 // Throw in an initialize of a null locale to make sure it doesn't throw. 192 // Throw in an initialize of a null locale to make sure it doesn't throw.
184 initializeMessages(null); 193 initializeMessages(null);
185 var f1 = initializeMessages(fr.locale).then((_) => printStuff(fr)); 194 var f1 = initializeMessages(fr.locale).then((_) => printStuff(fr));
186 var f2 = initializeMessages(de.locale).then((_) => printStuff(de)); 195 var f2 = initializeMessages(de.locale).then((_) => printStuff(de));
187 printStuff(english); 196 printStuff(english);
188 return Future.wait([f1, f2]); 197 return Future.wait([f1, f2]);
189 } 198 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698