Chromium Code Reviews| Index: pkg/intl/date_symbol_data_file.dart |
| =================================================================== |
| --- pkg/intl/date_symbol_data_file.dart (revision 0) |
| +++ pkg/intl/date_symbol_data_file.dart (revision 0) |
| @@ -0,0 +1,43 @@ |
| +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +/** |
| + * This file should be imported, along with date_format.dart in order to read |
| + * locale data from files in the file system. |
| + */ |
| + |
| +#library('date_symbol_data_json'); |
| + |
| +#import("date_symbols.dart"); |
| +#import("lib/lazy_locale_data.dart"); |
| +#import('lib/date_format_internal.dart'); |
| +#import('lib/file_data_reader.dart'); |
| + |
| +#source("data/dates/localeList.dart"); |
| + |
| +/** |
| + * This should be called for at least one [locale] before any date formatting |
| + * methods are called. It sets up the lookup for date symbols using [path]. |
| + * The [path] parameter should end with a /. |
| + * For some implementations this may be a no-op. |
|
Emily Fortuna
2012/09/04 20:14:42
Explain briefly when/why would this be a no-op.
Alan Knight
2012/09/04 23:39:03
Actually, it's not true, because even for the loca
|
| + */ |
| +Future initializeDateFormatting(String locale, String path) { |
| + var reader = new FileDataReader('${path}symbols/'); |
|
Emily Fortuna
2012/09/04 20:14:42
You can use the Path separator from the Platform c
Alan Knight
2012/09/04 23:39:03
Done.
|
| + initializeDateSymbols(() => new LazyLocaleData( |
| + reader, _createDateSymbol, availableLocalesForDateFormatting)); |
| + var reader2 = new FileDataReader('${path}patterns/'); |
| + initializeDatePatterns(() => new LazyLocaleData( |
| + reader2, (x) => x, availableLocalesForDateFormatting)); |
| + return initializeIndividualLocaleDateFormatting( |
| + (symbols, patterns) { |
| + return Futures.wait([ |
| + symbols.initLocale(locale), |
| + patterns.initLocale(locale)]); |
| + }); |
| +} |
| + |
| +/** Defines how new date symbol entries are created. */ |
| +DateSymbols _createDateSymbol(Map map) { |
| + return new DateSymbols.deserializeFromMap(map); |
| +} |