| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 provides a basic example of internationalization usage. It uses the | 6 * This provides a basic example of internationalization usage. It uses the |
| 7 * local variant of all the facilities, meaning that libraries with the | 7 * local variant of all the facilities, meaning that libraries with the |
| 8 * data for all the locales are directly imported by the program. More realistic | 8 * data for all the locales are directly imported by the program. More realistic |
| 9 * examples might read the data from files or over the web, which uses the | 9 * examples might read the data from files or over the web, which uses the |
| 10 * same APIs but requires different imports. | 10 * same APIs but requires different imports. |
| 11 * | 11 * |
| 12 * This defines messages for an English locale directly in the program and | 12 * This defines messages for an English locale directly in the program and |
| 13 * has separate libraries that define German and Thai messages that say more or | 13 * has separate libraries that define German and Thai messages that say more or |
| 14 * less the same thing, and prints the message with the date and time in it | 14 * less the same thing, and prints the message with the date and time in it |
| 15 * formatted appropriately for the locale. | 15 * formatted appropriately for the locale. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 #library('intl_basic_example'); | 18 #library('intl_basic_example'); |
| 19 // These can be replaced with package:intl/... references if using this in | 19 // These can be replaced with package:intl/... references if using this in |
| 20 // a separate package. | 20 // a separate package. |
| 21 // TODO(alanknight): Replace these with package: once pub works in buildbots. | 21 // TODO(alanknight): Replace these with package: once pub works in buildbots. |
| 22 #import('../../lib/date_format.dart'); | |
| 23 #import('../../lib/date_symbol_data_local.dart'); | 22 #import('../../lib/date_symbol_data_local.dart'); |
| 24 #import('../../lib/intl.dart'); | 23 #import('../../lib/intl.dart'); |
| 25 #import('../../lib/message_lookup_local.dart'); | 24 #import('../../lib/message_lookup_local.dart'); |
| 26 #import('messages_all.dart'); | 25 #import('messages_all.dart'); |
| 27 | 26 |
| 28 Function doThisWithTheOutput; | 27 Function doThisWithTheOutput; |
| 29 | 28 |
| 30 void setup(Function program, Function output) { | 29 void setup(Function program, Function output) { |
| 31 // Before we use any messages or use date formatting for a locale we must | 30 // Before we use any messages or use date formatting for a locale we must |
| 32 // call their initializtion messages, which are asynchronous, since they | 31 // call their initializtion messages, which are asynchronous, since they |
| (...skipping 26 matching lines...) Expand all Loading... |
| 59 printForLocale(aDate, th, runAt); | 58 printForLocale(aDate, th, runAt); |
| 60 } | 59 } |
| 61 | 60 |
| 62 printForLocale(aDate, intl, operation) { | 61 printForLocale(aDate, intl, operation) { |
| 63 var hmsFormat = intl.date().add_Hms(); | 62 var hmsFormat = intl.date().add_Hms(); |
| 64 var dayFormat = intl.date().add_yMMMMEEEEd(); | 63 var dayFormat = intl.date().add_yMMMMEEEEd(); |
| 65 var time = hmsFormat.format(aDate); | 64 var time = hmsFormat.format(aDate); |
| 66 var day = dayFormat.format(aDate); | 65 var day = dayFormat.format(aDate); |
| 67 Intl.withLocale(intl.locale, () { doThisWithTheOutput(operation(time,day));}); | 66 Intl.withLocale(intl.locale, () { doThisWithTheOutput(operation(time,day));}); |
| 68 } | 67 } |
| OLD | NEW |