| OLD | NEW |
| (Empty) | |
| 1 /** |
| 2 * Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 3 * for details. All rights reserved. Use of this source code is governed by a |
| 4 * BSD-style license that can be found in the LICENSE file. |
| 5 * |
| 6 */ |
| 7 |
| 8 #library('Intl'); |
| 9 #import('date_format.dart'); |
| 10 #import('message_format.dart'); |
| 11 |
| 12 class Intl { |
| 13 |
| 14 /** |
| 15 * As yet not clearly defined variable for holding onto our current locale, |
| 16 * which may actually be a list of locales, or have different information |
| 17 * for different aspects of internationalization (e.g. German locale but with |
| 18 * Canadian date format) |
| 19 */ |
| 20 // TODO (alanknight): Actually make this class do something with locales, |
| 21 // just a skeleton right now. |
| 22 var _locale; |
| 23 |
| 24 /** |
| 25 * Constructor |
| 26 */ |
| 27 Intl([this._locale]); |
| 28 |
| 29 /** |
| 30 * Methods to return appropriate format objects. |
| 31 */ |
| 32 DateFormat date() => new DateFormat.fullDate(); |
| 33 DateFormat time() => new DateFormat.fullTime(); |
| 34 DateFormat dateTime() => new DateFormat.fullDateTime(); |
| 35 MessageFormat message() => new MessageFormat(); |
| 36 |
| 37 /** |
| 38 * Support methods for message formatting. |
| 39 */ |
| 40 String plural(num howMany, Map actions) { |
| 41 var desiredKey = howMany.toString(); |
| 42 for (var key in actions.getKeys()) { |
| 43 if(desiredKey == key) return actions[key]; |
| 44 } |
| 45 if (actions.containsKey('other')) { |
| 46 return actions['other']; |
| 47 } else { |
| 48 return ''; |
| 49 } |
| 50 } |
| 51 |
| 52 String select(String choice, Map actions) { |
| 53 for (var key in actions.getKeys()) { |
| 54 if (choice == key) return actions[key]; |
| 55 } |
| 56 return ''; |
| 57 } |
| 58 } |
| OLD | NEW |