OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * This imports all of the different message libraries and provides an |
| 7 * [initializeMessages] function that sets up the lookup for a particular |
| 8 * library. |
| 9 */ |
| 10 library messages_all; |
| 11 |
| 12 import 'dart:async'; |
| 13 import 'package:intl/message_lookup_by_library.dart'; |
| 14 import 'package:intl/src/intl_helpers.dart'; |
| 15 import 'messages_th_th.dart' as th_TH; |
| 16 import 'messages_de.dart' as de; |
| 17 import 'package:intl/intl.dart'; |
| 18 |
| 19 // TODO(alanknight): Use lazy loading of the requested library. |
| 20 MessageLookupByLibrary _findExact(localeName) { |
| 21 switch (localeName) { |
| 22 case 'th_TH': |
| 23 return th_TH.messages; |
| 24 case 'de': |
| 25 return de.messages; |
| 26 default: |
| 27 return null; |
| 28 } |
| 29 } |
| 30 |
| 31 initializeMessages(localeName) { |
| 32 initializeInternalMessageLookup(() => new CompositeMessageLookup()); |
| 33 messageLookup.addLocale(localeName, _findGeneratedMessagesFor); |
| 34 return new Future.value(); |
| 35 } |
| 36 |
| 37 MessageLookupByLibrary _findGeneratedMessagesFor(locale) { |
| 38 var actualLocale = Intl.verifiedLocale(locale, (x) => _findExact(x) != null, |
| 39 onFailure: (_) => null); |
| 40 if (actualLocale == null) return null; |
| 41 return _findExact(actualLocale); |
| 42 } |
OLD | NEW |