| 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 * In order to avoid needing to import the libraries for each locale | 6 * This imports all of the different message libraries and provides an |
| 7 * individually in each program file, we make a separate library that imports | 7 * [initializeMessages] function that sets up the lookup for a particular |
| 8 * all of them. In this example there's only one program file, so it doesn't | 8 * library. |
| 9 * make very much difference. | |
| 10 */ | 9 */ |
| 11 library messages_all; | 10 library messages_all; |
| 12 | 11 |
| 12 import 'dart:async'; |
| 13 import 'package:intl/message_lookup_by_library.dart'; |
| 14 import 'package:intl/src/intl_helpers.dart'; |
| 13 import 'messages_th_th.dart' as th_TH; | 15 import 'messages_th_th.dart' as th_TH; |
| 14 import 'messages_de.dart' as de; | 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' : return th_TH.messages; |
| 23 case 'de' : return de.messages; |
| 24 default: return null; |
| 25 } |
| 26 } |
| 27 |
| 28 initializeMessages(localeName) { |
| 29 initializeInternalMessageLookup(() => new CompositeMessageLookup()); |
| 30 messageLookup.addLocale(localeName, _findGeneratedMessagesFor); |
| 31 return new Future.immediate(null); |
| 32 } |
| 33 |
| 34 MessageLookupByLibrary _findGeneratedMessagesFor(locale) { |
| 35 var actualLocale = Intl.verifiedLocale(locale, (x) => _findExact(x) != null); |
| 36 if (actualLocale == null) return null; |
| 37 return _findExact(actualLocale); |
| 38 } |
| OLD | NEW |