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

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

Issue 22392004: Improvements to warnings on message extraction. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
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 20 matching lines...) Expand all
31 "multiple " 31 "multiple "
32 "lines.", 32 "lines.",
33 name: "multiLine"); 33 name: "multiLine");
34 34
35 // Have types on the enclosing function's arguments. 35 // Have types on the enclosing function's arguments.
36 types(int a, String b, List c) => Intl.message("$a, $b, $c", name: 'types', 36 types(int a, String b, List c) => Intl.message("$a, $b, $c", name: 'types',
37 args: [a, b, c]); 37 args: [a, b, c]);
38 38
39 // This string will be printed with a French locale, so it will always show 39 // This string will be printed with a French locale, so it will always show
40 // up in the French version, regardless of the current locale. 40 // up in the French version, regardless of the current locale.
41 alwaysAccented() => 41 alwaysTranslated() =>
42 Intl.message("This string is always translated", locale: 'fr', 42 Intl.message("This string is always translated", locale: 'fr',
43 name: 'alwaysTranslated'); 43 name: 'alwaysTranslated');
44 44
45 // Test interpolation with curly braces around the expression, but it must 45 // Test interpolation with curly braces around the expression, but it must
46 // still be just a variable reference. 46 // still be just a variable reference.
47 trickyInterpolation(s) => 47 trickyInterpolation(s) =>
48 Intl.message("Interpolation is tricky when it ends a sentence like ${s}.", 48 Intl.message("Interpolation is tricky when it ends a sentence like ${s}.",
49 name: 'trickyInterpolation', args: [s]); 49 name: 'trickyInterpolation', args: [s]);
50 50
51 leadingQuotes() => Intl.message("\"So-called\"", name: 'leadingQuotes'); 51 leadingQuotes() => Intl.message("\"So-called\"", name: 'leadingQuotes');
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 if (locale.locale == 'fr') { 94 if (locale.locale == 'fr') {
95 var badName = "thisNameIsNotInTheOriginal"; 95 var badName = "thisNameIsNotInTheOriginal";
96 var notInOriginal = Intl.message("foo", name: badName); 96 var notInOriginal = Intl.message("foo", name: badName);
97 if (notInOriginal != "foo") { 97 if (notInOriginal != "foo") {
98 throw "You shouldn't be able to introduce a new message in a translation"; 98 throw "You shouldn't be able to introduce a new message in a translation";
99 } 99 }
100 } 100 }
101 101
102 // A function that is unnamed and assigned to a variable. It's also nested 102 // A function that is unnamed and assigned to a variable. It's also nested
103 // within another function definition. 103 // within another function definition.
104 var messageVariable = (a, b, c) => Intl.message( 104 // TODO(alanknight): This is assigned a regular name now because it conflicts
105 // with validating that the name argument matches the function name. It's
106 // not clear if anonymous functions are an important use case to support.
Emily Fortuna 2013/08/06 19:31:30 I thought we explicitly said in the design doc tha
Alan Knight 2013/08/06 20:00:26 Excellent, I'd forgotten. Removed the TODO.
107 message3(a, b, c) => Intl.message(
105 "Characters that need escaping, e.g slashes \\ dollars \${ (curly braces " 108 "Characters that need escaping, e.g slashes \\ dollars \${ (curly braces "
106 "are ok) and xml reserved characters <& and quotes \" " 109 "are ok) and xml reserved characters <& and quotes \" "
107 "parameters $a, $b, and $c", 110 "parameters $a, $b, and $c",
108 name: 'message3', 111 name: 'message3',
109 args: [a, b, c]); 112 args: [a, b, c]);
113 var messageVariable = message3;
110 114
111 print("-------------------------------------------"); 115 print("-------------------------------------------");
112 print("Printing messages for ${locale.locale}"); 116 print("Printing messages for ${locale.locale}");
113 Intl.withLocale(locale.locale, () { 117 Intl.withLocale(locale.locale, () {
114 print(message1()); 118 print(message1());
115 print(message2("hello")); 119 print(message2("hello"));
116 print(messageVariable(1,2,3)); 120 print(messageVariable(1,2,3));
117 print(multiLine()); 121 print(multiLine());
118 print(types(1, "b", ["c", "d"])); 122 print(types(1, "b", ["c", "d"]));
119 print(leadingQuotes()); 123 print(leadingQuotes());
120 print(alwaysAccented()); 124 print(alwaysTranslated());
121 print(trickyInterpolation("this")); 125 print(trickyInterpolation("this"));
122 var thing = new YouveGotMessages(); 126 var thing = new YouveGotMessages();
123 print(thing.method()); 127 print(thing.method());
124 print(thing.nonLambda()); 128 print(thing.nonLambda());
125 var x = YouveGotMessages.staticMessage(); 129 var x = YouveGotMessages.staticMessage();
126 print(YouveGotMessages.staticMessage()); 130 print(YouveGotMessages.staticMessage());
127 print(notAlwaysTranslated()); 131 print(notAlwaysTranslated());
128 print(originalNotInBMP()); 132 print(originalNotInBMP());
129 print(escapable()); 133 print(escapable());
130 134
(...skipping 23 matching lines...) Expand all
154 var localeToUse = 'en_US'; 158 var localeToUse = 'en_US';
155 159
156 main() { 160 main() {
157 var fr = new Intl("fr"); 161 var fr = new Intl("fr");
158 var english = new Intl("en_US"); 162 var english = new Intl("en_US");
159 var de = new Intl("de_DE"); 163 var de = new Intl("de_DE");
160 initializeMessages(fr.locale).then((_) => printStuff(fr)); 164 initializeMessages(fr.locale).then((_) => printStuff(fr));
161 initializeMessages(de.locale).then((_) => printStuff(de)); 165 initializeMessages(de.locale).then((_) => printStuff(de));
162 printStuff(english); 166 printStuff(english);
163 } 167 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698