Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit b3d7a03

Browse files
lgalfasopetebacondarwin
authored andcommitted
fix(i18n): Do not transform arrays into objects
Do not trasnform arrays into objects when generating the locale objects Add unit test for this check
1 parent ef5bc6c commit b3d7a03

File tree

247 files changed

+13236
-13231
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

247 files changed

+13236
-13231
lines changed

i18n/spec/closureI18nExtractorSpec.js

+5
Original file line numberDiff line numberDiff line change
@@ -257,5 +257,10 @@ describe("serializeContent", function() {
257257
var serializedContent = closureI18nExtractor.serializeContent(newTestLocaleInfo());
258258
expect((/[^\u0001-\u007f]/).test(serializedContent)).toBe(false);
259259
});
260+
it("should not transform arrays into objects", function() {
261+
var serializedContent = closureI18nExtractor.serializeContent(newTestLocaleInfo().fr_CA);
262+
var deserializedLocale = eval("(" + serializedContent + ")");
263+
expect(deserializedLocale.DATETIME_FORMATS.MONTH.length).not.toBe(undefined);
264+
});
260265
});
261266

i18n/src/closureI18nExtractor.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function canonicalizeForJsonStringify(unused_key, object) {
116116
// 2. https://code.google.com/p/v8/issues/detail?id=164
117117
// ECMA-262 does not specify enumeration order. The de facto standard
118118
// is to match insertion order, which V8 also does ...
119-
if (typeof object != "object") {
119+
if (typeof object != "object" || Object.prototype.toString.apply(object) === '[object Array]') {
120120
return object;
121121
}
122122
var result = {};

src/ngLocale/angular-locale_af-na.js

+54-54
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,56 @@ angular.module("ngLocale", [], ["$provide", function($provide) {
22
var PLURAL_CATEGORY = {ZERO: "zero", ONE: "one", TWO: "two", FEW: "few", MANY: "many", OTHER: "other"};
33
$provide.value("$locale", {
44
"DATETIME_FORMATS": {
5-
"AMPMS": {
6-
"0": "vm.",
7-
"1": "nm."
8-
},
9-
"DAY": {
10-
"0": "Sondag",
11-
"1": "Maandag",
12-
"2": "Dinsdag",
13-
"3": "Woensdag",
14-
"4": "Donderdag",
15-
"5": "Vrydag",
16-
"6": "Saterdag"
17-
},
18-
"MONTH": {
19-
"0": "Januarie",
20-
"1": "Februarie",
21-
"2": "Maart",
22-
"3": "April",
23-
"4": "Mei",
24-
"5": "Junie",
25-
"6": "Julie",
26-
"7": "Augustus",
27-
"8": "September",
28-
"9": "Oktober",
29-
"10": "November",
30-
"11": "Desember"
31-
},
32-
"SHORTDAY": {
33-
"0": "So",
34-
"1": "Ma",
35-
"2": "Di",
36-
"3": "Wo",
37-
"4": "Do",
38-
"5": "Vr",
39-
"6": "Sa"
40-
},
41-
"SHORTMONTH": {
42-
"0": "Jan",
43-
"1": "Feb",
44-
"2": "Mar",
45-
"3": "Apr",
46-
"4": "Mei",
47-
"5": "Jun",
48-
"6": "Jul",
49-
"7": "Aug",
50-
"8": "Sep",
51-
"9": "Okt",
52-
"10": "Nov",
53-
"11": "Des"
54-
},
5+
"AMPMS": [
6+
"vm.",
7+
"nm."
8+
],
9+
"DAY": [
10+
"Sondag",
11+
"Maandag",
12+
"Dinsdag",
13+
"Woensdag",
14+
"Donderdag",
15+
"Vrydag",
16+
"Saterdag"
17+
],
18+
"MONTH": [
19+
"Januarie",
20+
"Februarie",
21+
"Maart",
22+
"April",
23+
"Mei",
24+
"Junie",
25+
"Julie",
26+
"Augustus",
27+
"September",
28+
"Oktober",
29+
"November",
30+
"Desember"
31+
],
32+
"SHORTDAY": [
33+
"So",
34+
"Ma",
35+
"Di",
36+
"Wo",
37+
"Do",
38+
"Vr",
39+
"Sa"
40+
],
41+
"SHORTMONTH": [
42+
"Jan",
43+
"Feb",
44+
"Mar",
45+
"Apr",
46+
"Mei",
47+
"Jun",
48+
"Jul",
49+
"Aug",
50+
"Sep",
51+
"Okt",
52+
"Nov",
53+
"Des"
54+
],
5555
"fullDate": "EEEE d MMMM y",
5656
"longDate": "d MMMM y",
5757
"medium": "d MMM y HH:mm:ss",
@@ -65,8 +65,8 @@ $provide.value("$locale", {
6565
"CURRENCY_SYM": "R",
6666
"DECIMAL_SEP": ",",
6767
"GROUP_SEP": "\u00a0",
68-
"PATTERNS": {
69-
"0": {
68+
"PATTERNS": [
69+
{
7070
"gSize": 3,
7171
"lgSize": 3,
7272
"macFrac": 0,
@@ -78,7 +78,7 @@ $provide.value("$locale", {
7878
"posPre": "",
7979
"posSuf": ""
8080
},
81-
"1": {
81+
{
8282
"gSize": 3,
8383
"lgSize": 3,
8484
"macFrac": 0,
@@ -90,7 +90,7 @@ $provide.value("$locale", {
9090
"posPre": "\u00a4",
9191
"posSuf": ""
9292
}
93-
}
93+
]
9494
},
9595
"id": "af-na",
9696
"pluralCat": function (n) { if (n == 1) { return PLURAL_CATEGORY.ONE; } return PLURAL_CATEGORY.OTHER;}

src/ngLocale/angular-locale_af-za.js

+54-54
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,56 @@ angular.module("ngLocale", [], ["$provide", function($provide) {
22
var PLURAL_CATEGORY = {ZERO: "zero", ONE: "one", TWO: "two", FEW: "few", MANY: "many", OTHER: "other"};
33
$provide.value("$locale", {
44
"DATETIME_FORMATS": {
5-
"AMPMS": {
6-
"0": "vm.",
7-
"1": "nm."
8-
},
9-
"DAY": {
10-
"0": "Sondag",
11-
"1": "Maandag",
12-
"2": "Dinsdag",
13-
"3": "Woensdag",
14-
"4": "Donderdag",
15-
"5": "Vrydag",
16-
"6": "Saterdag"
17-
},
18-
"MONTH": {
19-
"0": "Januarie",
20-
"1": "Februarie",
21-
"2": "Maart",
22-
"3": "April",
23-
"4": "Mei",
24-
"5": "Junie",
25-
"6": "Julie",
26-
"7": "Augustus",
27-
"8": "September",
28-
"9": "Oktober",
29-
"10": "November",
30-
"11": "Desember"
31-
},
32-
"SHORTDAY": {
33-
"0": "So",
34-
"1": "Ma",
35-
"2": "Di",
36-
"3": "Wo",
37-
"4": "Do",
38-
"5": "Vr",
39-
"6": "Sa"
40-
},
41-
"SHORTMONTH": {
42-
"0": "Jan",
43-
"1": "Feb",
44-
"2": "Mar",
45-
"3": "Apr",
46-
"4": "Mei",
47-
"5": "Jun",
48-
"6": "Jul",
49-
"7": "Aug",
50-
"8": "Sep",
51-
"9": "Okt",
52-
"10": "Nov",
53-
"11": "Des"
54-
},
5+
"AMPMS": [
6+
"vm.",
7+
"nm."
8+
],
9+
"DAY": [
10+
"Sondag",
11+
"Maandag",
12+
"Dinsdag",
13+
"Woensdag",
14+
"Donderdag",
15+
"Vrydag",
16+
"Saterdag"
17+
],
18+
"MONTH": [
19+
"Januarie",
20+
"Februarie",
21+
"Maart",
22+
"April",
23+
"Mei",
24+
"Junie",
25+
"Julie",
26+
"Augustus",
27+
"September",
28+
"Oktober",
29+
"November",
30+
"Desember"
31+
],
32+
"SHORTDAY": [
33+
"So",
34+
"Ma",
35+
"Di",
36+
"Wo",
37+
"Do",
38+
"Vr",
39+
"Sa"
40+
],
41+
"SHORTMONTH": [
42+
"Jan",
43+
"Feb",
44+
"Mar",
45+
"Apr",
46+
"Mei",
47+
"Jun",
48+
"Jul",
49+
"Aug",
50+
"Sep",
51+
"Okt",
52+
"Nov",
53+
"Des"
54+
],
5555
"fullDate": "EEEE dd MMMM y",
5656
"longDate": "dd MMMM y",
5757
"medium": "dd MMM y h:mm:ss a",
@@ -65,8 +65,8 @@ $provide.value("$locale", {
6565
"CURRENCY_SYM": "R",
6666
"DECIMAL_SEP": ",",
6767
"GROUP_SEP": "\u00a0",
68-
"PATTERNS": {
69-
"0": {
68+
"PATTERNS": [
69+
{
7070
"gSize": 3,
7171
"lgSize": 3,
7272
"macFrac": 0,
@@ -78,7 +78,7 @@ $provide.value("$locale", {
7878
"posPre": "",
7979
"posSuf": ""
8080
},
81-
"1": {
81+
{
8282
"gSize": 3,
8383
"lgSize": 3,
8484
"macFrac": 0,
@@ -90,7 +90,7 @@ $provide.value("$locale", {
9090
"posPre": "\u00a4",
9191
"posSuf": ""
9292
}
93-
}
93+
]
9494
},
9595
"id": "af-za",
9696
"pluralCat": function (n) { if (n == 1) { return PLURAL_CATEGORY.ONE; } return PLURAL_CATEGORY.OTHER;}

0 commit comments

Comments
 (0)