Skip to content

Commit 341b55d

Browse files
committed
localization with angular
1 parent 5673f19 commit 341b55d

8 files changed

Lines changed: 279 additions & 8 deletions

File tree

src/Modules/SimplCommerce.Module.Catalog/wwwroot/admin/product/product-list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ <h2>Product List</h2>
3434
<td><span ng-if="product.hasOptions" class="glyphicon glyphicon-ok"></span></td>
3535
<td><span ng-if="product.isVisibleIndividually" class="glyphicon glyphicon-ok"></span></td>
3636
<td><span ng-if="product.isPublished" class="glyphicon glyphicon-ok"></span></td>
37-
<td>{{product.createdOn}}</td>
37+
<td>{{product.createdOn | date:'medium' }}</td>
3838
<td>
3939
<button ng-if="product.isPublished" title="Un Publish" ng-click="vm.changeStatus(product)" class="btn btn-primary btn-xs"> <span class="glyphicon glyphicon-pause"></span></button>
4040
<button ng-if="!product.isPublished" title="Publish" ng-click="vm.changeStatus(product)" class="btn btn-primary btn-xs"> <span class="glyphicon glyphicon-play"></span></button>

src/Modules/SimplCommerce.Module.Core/Views/HomeAdmin/Index.cshtml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
@using Microsoft.AspNetCore.Identity
1+
@using System.Globalization
2+
@using Microsoft.AspNetCore.Identity
23
@using SimplCommerce.Module.Core.Models
4+
35
@inject UserManager<User> UserManager
46

57
@{
@@ -48,6 +50,7 @@
4850
<script src="~/lib/angular-summernote/angular-summernote.js"></script>
4951
<script src="~/lib/toastr/toastr.js"></script>
5052
<script src="~/lib/bootbox/bootbox.js"></script>
53+
<script src="~/lib/i18n/angular-locale_@(CultureInfo.CurrentCulture.Name.ToLower()).js"></script>
5154

5255
<script src="~/admin/admin-app.js"></script>
5356
<script src="~/admin/common/common.js"></script>

src/Modules/SimplCommerce.Module.Core/wwwroot/admin/user/user-list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ <h2>{{ ::vm.translate.get('User List')}}</h2>
2727
<tr ng-repeat="user in vm.users">
2828
<td>{{user.email}}</td>
2929
<td>{{user.fullName}}</td>
30-
<td>{{user.createdOn}}</td>
30+
<td>{{user.createdOn | date:'medium' }}</td>
3131
<td></td>
3232
</tr>
3333
</tbody>

src/Modules/SimplCommerce.Module.Core/wwwroot/admin/widget/widget-instance-list.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ <h2>Widget Instance List</h2>
3434
<td>{{instance.name}}</td>
3535
<td>{{instance.widgetType}}</td>
3636
<td>{{instance.widgetZone}}</td>
37-
<td>{{instance.publishStart}}</td>
38-
<td>{{instance.publishEnd}}</td>
37+
<td>{{instance.publishStart | date:'medium'}}</td>
38+
<td>{{instance.publishEnd | date:'medium'}}</td>
3939
<td>
4040
<a ui-sref="{{instance.editUrl}}({id: instance.id})" title="Edit" class="btn btn-primary btn-xs"> <span class="glyphicon glyphicon-pencil"></span></a>
4141
<button ng-click="vm.deleteWidgetInstance(instance)" class="btn btn-danger btn-xs delete"> <span class="glyphicon glyphicon-remove"></span></button>

src/Modules/SimplCommerce.Module.Orders/Controllers/OrderApiController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public ActionResult List([FromBody] SmartTableParam param)
3737
{
3838
Id = order.Id,
3939
CustomerName = order.CreatedBy.FullName,
40-
SubTotal = order.SubTotal.ToString("C"),
40+
SubTotal = order.SubTotal,
4141
OrderStatus = order.OrderStatus.ToString(),
4242
CreatedOn = order.CreatedOn
4343
});

src/Modules/SimplCommerce.Module.Orders/wwwroot/admin/order/order-list.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ <h2>Order List</h2>
2626
<td>{{order.orderStatus}}</td>
2727
<td></td>
2828
<td>{{order.customerName}}</td>
29-
<td>{{order.createdOn}}</td>
30-
<td>{{order.subTotal}}</td>
29+
<td>{{order.createdOn | date:'medium'}}</td>
30+
<td>{{order.subTotal | currency }}</td>
3131
<td><a ui-sref="order-detail({id: order.id})" title="View" class="btn btn-primary btn-xs"> <span class="glyphicon glyphicon-eye-open"></span></a></td>
3232
</tr>
3333
</tbody>
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
'use strict';
2+
angular.module("ngLocale", [], ["$provide", function ($provide) {
3+
var PLURAL_CATEGORY = { ZERO: "zero", ONE: "one", TWO: "two", FEW: "few", MANY: "many", OTHER: "other" };
4+
function getDecimals(n) {
5+
n = n + '';
6+
var i = n.indexOf('.');
7+
return (i == -1) ? 0 : n.length - i - 1;
8+
}
9+
10+
function getVF(n, opt_precision) {
11+
var v = opt_precision;
12+
13+
if (undefined === v) {
14+
v = Math.min(getDecimals(n), 3);
15+
}
16+
17+
var base = Math.pow(10, v);
18+
var f = ((n * base) | 0) % base;
19+
return { v: v, f: f };
20+
}
21+
22+
$provide.value("$locale", {
23+
"DATETIME_FORMATS": {
24+
"AMPMS": [
25+
"AM",
26+
"PM"
27+
],
28+
"DAY": [
29+
"Sunday",
30+
"Monday",
31+
"Tuesday",
32+
"Wednesday",
33+
"Thursday",
34+
"Friday",
35+
"Saturday"
36+
],
37+
"ERANAMES": [
38+
"Before Christ",
39+
"Anno Domini"
40+
],
41+
"ERAS": [
42+
"BC",
43+
"AD"
44+
],
45+
"FIRSTDAYOFWEEK": 6,
46+
"MONTH": [
47+
"January",
48+
"February",
49+
"March",
50+
"April",
51+
"May",
52+
"June",
53+
"July",
54+
"August",
55+
"September",
56+
"October",
57+
"November",
58+
"December"
59+
],
60+
"SHORTDAY": [
61+
"Sun",
62+
"Mon",
63+
"Tue",
64+
"Wed",
65+
"Thu",
66+
"Fri",
67+
"Sat"
68+
],
69+
"SHORTMONTH": [
70+
"Jan",
71+
"Feb",
72+
"Mar",
73+
"Apr",
74+
"May",
75+
"Jun",
76+
"Jul",
77+
"Aug",
78+
"Sep",
79+
"Oct",
80+
"Nov",
81+
"Dec"
82+
],
83+
"STANDALONEMONTH": [
84+
"January",
85+
"February",
86+
"March",
87+
"April",
88+
"May",
89+
"June",
90+
"July",
91+
"August",
92+
"September",
93+
"October",
94+
"November",
95+
"December"
96+
],
97+
"WEEKENDRANGE": [
98+
5,
99+
6
100+
],
101+
"fullDate": "EEEE, MMMM d, y",
102+
"longDate": "MMMM d, y",
103+
"medium": "MMM d, y h:mm:ss a",
104+
"mediumDate": "MMM d, y",
105+
"mediumTime": "h:mm:ss a",
106+
"short": "M/d/yy h:mm a",
107+
"shortDate": "M/d/yy",
108+
"shortTime": "h:mm a"
109+
},
110+
"NUMBER_FORMATS": {
111+
"CURRENCY_SYM": "$",
112+
"DECIMAL_SEP": ".",
113+
"GROUP_SEP": ",",
114+
"PATTERNS": [
115+
{
116+
"gSize": 3,
117+
"lgSize": 3,
118+
"maxFrac": 3,
119+
"minFrac": 0,
120+
"minInt": 1,
121+
"negPre": "-",
122+
"negSuf": "",
123+
"posPre": "",
124+
"posSuf": ""
125+
},
126+
{
127+
"gSize": 3,
128+
"lgSize": 3,
129+
"maxFrac": 2,
130+
"minFrac": 2,
131+
"minInt": 1,
132+
"negPre": "-\u00a4",
133+
"negSuf": "",
134+
"posPre": "\u00a4",
135+
"posSuf": ""
136+
}
137+
]
138+
},
139+
"id": "en-us",
140+
"localeID": "en_US",
141+
"pluralCat": function (n, opt_precision) { var i = n | 0; var vf = getVF(n, opt_precision); if (i == 1 && vf.v == 0) { return PLURAL_CATEGORY.ONE; } return PLURAL_CATEGORY.OTHER; }
142+
});
143+
}]);
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
'use strict';
2+
angular.module("ngLocale", [], ["$provide", function ($provide) {
3+
var PLURAL_CATEGORY = { ZERO: "zero", ONE: "one", TWO: "two", FEW: "few", MANY: "many", OTHER: "other" };
4+
$provide.value("$locale", {
5+
"DATETIME_FORMATS": {
6+
"AMPMS": [
7+
"SA",
8+
"CH"
9+
],
10+
"DAY": [
11+
"Ch\u1ee7 Nh\u1eadt",
12+
"Th\u1ee9 Hai",
13+
"Th\u1ee9 Ba",
14+
"Th\u1ee9 T\u01b0",
15+
"Th\u1ee9 N\u0103m",
16+
"Th\u1ee9 S\u00e1u",
17+
"Th\u1ee9 B\u1ea3y"
18+
],
19+
"ERANAMES": [
20+
"tr. CN",
21+
"sau CN"
22+
],
23+
"ERAS": [
24+
"tr. CN",
25+
"sau CN"
26+
],
27+
"FIRSTDAYOFWEEK": 0,
28+
"MONTH": [
29+
"th\u00e1ng 1",
30+
"th\u00e1ng 2",
31+
"th\u00e1ng 3",
32+
"th\u00e1ng 4",
33+
"th\u00e1ng 5",
34+
"th\u00e1ng 6",
35+
"th\u00e1ng 7",
36+
"th\u00e1ng 8",
37+
"th\u00e1ng 9",
38+
"th\u00e1ng 10",
39+
"th\u00e1ng 11",
40+
"th\u00e1ng 12"
41+
],
42+
"SHORTDAY": [
43+
"CN",
44+
"Th 2",
45+
"Th 3",
46+
"Th 4",
47+
"Th 5",
48+
"Th 6",
49+
"Th 7"
50+
],
51+
"SHORTMONTH": [
52+
"thg 1",
53+
"thg 2",
54+
"thg 3",
55+
"thg 4",
56+
"thg 5",
57+
"thg 6",
58+
"thg 7",
59+
"thg 8",
60+
"thg 9",
61+
"thg 10",
62+
"thg 11",
63+
"thg 12"
64+
],
65+
"STANDALONEMONTH": [
66+
"Th\u00e1ng 1",
67+
"Th\u00e1ng 2",
68+
"Th\u00e1ng 3",
69+
"Th\u00e1ng 4",
70+
"Th\u00e1ng 5",
71+
"Th\u00e1ng 6",
72+
"Th\u00e1ng 7",
73+
"Th\u00e1ng 8",
74+
"Th\u00e1ng 9",
75+
"Th\u00e1ng 10",
76+
"Th\u00e1ng 11",
77+
"Th\u00e1ng 12"
78+
],
79+
"WEEKENDRANGE": [
80+
5,
81+
6
82+
],
83+
"fullDate": "EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y",
84+
"longDate": "'Ng\u00e0y' dd 'th\u00e1ng' MM 'n\u0103m' y",
85+
"medium": "d MMM, y HH:mm:ss",
86+
"mediumDate": "d MMM, y",
87+
"mediumTime": "HH:mm:ss",
88+
"short": "dd/MM/y HH:mm",
89+
"shortDate": "dd/MM/y",
90+
"shortTime": "HH:mm"
91+
},
92+
"NUMBER_FORMATS": {
93+
"CURRENCY_SYM": "\u20ab",
94+
"DECIMAL_SEP": ",",
95+
"GROUP_SEP": ".",
96+
"PATTERNS": [
97+
{
98+
"gSize": 3,
99+
"lgSize": 3,
100+
"maxFrac": 3,
101+
"minFrac": 0,
102+
"minInt": 1,
103+
"negPre": "-",
104+
"negSuf": "",
105+
"posPre": "",
106+
"posSuf": ""
107+
},
108+
{
109+
"gSize": 3,
110+
"lgSize": 3,
111+
"maxFrac": 2,
112+
"minFrac": 2,
113+
"minInt": 1,
114+
"negPre": "-\u00a4\u00a0",
115+
"negSuf": "",
116+
"posPre": "\u00a4\u00a0",
117+
"posSuf": ""
118+
}
119+
]
120+
},
121+
"id": "vi-vn",
122+
"localeID": "vi_VN",
123+
"pluralCat": function (n, opt_precision) { return PLURAL_CATEGORY.OTHER; }
124+
});
125+
}]);

0 commit comments

Comments
 (0)