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

Commit

Permalink
fix(DateFilter): should work on other locale
Browse files Browse the repository at this point in the history
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
  • Loading branch information
technohippy authored and mhevery committed Mar 6, 2014
1 parent 710cd5b commit d7e77de
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/angular.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'dart:html' as dom;
import 'dart:js' as js;
import 'package:di/di.dart';
import 'package:di/dynamic_injector.dart';
import 'package:intl/date_symbol_data_local.dart';

/**
* If you are writing code accessed from Angular expressions, you must include
Expand Down
8 changes: 5 additions & 3 deletions lib/bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ Injector ngBootstrap({
return zone.run(() {
var rootElements = [element];
Injector injector = injectorFactory(ngModules);
var compiler = injector.get(Compiler);
var blockFactory = compiler(rootElements, injector.get(DirectiveMap));
blockFactory(injector, rootElements);
initializeDateFormatting(null, null).then((_) {
var compiler = injector.get(Compiler);
var blockFactory = compiler(rootElements, injector.get(DirectiveMap));
blockFactory(injector, rootElements);
});
return injector;
});
}
Expand Down
17 changes: 17 additions & 0 deletions test/filter/date_spec.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
library date_spec;

import '../_specs.dart';
import 'package:intl/intl.dart';

void main() {
describe('date', () {
Expand Down Expand Up @@ -64,5 +65,21 @@ void main() {
date(noon, "shortTime");
date(noon, "shortTime");
});


it('should accept various locales', () {

try {
Intl.defaultLocale = 'de';
expect(date(noon, "medium")).
toEqual('Sep 3, 2010 12:05:08 nachm.');

Intl.defaultLocale = 'fr';
expect(date(noon, "medium")).
toEqual('sept. 3, 2010 12:05:08 PM');
} finally {
Intl.defaultLocale = 'en';
}
});
});
}

0 comments on commit d7e77de

Please sign in to comment.