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

Unified Diff: pkg/intl/lib/date_symbol_data_http_request.dart

Issue 10959002: Read locales over http in the browser (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: pkg/intl/lib/date_symbol_data_http_request.dart
===================================================================
--- pkg/intl/lib/date_symbol_data_http_request.dart (revision 0)
+++ pkg/intl/lib/date_symbol_data_http_request.dart (revision 0)
@@ -0,0 +1,42 @@
+// 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 via http requests to a web server..
+ */
+#library('date_symbol_data_json');
+
+#import("date_symbols.dart");
+#import("src/lazy_locale_data.dart");
+#import('src/date_format_internal.dart');
+#import('src/http_request_data_reader.dart');
+
+#source("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 [url].
+ * The [url] parameter should end with a "/". For example,
+ * "http://localhost:8000/dates/"
+ */
+Future initializeDateFormatting(String locale, String url) {
+ var reader = new HTTPRequestDataReader('${url}symbols/');
+ initializeDateSymbols(() => new LazyLocaleData(
+ reader, _createDateSymbol, availableLocalesForDateFormatting));
+ var reader2 = new HTTPRequestDataReader('${url}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);
+}
« no previous file with comments | « no previous file | pkg/intl/lib/src/http_request_data_reader.dart » ('j') | pkg/intl/test/date_time_format_http_request_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698