| 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. | 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; |
| 11 | 11 |
| 12 import "package:intl/intl.dart"; | 12 import "package:intl/intl.dart"; |
| 13 import "foo_messages_all.dart"; | 13 import "foo_messages_all.dart"; |
| 14 import "print_to_list.dart"; | 14 import "print_to_list.dart"; |
| 15 import "dart:async"; | 15 import "dart:async"; |
| 16 import "package:unittest/unittest.dart"; |
| 16 | 17 |
| 17 part 'part_of_sample_with_messages.dart'; | 18 part 'part_of_sample_with_messages.dart'; |
| 18 | 19 |
| 19 message1() => Intl.message("This is a message", name: 'message1', desc: 'foo' ); | 20 message1() => Intl.message("This is a message", name: 'message1', desc: 'foo' ); |
| 20 | 21 |
| 21 message2(x) => Intl.message("Another message with parameter $x", | 22 message2(x) => Intl.message("Another message with parameter $x", |
| 22 name: 'message2', desc: 'Description 2', args: [x], examples: {'x' : 3}); | 23 name: 'message2', desc: 'Description 2', args: [x], examples: {'x' : 3}); |
| 23 | 24 |
| 24 // A string with multiple adjacent strings concatenated together, verify | 25 // A string with multiple adjacent strings concatenated together, verify |
| 25 // that the parser handles this properly. | 26 // that the parser handles this properly. |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 } | 217 } |
| 217 | 218 |
| 218 var localeToUse = 'en_US'; | 219 var localeToUse = 'en_US'; |
| 219 | 220 |
| 220 main() { | 221 main() { |
| 221 var fr = new Intl("fr"); | 222 var fr = new Intl("fr"); |
| 222 var english = new Intl("en_US"); | 223 var english = new Intl("en_US"); |
| 223 var de = new Intl("de_DE"); | 224 var de = new Intl("de_DE"); |
| 224 // Throw in an initialize of a null locale to make sure it doesn't throw. | 225 // Throw in an initialize of a null locale to make sure it doesn't throw. |
| 225 initializeMessages(null); | 226 initializeMessages(null); |
| 226 var f1 = initializeMessages(fr.locale).then((_) => printStuff(fr)); | 227 |
| 228 // Verify that a translated message isn't initially present. |
| 229 var messageInGerman = Intl.withLocale('de_DE', message1); |
| 230 test("Locales don't work before they're initialized", () |
| 231 => expect(messageInGerman, "This is a message")); |
| 232 |
| 233 var f1 = initializeMessages(fr.locale) |
| 234 // Since English has the one message which is always translated, we |
| 235 // can't print it until French is ready. |
| 236 .then((_) => printStuff(english)) |
| 237 .then((_) => printStuff(fr)); |
| 227 var f2 = initializeMessages('de-de').then((_) => printStuff(de)); | 238 var f2 = initializeMessages('de-de').then((_) => printStuff(de)); |
| 228 printStuff(english); | |
| 229 return Future.wait([f1, f2]); | 239 return Future.wait([f1, f2]); |
| 230 } | 240 } |
| OLD | NEW |