blob: a418a9cf87f859f9de0ea9754fb852d3a5bf9b01 [file] [log] [blame]
// 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 'dart:async';
import "date_symbols.dart";
import "src/lazy_locale_data.dart";
import 'src/date_format_internal.dart';
import 'src/file_data_reader.dart';
import 'package:path/path.dart' as path;
part "src/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 directory separator appropriate
* for the platform.
Future initializeDateFormatting(String locale, String filePath) {
var reader = new FileDataReader(path.join(filePath, 'symbols'));
initializeDateSymbols(() => new LazyLocaleData(
reader, _createDateSymbol, availableLocalesForDateFormatting));
var reader2 = new FileDataReader(path.join(filePath, 'patterns'));
initializeDatePatterns(() => new LazyLocaleData(
reader2, (x) => x, availableLocalesForDateFormatting));
return initializeIndividualLocaleDateFormatting(
(symbols, patterns) {
return Future.wait([
/** Defines how new date symbol entries are created. */
DateSymbols _createDateSymbol(Map map) {
return new DateSymbols.deserializeFromMap(map);