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

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

Issue 20072002: Allow Intl.plural/gender as the top-level, omitting the Intl.message wrapper and the first layer of… (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/part_of_sample_with_messages.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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 // This is invalid and should be recognized as such, because the message has 61 // This is invalid and should be recognized as such, because the message has
62 // to be a literal. Otherwise, interpolations would be outside of the function 62 // to be a literal. Otherwise, interpolations would be outside of the function
63 // scope. 63 // scope.
64 var someString = "No, it has to be a literal string"; 64 var someString = "No, it has to be a literal string";
65 noVariables() => Intl.message(someString, name: "noVariables"); 65 noVariables() => Intl.message(someString, name: "noVariables");
66 66
67 // This is unremarkable in English, but the translated versions will contain 67 // This is unremarkable in English, but the translated versions will contain
68 // characters that ought to be escaped during code generation. 68 // characters that ought to be escaped during code generation.
69 escapable() => Intl.message("Escapable characters here: ", name: "escapable"); 69 escapable() => Intl.message("Escapable characters here: ", name: "escapable");
70 70
71 outerPlural(n) => Intl.plural(n, zero: 'none', one: 'one', other: 'some',
72 name: 'outerPlural', desc: 'A plural with no enclosing message', args: [n]);
73
74 outerGender(g) => Intl.gender(g, male: 'm', female: 'f', other: 'o',
75 name: 'outerGender', desc: 'A gender with no enclosing message', args: [g]);
76
77 // A standalone gender message where we don't provide name or args. This should
78 // be rejected by validation code.
79 invalidOuterGender(g) => Intl.gender(g, other: 'o');
80
81 // A trivial nested plural/gender where both are done directly rather than
82 // in interpolations.
83 nestedOuter(number, gen) => Intl.plural(number,
84 other: Intl.gender(gen, male: "$number male", other: "$number other"),
85 name: 'nestedOuter',
86 args: [number, gen]);
87
71 printStuff(Intl locale) { 88 printStuff(Intl locale) {
72 89
73 // Use a name that's not a literal so this will get skipped. Then we have 90 // Use a name that's not a literal so this will get skipped. Then we have
74 // a name that's not in the original but we include it in the French 91 // a name that's not in the original but we include it in the French
75 // translation. Because it's not in the original it shouldn't get included 92 // translation. Because it's not in the original it shouldn't get included
76 // in the generated catalog and shouldn't get translated. 93 // in the generated catalog and shouldn't get translated.
77 if (locale.locale == 'fr') { 94 if (locale.locale == 'fr') {
78 var badName = "thisNameIsNotInTheOriginal"; 95 var badName = "thisNameIsNotInTheOriginal";
79 var notInOriginal = Intl.message("foo", name: badName); 96 var notInOriginal = Intl.message("foo", name: badName);
80 if (notInOriginal != "foo") { 97 if (notInOriginal != "foo") {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 var bob = new Person("Bob", "male"); 135 var bob = new Person("Bob", "male");
119 var cat = new Person("cat", null); 136 var cat = new Person("cat", null);
120 print(thing.whereTheyWent(alice, "house")); 137 print(thing.whereTheyWent(alice, "house"));
121 print(thing.whereTheyWent(bob, "house")); 138 print(thing.whereTheyWent(bob, "house"));
122 print(thing.whereTheyWent(cat, "litter box")); 139 print(thing.whereTheyWent(cat, "litter box"));
123 print(thing.nested([alice, bob], "magasin")); 140 print(thing.nested([alice, bob], "magasin"));
124 print(thing.nested([alice], "magasin")); 141 print(thing.nested([alice], "magasin"));
125 print(thing.nested([], "magasin")); 142 print(thing.nested([], "magasin"));
126 print(thing.nested([bob, bob], "magasin")); 143 print(thing.nested([bob, bob], "magasin"));
127 print(thing.nested([alice, alice], "magasin")); 144 print(thing.nested([alice, alice], "magasin"));
145
146 print(outerPlural(0));
147 print(outerPlural(1));
148 print(outerGender("male"));
149 print(outerGender("female"));
150 print(nestedOuter(7, "male"));
128 }); 151 });
129 } 152 }
130 153
131 var localeToUse = 'en_US'; 154 var localeToUse = 'en_US';
132 155
133 main() { 156 main() {
134 var fr = new Intl("fr"); 157 var fr = new Intl("fr");
135 var english = new Intl("en_US"); 158 var english = new Intl("en_US");
136 var de = new Intl("de_DE"); 159 var de = new Intl("de_DE");
137 initializeMessages(fr.locale).then((_) => printStuff(fr)); 160 initializeMessages(fr.locale).then((_) => printStuff(fr));
138 initializeMessages(de.locale).then((_) => printStuff(de)); 161 initializeMessages(de.locale).then((_) => printStuff(de));
139 printStuff(english); 162 printStuff(english);
140 } 163 }
OLDNEW
« no previous file with comments | « pkg/intl/test/message_extraction/part_of_sample_with_messages.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698