Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: pkg/intl/lib/date_symbol_data_http_request.dart

Issue 245783004: pkg/intl: turned part into library (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_http_request; 9 library date_symbol_data_http_request;
10 10
11 import 'dart:async'; 11 import 'dart:async';
12
12 import 'date_symbols.dart'; 13 import 'date_symbols.dart';
13 import 'src/lazy_locale_data.dart'; 14 import 'intl.dart';
15 import 'src/data/dates/locale_list.dart';
14 import 'src/date_format_internal.dart'; 16 import 'src/date_format_internal.dart';
15 import 'src/http_request_data_reader.dart'; 17 import 'src/http_request_data_reader.dart';
16 import 'intl.dart'; 18 import 'src/lazy_locale_data.dart';
17 19
18 part "src/data/dates/localeList.dart"; 20 export 'src/data/dates/locale_list.dart';
19 21
20 /** 22 /**
21 * This should be called for at least one [locale] before any date formatting 23 * This should be called for at least one [locale] before any date formatting
22 * methods are called. It sets up the lookup for date symbols using [url]. 24 * methods are called. It sets up the lookup for date symbols using [url].
23 * The [url] parameter should end with a "/". For example, 25 * The [url] parameter should end with a "/". For example,
24 * "http://localhost:8000/dates/" 26 * "http://localhost:8000/dates/"
25 */ 27 */
26 Future initializeDateFormatting(String locale, String url) { 28 Future initializeDateFormatting(String locale, String url) {
27 var reader = new HTTPRequestDataReader('${url}symbols/'); 29 var reader = new HTTPRequestDataReader('${url}symbols/');
28 initializeDateSymbols(() => new LazyLocaleData( 30 initializeDateSymbols(() => new LazyLocaleData(
29 reader, _createDateSymbol, availableLocalesForDateFormatting)); 31 reader, _createDateSymbol, availableLocalesForDateFormatting));
30 var reader2 = new HTTPRequestDataReader('${url}patterns/'); 32 var reader2 = new HTTPRequestDataReader('${url}patterns/');
31 initializeDatePatterns(() => new LazyLocaleData( 33 initializeDatePatterns(() => new LazyLocaleData(
32 reader2, (x) => x, availableLocalesForDateFormatting)); 34 reader2, (x) => x, availableLocalesForDateFormatting));
33 var actualLocale = Intl.verifiedLocale(locale, 35 var actualLocale = Intl.verifiedLocale(locale,
34 (l) => availableLocalesForDateFormatting.contains(l)); 36 (l) => availableLocalesForDateFormatting.contains(l));
35 return initializeIndividualLocaleDateFormatting( 37 return initializeIndividualLocaleDateFormatting(
36 (symbols, patterns) { 38 (symbols, patterns) {
37 return Future.wait([ 39 return Future.wait([
38 symbols.initLocale(actualLocale), 40 symbols.initLocale(actualLocale),
39 patterns.initLocale(actualLocale)]); 41 patterns.initLocale(actualLocale)]);
40 }); 42 });
41 } 43 }
42 44
43 /** Defines how new date symbol entries are created. */ 45 /** Defines how new date symbol entries are created. */
44 DateSymbols _createDateSymbol(Map map) => 46 DateSymbols _createDateSymbol(Map map) =>
45 new DateSymbols.deserializeFromMap(map); 47 new DateSymbols.deserializeFromMap(map);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698