| 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 /// This file should be imported, along with date_format.dart in order to read |
| 6 * This file should be imported, along with date_format.dart in order to read | 6 /// locale data from files in the file system. |
| 7 * locale data from files in the file system. | |
| 8 */ | |
| 9 | 7 |
| 10 library date_symbol_data_file; | 8 library date_symbol_data_file; |
| 11 | 9 |
| 12 import 'dart:async'; | 10 import 'dart:async'; |
| 13 | 11 |
| 14 import 'package:path/path.dart' as path; | 12 import 'package:path/path.dart' as path; |
| 15 | 13 |
| 16 import 'date_symbols.dart'; | 14 import 'date_symbols.dart'; |
| 17 import 'src/data/dates/locale_list.dart'; | 15 import 'src/data/dates/locale_list.dart'; |
| 18 import 'src/date_format_internal.dart'; | 16 import 'src/date_format_internal.dart'; |
| 19 import 'src/file_data_reader.dart'; | 17 import 'src/file_data_reader.dart'; |
| 20 import 'src/lazy_locale_data.dart'; | 18 import 'src/lazy_locale_data.dart'; |
| 21 | 19 |
| 22 export 'src/data/dates/locale_list.dart'; | 20 export 'src/data/dates/locale_list.dart'; |
| 23 | 21 |
| 24 /** | 22 /// This should be called for at least one [locale] before any date formatting |
| 25 * This should be called for at least one [locale] before any date formatting | 23 /// methods are called. It sets up the lookup for date symbols using [path]. |
| 26 * methods are called. It sets up the lookup for date symbols using [path]. | 24 /// The [path] parameter should end with a directory separator appropriate |
| 27 * The [path] parameter should end with a directory separator appropriate | 25 /// for the platform. |
| 28 * for the platform. | |
| 29 */ | |
| 30 Future initializeDateFormatting(String locale, String filePath) { | 26 Future initializeDateFormatting(String locale, String filePath) { |
| 31 var reader = new FileDataReader(path.join(filePath, 'symbols')); | 27 var reader = new FileDataReader(path.join(filePath, 'symbols')); |
| 32 initializeDateSymbols(() => new LazyLocaleData( | 28 initializeDateSymbols(() => new LazyLocaleData( |
| 33 reader, _createDateSymbol, availableLocalesForDateFormatting)); | 29 reader, _createDateSymbol, availableLocalesForDateFormatting)); |
| 34 var reader2 = new FileDataReader(path.join(filePath, 'patterns')); | 30 var reader2 = new FileDataReader(path.join(filePath, 'patterns')); |
| 35 initializeDatePatterns(() => | 31 initializeDatePatterns(() => |
| 36 new LazyLocaleData(reader2, (x) => x, availableLocalesForDateFormatting)); | 32 new LazyLocaleData(reader2, (x) => x, availableLocalesForDateFormatting)); |
| 37 return initializeIndividualLocaleDateFormatting((symbols, patterns) { | 33 return initializeIndividualLocaleDateFormatting((symbols, patterns) { |
| 38 return Future | 34 return Future.wait( |
| 39 .wait([symbols.initLocale(locale), patterns.initLocale(locale)]); | 35 <Future>[symbols.initLocale(locale), patterns.initLocale(locale)]); |
| 40 }); | 36 }); |
| 41 } | 37 } |
| 42 | 38 |
| 43 /** Defines how new date symbol entries are created. */ | 39 /// Defines how new date symbol entries are created. |
| 44 DateSymbols _createDateSymbol(Map map) => | 40 DateSymbols _createDateSymbol(Map map) => |
| 45 new DateSymbols.deserializeFromMap(map); | 41 new DateSymbols.deserializeFromMap(map); |
| OLD | NEW |