Skip to content

Commit bb5bc50

Browse files
feat(chapter7): chapter 7 1st draft
1 parent 6a32d0d commit bb5bc50

File tree

11 files changed

+216
-0
lines changed

11 files changed

+216
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!doctype html>
2+
<html ng-app="locale">
3+
<head>
4+
<meta charset="utf-8">
5+
<script src="../../lib/angular/1.0.2/angular.js"></script>
6+
<script src="../../lib/angular/1.0.2/angular-locale_fr-ca.js"></script>
7+
<script src="locale.js"></script>
8+
</head>
9+
<body ng-controller="LocaleCtrl">
10+
<div>
11+
Locale id: {{localeid}}
12+
</div>
13+
<div>
14+
Months: {{months}}
15+
</div>
16+
</body>
17+
</html>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
angular.module('locale', ['ngLocale'])
2+
.controller('LocaleCtrl', function ($scope, $locale) {
3+
4+
$scope.localeid = $locale.id;
5+
6+
$scope.months = $locale.DATETIME_FORMATS.MONTH;
7+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
angular.module('filters', ['ngLocale'])
2+
3+
.controller('FiltersCtrl', function ($scope) {
4+
5+
$scope.now = new Date();
6+
7+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!doctype html>
2+
<html ng-app="filters">
3+
<head>
4+
<meta charset="utf-8">
5+
<script src="../../lib/angular/1.0.2/angular.js"></script>
6+
<script src="filters.js"></script>
7+
</head>
8+
<body ng-controller="FiltersCtrl">
9+
<div>Now: {{now | date:'fullDate'}}</div>
10+
<div>100: {{100 | currency}}</div>
11+
<div>100: {{100 | currency:'EUR'}}</div>
12+
<div>1000.5: {{1000.5 | number}}</div>
13+
</body>
14+
</html>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!doctype html>
2+
<html ng-app="filters">
3+
<head>
4+
<meta charset="utf-8">
5+
<script src="../../lib/angular/1.0.2/angular.js"></script>
6+
<script src="../../lib/angular/1.0.2/angular-locale_fr-fr.js"></script>
7+
<script src="filters.js"></script>
8+
</head>
9+
<body ng-controller="FiltersCtrl">
10+
<div>Now: {{now | date:'fullDate'}}</div>
11+
<div>100: {{100 | currency}}</div>
12+
<div>100: {{1000.5 | number}}</div>
13+
</body>
14+
</html>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
angular.module('i18nmessages', [])
2+
.value('i18nmessages', {
3+
'greetings.hello': 'Hello'
4+
});
5+
6+
angular.module('i18nfilter', ['i18nmessages'])
7+
.filter('i18n', function (i18nmessages) {
8+
return function (input) {
9+
if (!angular.isString(input)) {
10+
return input;
11+
}
12+
return i18nmessages[input] || '?'+input+'?';
13+
};
14+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!doctype html>
2+
<html ng-app="i18nfilter">
3+
<head>
4+
<meta charset="utf-8">
5+
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js"></script>
6+
<script src="i18nfilter.js"></script>
7+
</head>
8+
<body ng-init="name='World'">
9+
<span>{{'greetings.hello' | i18n}}, {{name}}!</span>
10+
</body>
11+
</html>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
angular.module('filterCustomization', [])
2+
.config(function ($provide) {
3+
var customFormats = {
4+
'fr-ca': {
5+
'fullDate': 'y'
6+
}
7+
};
8+
9+
$provide.decorator('dateFilter', function ($delegate, $locale) {
10+
return function (input, format) {
11+
return $delegate(input, customFormats[$locale.id][format] || format);
12+
};
13+
});
14+
})
15+
16+
.controller('DateCtrl', function ($scope) {
17+
$scope.now = new Date();
18+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!doctype html>
2+
<html ng-app="filterCustomization">
3+
<head>
4+
<meta charset="utf-8">
5+
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js"></script>
6+
<script src="../../lib/angular/1.0.2/angular-locale_fr-ca.js"></script>
7+
<script src="filterCustomization.js"></script>
8+
</head>
9+
<body ng-controller="DateCtrl">
10+
{{now | date:'fullDate'}}
11+
</body>
12+
</html>

lib/angular/1.0.2/angular-locale_fr-ca.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)