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

Unified Diff: pkg/intl/lib/src/intl_helpers.dart

Issue 11669013: Document date format initialization better and make it possible to use en_US dates without it (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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
« no previous file with comments | « pkg/intl/lib/src/date_format_internal.dart ('k') | pkg/intl/test/date_time_format_test_core.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/intl/lib/src/intl_helpers.dart
===================================================================
--- pkg/intl/lib/src/intl_helpers.dart (revision 16450)
+++ pkg/intl/lib/src/intl_helpers.dart (working copy)
@@ -8,20 +8,22 @@
*/
library intl_helpers;
+import '../date_symbols.dart';
/**
* This is used as a marker for a locale data map that hasn't been initialized,
- * and will throw an exception on any usage.
+ * and will throw an exception on any usage that isn't the fallback
+ * patterns/symbols provided.
*/
-class UninitializedLocaleData {
+class UninitializedLocaleData<F> {
final String message;
- const UninitializedLocaleData(this.message);
+ final F fallbackData;
+ const UninitializedLocaleData(this.message, this.fallbackData);
- operator [](String key) {
- _throwException();
- }
+ operator [](String key) =>
+ (key == 'en_US') ? fallbackData : _throwException();
List get keys => _throwException();
- bool containsKey(String key) => _throwException();
+ bool containsKey(String key) => (key == 'en_US') ? true : _throwException();
_throwException() {
throw new LocaleDataException("Locale data has not been initialized"
@@ -48,7 +50,7 @@
* implementation.
*/
var messageLookup = const
- UninitializedLocaleData('initializeMessages(<locale>)');
+ UninitializedLocaleData('initializeMessages(<locale>)', null);
/**
* Initialize the message lookup mechanism. This is for internal use only.
« no previous file with comments | « pkg/intl/lib/src/date_format_internal.dart ('k') | pkg/intl/test/date_time_format_test_core.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698