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

Commit

Permalink
fix(i18n): Do not transform arrays into objects
Browse files Browse the repository at this point in the history
Do not trasnform arrays into objects when generating the locale objects
Add unit test for this check
  • Loading branch information
lgalfaso authored and btford committed Aug 12, 2013
1 parent 634ac03 commit 751c77f
Show file tree
Hide file tree
Showing 247 changed files with 13,236 additions and 13,231 deletions.
5 changes: 5 additions & 0 deletions i18n/spec/closureI18nExtractorSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,5 +257,10 @@ describe("serializeContent", function() {
var serializedContent = closureI18nExtractor.serializeContent(newTestLocaleInfo());
expect((/[^\u0001-\u007f]/).test(serializedContent)).toBe(false);
});
it("should not transform arrays into objects", function() {
var serializedContent = closureI18nExtractor.serializeContent(newTestLocaleInfo().fr_CA);
var deserializedLocale = eval("(" + serializedContent + ")");
expect(deserializedLocale.DATETIME_FORMATS.MONTH.length).not.toBe(undefined);
});
});

2 changes: 1 addition & 1 deletion i18n/src/closureI18nExtractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function canonicalizeForJsonStringify(unused_key, object) {
// 2. https://code.google.com/p/v8/issues/detail?id=164
// ECMA-262 does not specify enumeration order. The de facto standard
// is to match insertion order, which V8 also does ...
if (typeof object != "object") {
if (typeof object != "object" || Object.prototype.toString.apply(object) === '[object Array]') {
return object;
}
var result = {};
Expand Down
108 changes: 54 additions & 54 deletions src/ngLocale/angular-locale_af-na.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,56 @@ angular.module("ngLocale", [], ["$provide", function($provide) {
var PLURAL_CATEGORY = {ZERO: "zero", ONE: "one", TWO: "two", FEW: "few", MANY: "many", OTHER: "other"};
$provide.value("$locale", {
"DATETIME_FORMATS": {
"AMPMS": {
"0": "vm.",
"1": "nm."
},
"DAY": {
"0": "Sondag",
"1": "Maandag",
"2": "Dinsdag",
"3": "Woensdag",
"4": "Donderdag",
"5": "Vrydag",
"6": "Saterdag"
},
"MONTH": {
"0": "Januarie",
"1": "Februarie",
"2": "Maart",
"3": "April",
"4": "Mei",
"5": "Junie",
"6": "Julie",
"7": "Augustus",
"8": "September",
"9": "Oktober",
"10": "November",
"11": "Desember"
},
"SHORTDAY": {
"0": "So",
"1": "Ma",
"2": "Di",
"3": "Wo",
"4": "Do",
"5": "Vr",
"6": "Sa"
},
"SHORTMONTH": {
"0": "Jan",
"1": "Feb",
"2": "Mar",
"3": "Apr",
"4": "Mei",
"5": "Jun",
"6": "Jul",
"7": "Aug",
"8": "Sep",
"9": "Okt",
"10": "Nov",
"11": "Des"
},
"AMPMS": [
"vm.",
"nm."
],
"DAY": [
"Sondag",
"Maandag",
"Dinsdag",
"Woensdag",
"Donderdag",
"Vrydag",
"Saterdag"
],
"MONTH": [
"Januarie",
"Februarie",
"Maart",
"April",
"Mei",
"Junie",
"Julie",
"Augustus",
"September",
"Oktober",
"November",
"Desember"
],
"SHORTDAY": [
"So",
"Ma",
"Di",
"Wo",
"Do",
"Vr",
"Sa"
],
"SHORTMONTH": [
"Jan",
"Feb",
"Mar",
"Apr",
"Mei",
"Jun",
"Jul",
"Aug",
"Sep",
"Okt",
"Nov",
"Des"
],
"fullDate": "EEEE d MMMM y",
"longDate": "d MMMM y",
"medium": "d MMM y HH:mm:ss",
Expand All @@ -65,8 +65,8 @@ $provide.value("$locale", {
"CURRENCY_SYM": "R",
"DECIMAL_SEP": ",",
"GROUP_SEP": "\u00a0",
"PATTERNS": {
"0": {
"PATTERNS": [
{
"gSize": 3,
"lgSize": 3,
"macFrac": 0,
Expand All @@ -78,7 +78,7 @@ $provide.value("$locale", {
"posPre": "",
"posSuf": ""
},
"1": {
{
"gSize": 3,
"lgSize": 3,
"macFrac": 0,
Expand All @@ -90,7 +90,7 @@ $provide.value("$locale", {
"posPre": "\u00a4",
"posSuf": ""
}
}
]
},
"id": "af-na",
"pluralCat": function (n) { if (n == 1) { return PLURAL_CATEGORY.ONE; } return PLURAL_CATEGORY.OTHER;}
Expand Down
108 changes: 54 additions & 54 deletions src/ngLocale/angular-locale_af-za.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,56 @@ angular.module("ngLocale", [], ["$provide", function($provide) {
var PLURAL_CATEGORY = {ZERO: "zero", ONE: "one", TWO: "two", FEW: "few", MANY: "many", OTHER: "other"};
$provide.value("$locale", {
"DATETIME_FORMATS": {
"AMPMS": {
"0": "vm.",
"1": "nm."
},
"DAY": {
"0": "Sondag",
"1": "Maandag",
"2": "Dinsdag",
"3": "Woensdag",
"4": "Donderdag",
"5": "Vrydag",
"6": "Saterdag"
},
"MONTH": {
"0": "Januarie",
"1": "Februarie",
"2": "Maart",
"3": "April",
"4": "Mei",
"5": "Junie",
"6": "Julie",
"7": "Augustus",
"8": "September",
"9": "Oktober",
"10": "November",
"11": "Desember"
},
"SHORTDAY": {
"0": "So",
"1": "Ma",
"2": "Di",
"3": "Wo",
"4": "Do",
"5": "Vr",
"6": "Sa"
},
"SHORTMONTH": {
"0": "Jan",
"1": "Feb",
"2": "Mar",
"3": "Apr",
"4": "Mei",
"5": "Jun",
"6": "Jul",
"7": "Aug",
"8": "Sep",
"9": "Okt",
"10": "Nov",
"11": "Des"
},
"AMPMS": [
"vm.",
"nm."
],
"DAY": [
"Sondag",
"Maandag",
"Dinsdag",
"Woensdag",
"Donderdag",
"Vrydag",
"Saterdag"
],
"MONTH": [
"Januarie",
"Februarie",
"Maart",
"April",
"Mei",
"Junie",
"Julie",
"Augustus",
"September",
"Oktober",
"November",
"Desember"
],
"SHORTDAY": [
"So",
"Ma",
"Di",
"Wo",
"Do",
"Vr",
"Sa"
],
"SHORTMONTH": [
"Jan",
"Feb",
"Mar",
"Apr",
"Mei",
"Jun",
"Jul",
"Aug",
"Sep",
"Okt",
"Nov",
"Des"
],
"fullDate": "EEEE dd MMMM y",
"longDate": "dd MMMM y",
"medium": "dd MMM y h:mm:ss a",
Expand All @@ -65,8 +65,8 @@ $provide.value("$locale", {
"CURRENCY_SYM": "R",
"DECIMAL_SEP": ",",
"GROUP_SEP": "\u00a0",
"PATTERNS": {
"0": {
"PATTERNS": [
{
"gSize": 3,
"lgSize": 3,
"macFrac": 0,
Expand All @@ -78,7 +78,7 @@ $provide.value("$locale", {
"posPre": "",
"posSuf": ""
},
"1": {
{
"gSize": 3,
"lgSize": 3,
"macFrac": 0,
Expand All @@ -90,7 +90,7 @@ $provide.value("$locale", {
"posPre": "\u00a4",
"posSuf": ""
}
}
]
},
"id": "af-za",
"pluralCat": function (n) { if (n == 1) { return PLURAL_CATEGORY.ONE; } return PLURAL_CATEGORY.OTHER;}
Expand Down
Loading

0 comments on commit 751c77f

Please sign in to comment.