Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit d7e77de

Browse files
technohippymhevery
authored andcommitted
fix(DateFilter): should work on other locale
Now date filter work only on 'en' locale and if we set Intl.defaultLocale other locale than 'en' it caoses LocaleDataException. This patch fixes this bug. Closes #604
1 parent 710cd5b commit d7e77de

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

lib/angular.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import 'dart:html' as dom;
1414
import 'dart:js' as js;
1515
import 'package:di/di.dart';
1616
import 'package:di/dynamic_injector.dart';
17+
import 'package:intl/date_symbol_data_local.dart';
1718

1819
/**
1920
* If you are writing code accessed from Angular expressions, you must include

lib/bootstrap.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,11 @@ Injector ngBootstrap({
9191
return zone.run(() {
9292
var rootElements = [element];
9393
Injector injector = injectorFactory(ngModules);
94-
var compiler = injector.get(Compiler);
95-
var blockFactory = compiler(rootElements, injector.get(DirectiveMap));
96-
blockFactory(injector, rootElements);
94+
initializeDateFormatting(null, null).then((_) {
95+
var compiler = injector.get(Compiler);
96+
var blockFactory = compiler(rootElements, injector.get(DirectiveMap));
97+
blockFactory(injector, rootElements);
98+
});
9799
return injector;
98100
});
99101
}

test/filter/date_spec.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
library date_spec;
22

33
import '../_specs.dart';
4+
import 'package:intl/intl.dart';
45

56
void main() {
67
describe('date', () {
@@ -64,5 +65,21 @@ void main() {
6465
date(noon, "shortTime");
6566
date(noon, "shortTime");
6667
});
68+
69+
70+
it('should accept various locales', () {
71+
72+
try {
73+
Intl.defaultLocale = 'de';
74+
expect(date(noon, "medium")).
75+
toEqual('Sep 3, 2010 12:05:08 nachm.');
76+
77+
Intl.defaultLocale = 'fr';
78+
expect(date(noon, "medium")).
79+
toEqual('sept. 3, 2010 12:05:08 PM');
80+
} finally {
81+
Intl.defaultLocale = 'en';
82+
}
83+
});
6784
});
6885
}

0 commit comments

Comments
 (0)