Chromium Code Reviews| 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 * Message/plural format library with locale support. | 6 * Message/plural format library with locale support. |
| 7 * | 7 * |
| 8 * | 8 * |
| 9 * _message example: | 9 * _message example: |
| 10 * '''I see ${intl.plural(num_people, | 10 * '''I see ${Intl.plural(num_people, |
| 11 * {'0': 'no one at all', | 11 * {'0': 'no one at all', |
| 12 * '1': 'one other person', | 12 * '1': 'one other person', |
| 13 * 'other': '$num_people other people'})} in $place.'''' | 13 * 'other': '$num_people other people'})} in $place.'''' |
| 14 * | 14 * |
| 15 * Useage example: | 15 * Usage examples: |
| 16 * msg(num_people, place) => new IntlMessage( | 16 * today(date) => intl.message( |
| 17 '''I see ${intl.plural(num_people, | 17 * "Today's date is $date", |
| 18 * desc: 'Indicate the current date', | |
| 19 * examples: {'date' : 'June 8, 2012'}); | |
|
Emily Fortuna
2012/06/08 21:50:37
I'd recommend not using a date in this example bec
Alan Knight
2012/06/08 22:04:53
I thought it was actually good to start having exa
Emily Fortuna
2012/06/08 22:09:40
Yeah, but technically, you should probably say som
Alan Knight
2012/06/08 22:14:21
But on the same basis, below I should probably wri
Emily Fortuna
2012/06/08 22:17:14
Fine. The difference being we have an API already
| |
| 20 * print(today(new Date.now()); | |
| 21 * | |
| 22 * msg(num_people, place) => intl.message( | |
| 23 * '''I see ${Intl.plural(num_people, | |
| 18 * {'0': 'no one at all', | 24 * {'0': 'no one at all', |
| 19 * '1': 'one other person', | 25 * '1': 'one other person', |
| 20 * 'other': '$num_people other people'})} in $place.'''', | 26 * 'other': '$num_people other people'})} in $place.'''', |
| 21 * desc: 'Description of how many people are seen as program start.', | 27 * desc: 'Description of how many people are seen as program start.', |
| 22 * examples: {'num_people': 3, 'place': 'London'}); | 28 * examples: {'num_people': 3, 'place': 'London'}); |
| 23 * | 29 * |
| 24 * Calling `msg({'num_people': 2, 'place': 'Athens'});` would | 30 * Calling `msg({'num_people': 2, 'place': 'Athens'});` would |
| 25 * produce "I see 2 other people in Athens." as output. | 31 * produce "I see 2 other people in Athens." as output. |
| 26 * <!-- TODO(efortuna): documentation example involving the offset parameter. | 32 * <!-- TODO(efortuna): documentation example involving the offset parameter. |
| 27 * --> | 33 * --> |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 * concatenation. | 71 * concatenation. |
| 66 */ | 72 */ |
| 67 IntlMessage(this._message, [final String desc='', final Map examples=const {}, | 73 IntlMessage(this._message, [final String desc='', final Map examples=const {}, |
| 68 final String locale='']) { | 74 final String locale='']) { |
| 69 this._messageDescription = desc; | 75 this._messageDescription = desc; |
| 70 this._messageExamples = examples; | 76 this._messageExamples = examples; |
| 71 this._languageCode = locale; | 77 this._languageCode = locale; |
| 72 } | 78 } |
| 73 | 79 |
| 74 } | 80 } |
| OLD | NEW |