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 * 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 |
7 * locale data via http requests to a web server.. | 7 * locale data via http requests to a web server.. |
8 */ | 8 */ |
9 library date_symbol_data_json; | 9 #library('date_symbol_data_json'); |
10 | 10 |
11 import "date_symbols.dart"; | 11 #import("date_symbols.dart"); |
12 import "src/lazy_locale_data.dart"; | 12 #import("src/lazy_locale_data.dart"); |
13 import 'src/date_format_internal.dart'; | 13 #import('src/date_format_internal.dart'); |
14 import 'src/http_request_data_reader.dart'; | 14 #import('src/http_request_data_reader.dart'); |
15 | 15 |
16 part "src/data/dates/localeList.dart"; | 16 #source("src/data/dates/localeList.dart"); |
17 | 17 |
18 /** | 18 /** |
19 * This should be called for at least one [locale] before any date formatting | 19 * This should be called for at least one [locale] before any date formatting |
20 * methods are called. It sets up the lookup for date symbols using [url]. | 20 * methods are called. It sets up the lookup for date symbols using [url]. |
21 * The [url] parameter should end with a "/". For example, | 21 * The [url] parameter should end with a "/". For example, |
22 * "http://localhost:8000/dates/" | 22 * "http://localhost:8000/dates/" |
23 */ | 23 */ |
24 Future initializeDateFormatting(String locale, String url) { | 24 Future initializeDateFormatting(String locale, String url) { |
25 var reader = new HTTPRequestDataReader('${url}symbols/'); | 25 var reader = new HTTPRequestDataReader('${url}symbols/'); |
26 initializeDateSymbols(() => new LazyLocaleData( | 26 initializeDateSymbols(() => new LazyLocaleData( |
27 reader, _createDateSymbol, availableLocalesForDateFormatting)); | 27 reader, _createDateSymbol, availableLocalesForDateFormatting)); |
28 var reader2 = new HTTPRequestDataReader('${url}patterns/'); | 28 var reader2 = new HTTPRequestDataReader('${url}patterns/'); |
29 initializeDatePatterns(() => new LazyLocaleData( | 29 initializeDatePatterns(() => new LazyLocaleData( |
30 reader2, (x) => x, availableLocalesForDateFormatting)); | 30 reader2, (x) => x, availableLocalesForDateFormatting)); |
31 return initializeIndividualLocaleDateFormatting( | 31 return initializeIndividualLocaleDateFormatting( |
32 (symbols, patterns) { | 32 (symbols, patterns) { |
33 return Futures.wait([ | 33 return Futures.wait([ |
34 symbols.initLocale(locale), | 34 symbols.initLocale(locale), |
35 patterns.initLocale(locale)]); | 35 patterns.initLocale(locale)]); |
36 }); | 36 }); |
37 } | 37 } |
38 | 38 |
39 /** Defines how new date symbol entries are created. */ | 39 /** Defines how new date symbol entries are created. */ |
40 DateSymbols _createDateSymbol(Map map) { | 40 DateSymbols _createDateSymbol(Map map) { |
41 return new DateSymbols.deserializeFromMap(map); | 41 return new DateSymbols.deserializeFromMap(map); |
42 } | 42 } |
OLD | NEW |