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

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

Issue 23090005: Verify the locale when initializing dates over http (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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
« no previous file with comments | « no previous file | pkg/intl/test/date_time_format_http_request_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_json; 9 library date_symbol_data_json;
10 10
11 import 'dart:async'; 11 import 'dart:async';
12 import 'date_symbols.dart'; 12 import 'date_symbols.dart';
13 import 'src/lazy_locale_data.dart'; 13 import 'src/lazy_locale_data.dart';
14 import 'src/date_format_internal.dart'; 14 import 'src/date_format_internal.dart';
15 import 'src/http_request_data_reader.dart'; 15 import 'src/http_request_data_reader.dart';
16 import 'intl.dart';
16 17
17 part "src/data/dates/localeList.dart"; 18 part "src/data/dates/localeList.dart";
18 19
19 /** 20 /**
20 * This should be called for at least one [locale] before any date formatting 21 * This should be called for at least one [locale] before any date formatting
21 * methods are called. It sets up the lookup for date symbols using [url]. 22 * methods are called. It sets up the lookup for date symbols using [url].
22 * The [url] parameter should end with a "/". For example, 23 * The [url] parameter should end with a "/". For example,
23 * "http://localhost:8000/dates/" 24 * "http://localhost:8000/dates/"
24 */ 25 */
25 Future initializeDateFormatting(String locale, String url) { 26 Future initializeDateFormatting(String locale, String url) {
26 var reader = new HTTPRequestDataReader('${url}symbols/'); 27 var reader = new HTTPRequestDataReader('${url}symbols/');
27 initializeDateSymbols(() => new LazyLocaleData( 28 initializeDateSymbols(() => new LazyLocaleData(
28 reader, _createDateSymbol, availableLocalesForDateFormatting)); 29 reader, _createDateSymbol, availableLocalesForDateFormatting));
29 var reader2 = new HTTPRequestDataReader('${url}patterns/'); 30 var reader2 = new HTTPRequestDataReader('${url}patterns/');
30 initializeDatePatterns(() => new LazyLocaleData( 31 initializeDatePatterns(() => new LazyLocaleData(
31 reader2, (x) => x, availableLocalesForDateFormatting)); 32 reader2, (x) => x, availableLocalesForDateFormatting));
33 var actualLocale = Intl.verifiedLocale(locale,
34 (l) => availableLocalesForDateFormatting.contains(l));
32 return initializeIndividualLocaleDateFormatting( 35 return initializeIndividualLocaleDateFormatting(
33 (symbols, patterns) { 36 (symbols, patterns) {
34 return Future.wait([ 37 return Future.wait([
35 symbols.initLocale(locale), 38 symbols.initLocale(actualLocale),
36 patterns.initLocale(locale)]); 39 patterns.initLocale(actualLocale)]);
37 }); 40 });
38 } 41 }
39 42
40 /** Defines how new date symbol entries are created. */ 43 /** Defines how new date symbol entries are created. */
41 DateSymbols _createDateSymbol(Map map) { 44 DateSymbols _createDateSymbol(Map map) {
42 return new DateSymbols.deserializeFromMap(map); 45 return new DateSymbols.deserializeFromMap(map);
43 } 46 }
OLDNEW
« no previous file with comments | « no previous file | pkg/intl/test/date_time_format_http_request_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698