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 library provides internationalization and localization. This includes | 6 * This library provides internationalization and localization. This includes |
7 * message formatting and replacement, date and number formatting and parsing, | 7 * message formatting and replacement, date and number formatting and parsing, |
8 * and utilities for working with Bidirectional text. | 8 * and utilities for working with Bidirectional text. |
9 * | 9 * |
10 * For things that require locale or other data, there are multiple different | 10 * For things that require locale or other data, there are multiple different |
(...skipping 27 matching lines...) Expand all Loading... |
38 * '''I see ${Intl.plural(num_people, | 38 * '''I see ${Intl.plural(num_people, |
39 * {'0': 'no one at all', | 39 * {'0': 'no one at all', |
40 * '1': 'one other person', | 40 * '1': 'one other person', |
41 * 'other': '$num_people other people'})} in $place.'''' | 41 * 'other': '$num_people other people'})} in $place.'''' |
42 * | 42 * |
43 * Usage examples: | 43 * Usage examples: |
44 * today(date) => Intl.message( | 44 * today(date) => Intl.message( |
45 * "Today's date is $date", | 45 * "Today's date is $date", |
46 * desc: 'Indicate the current date', | 46 * desc: 'Indicate the current date', |
47 * examples: {'date' : 'June 8, 2012'}); | 47 * examples: {'date' : 'June 8, 2012'}); |
48 * print(today(new Date.now()); | 48 * print(today(new DateTime.now()); |
49 * | 49 * |
50 * msg({num_people, place}) => Intl.message( | 50 * msg({num_people, place}) => Intl.message( |
51 * '''I see ${Intl.plural(num_people, | 51 * '''I see ${Intl.plural(num_people, |
52 * {'0': 'no one at all', | 52 * {'0': 'no one at all', |
53 * '1': 'one other person', | 53 * '1': 'one other person', |
54 * 'other': '$num_people other people'})} in $place.'''', | 54 * 'other': '$num_people other people'})} in $place.'''', |
55 * desc: 'Description of how many people are seen as program start.', | 55 * desc: 'Description of how many people are seen as program start.', |
56 * examples: {'num_people': 3, 'place': 'London'}); | 56 * examples: {'num_people': 3, 'place': 'London'}); |
57 * | 57 * |
58 * Calling `msg({'num_people': 2, 'place': 'Athens'});` would | 58 * Calling `msg({'num_people': 2, 'place': 'Athens'});` would |
59 * produce "I see 2 other people in Athens." as output in the default locale. | 59 * produce "I see 2 other people in Athens." as output in the default locale. |
60 * | 60 * |
61 * To use a locale other than the default, use the `withLocale` function. | 61 * To use a locale other than the default, use the `withLocale` function. |
62 * var todayString = new DateFormat("pt_BR").format(new Date.now()); | 62 * var todayString = new DateFormat("pt_BR").format(new DateTime.now()); |
63 * print(withLocale("pt_BR", () => today(todayString)); | 63 * print(withLocale("pt_BR", () => today(todayString)); |
64 * | 64 * |
65 * See `tests/message_format_test.dart` for more examples. | 65 * See `tests/message_format_test.dart` for more examples. |
66 */ | 66 */ |
67 //TODO(efortuna): documentation example involving the offset parameter? | 67 //TODO(efortuna): documentation example involving the offset parameter? |
68 | 68 |
69 class Intl { | 69 class Intl { |
70 /** | 70 /** |
71 * String indicating the locale code with which the message is to be | 71 * String indicating the locale code with which the message is to be |
72 * formatted (such as en-CA). | 72 * formatted (such as en-CA). |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 /** | 265 /** |
266 * Accessor for the current locale. This should always == the default locale, | 266 * Accessor for the current locale. This should always == the default locale, |
267 * unless for some reason this gets called inside a message that resets the | 267 * unless for some reason this gets called inside a message that resets the |
268 * locale. | 268 * locale. |
269 */ | 269 */ |
270 static String getCurrentLocale() { | 270 static String getCurrentLocale() { |
271 if (_defaultLocale == null) _defaultLocale = systemLocale; | 271 if (_defaultLocale == null) _defaultLocale = systemLocale; |
272 return _defaultLocale; | 272 return _defaultLocale; |
273 } | 273 } |
274 } | 274 } |
OLD | NEW |