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

Commit

Permalink
fix(i18n): escape all chars above \u007f in locale files
Browse files Browse the repository at this point in the history
Modify the script that writes the locales so all characters above \u007f are escaped
Includes the updated locale files after running the closureI18nExtractor.

Closes #2417
  • Loading branch information
petebacondarwin committed Apr 17, 2013
1 parent 363e4cb commit 695c54c
Show file tree
Hide file tree
Showing 250 changed files with 4,601 additions and 4,585 deletions.
11 changes: 11 additions & 0 deletions i18n/spec/closureI18nExtractorSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,14 @@ describe("pluralExtractor", function() {
})
});

describe("serializeContent", function() {
it("should not make any modifications to the content of the locale", function() {
var serializedContent = closureI18nExtractor.serializeContent(newTestLocaleInfo());
expect(eval("(" + serializedContent + ")")).toEqual(newTestLocaleInfo());
});
it("should only have ascii characters", function() {
var serializedContent = closureI18nExtractor.serializeContent(newTestLocaleInfo());
expect((/[^\u0001-\u007f]/).test(serializedContent)).toBe(false);
});
});

11 changes: 8 additions & 3 deletions i18n/src/closureI18nExtractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ exports.pluralExtractor = pluralExtractor;
exports.outputLocale = outputLocale;
exports.correctedLocaleId = correctedLocaleId;
exports.findLocaleId = findLocaleId;
exports.serializeContent = serializeContent;

var goog = { provide: function() {},
require: function() {},
Expand Down Expand Up @@ -125,6 +126,12 @@ function canonicalizeForJsonStringify(unused_key, object) {
return result;
}

function serializeContent(localeObj) {
return JSON.stringify(localeObj, canonicalizeForJsonStringify, ' ')
.replace(new RegExp('[\\u007f-\\uffff]', 'g'), function(c) { return '\\u'+('0000'+c.charCodeAt(0).toString(16)).slice(-4); })
.replace(/"@@|@@"/g, '');
}

function outputLocale(localeInfo, localeID) {
var fallBackID = localeID.match(/[A-Za-z]+/)[0],
localeObj = localeInfo[localeID],
Expand Down Expand Up @@ -167,9 +174,7 @@ function outputLocale(localeInfo, localeID) {
id: localeObj.id
};

var content = JSON.stringify(localeInfo[localeID], canonicalizeForJsonStringify, ' ')
.replace(//g, '\\u00A4')
.replace(/"@@|@@"/g, '');
var content = serializeContent(localeInfo[localeID]);

return prefix + content + suffix;
}
6 changes: 3 additions & 3 deletions src/ngLocale/angular-locale_af-na.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "R",
"DECIMAL_SEP": ",",
"GROUP_SEP": " ",
"GROUP_SEP": "\u00a0",
"PATTERNS": {
"0": {
"gSize": 3,
Expand All @@ -85,9 +85,9 @@ $provide.value("$locale", {
"maxFrac": 2,
"minFrac": 2,
"minInt": 1,
"negPre": "(\u00A4",
"negPre": "(\u00a4",
"negSuf": ")",
"posPre": "\u00A4",
"posPre": "\u00a4",
"posSuf": ""
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/ngLocale/angular-locale_af-za.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "R",
"DECIMAL_SEP": ",",
"GROUP_SEP": " ",
"GROUP_SEP": "\u00a0",
"PATTERNS": {
"0": {
"gSize": 3,
Expand All @@ -85,9 +85,9 @@ $provide.value("$locale", {
"maxFrac": 2,
"minFrac": 2,
"minInt": 1,
"negPre": "(\u00A4",
"negPre": "(\u00a4",
"negSuf": ")",
"posPre": "\u00A4",
"posPre": "\u00a4",
"posSuf": ""
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/ngLocale/angular-locale_af.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "R",
"DECIMAL_SEP": ",",
"GROUP_SEP": " ",
"GROUP_SEP": "\u00a0",
"PATTERNS": {
"0": {
"gSize": 3,
Expand All @@ -85,9 +85,9 @@ $provide.value("$locale", {
"maxFrac": 2,
"minFrac": 2,
"minInt": 1,
"negPre": "(\u00A4",
"negPre": "(\u00a4",
"negSuf": ")",
"posPre": "\u00A4",
"posPre": "\u00a4",
"posSuf": ""
}
}
Expand Down
84 changes: 42 additions & 42 deletions src/ngLocale/angular-locale_am-et.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,54 @@ var PLURAL_CATEGORY = {ZERO: "zero", ONE: "one", TWO: "two", FEW: "few", MANY: "
$provide.value("$locale", {
"DATETIME_FORMATS": {
"AMPMS": {
"0": "ጡዋት",
"1": "ከሳዓት"
"0": "\u1321\u12cb\u1275",
"1": "\u12a8\u1233\u12d3\u1275"
},
"DAY": {
"0": "እሑድ",
"1": "ሰኞ",
"2": "ማክሰኞ",
"3": "ረቡዕ",
"4": "ሐሙስ",
"5": "ዓርብ",
"6": "ቅዳሜ"
"0": "\u12a5\u1211\u12f5",
"1": "\u1230\u129e",
"2": "\u121b\u12ad\u1230\u129e",
"3": "\u1228\u1261\u12d5",
"4": "\u1210\u1219\u1235",
"5": "\u12d3\u122d\u1265",
"6": "\u1245\u12f3\u121c"
},
"MONTH": {
"0": "ጃንዩወሪ",
"1": "ፌብሩወሪ",
"2": "ማርች",
"3": "ኤፕረል",
"4": "ሜይ",
"5": "ጁን",
"6": "ጁላይ",
"7": "ኦገስት",
"8": "ሴፕቴምበር",
"9": "ኦክተውበር",
"10": "ኖቬምበር",
"11": "ዲሴምበር"
"0": "\u1303\u1295\u12e9\u12c8\u122a",
"1": "\u134c\u1265\u1229\u12c8\u122a",
"2": "\u121b\u122d\u127d",
"3": "\u12a4\u1355\u1228\u120d",
"4": "\u121c\u12ed",
"5": "\u1301\u1295",
"6": "\u1301\u120b\u12ed",
"7": "\u12a6\u1308\u1235\u1275",
"8": "\u1234\u1355\u1274\u121d\u1260\u122d",
"9": "\u12a6\u12ad\u1270\u12cd\u1260\u122d",
"10": "\u1296\u126c\u121d\u1260\u122d",
"11": "\u12f2\u1234\u121d\u1260\u122d"
},
"SHORTDAY": {
"0": "እሑድ",
"1": "ሰኞ",
"2": "ማክሰ",
"3": "ረቡዕ",
"4": "ሐሙስ",
"5": "ዓርብ",
"6": "ቅዳሜ"
"0": "\u12a5\u1211\u12f5",
"1": "\u1230\u129e",
"2": "\u121b\u12ad\u1230",
"3": "\u1228\u1261\u12d5",
"4": "\u1210\u1219\u1235",
"5": "\u12d3\u122d\u1265",
"6": "\u1245\u12f3\u121c"
},
"SHORTMONTH": {
"0": "ጃንዩ",
"1": "ፌብሩ",
"2": "ማርች",
"3": "ኤፕረ",
"4": "ሜይ",
"5": "ጁን",
"6": "ጁላይ",
"7": "ኦገስ",
"8": "ሴፕቴ",
"9": "ኦክተ",
"10": "ኖቬም",
"11": "ዲሴም"
"0": "\u1303\u1295\u12e9",
"1": "\u134c\u1265\u1229",
"2": "\u121b\u122d\u127d",
"3": "\u12a4\u1355\u1228",
"4": "\u121c\u12ed",
"5": "\u1301\u1295",
"6": "\u1301\u120b\u12ed",
"7": "\u12a6\u1308\u1235",
"8": "\u1234\u1355\u1274",
"9": "\u12a6\u12ad\u1270",
"10": "\u1296\u126c\u121d",
"11": "\u12f2\u1234\u121d"
},
"fullDate": "EEEE, d MMMM y",
"longDate": "d MMMM y",
Expand Down Expand Up @@ -85,9 +85,9 @@ $provide.value("$locale", {
"maxFrac": 2,
"minFrac": 2,
"minInt": 1,
"negPre": "(\u00A4",
"negPre": "(\u00a4",
"negSuf": ")",
"posPre": "\u00A4",
"posPre": "\u00a4",
"posSuf": ""
}
}
Expand Down
84 changes: 42 additions & 42 deletions src/ngLocale/angular-locale_am.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,54 @@ var PLURAL_CATEGORY = {ZERO: "zero", ONE: "one", TWO: "two", FEW: "few", MANY: "
$provide.value("$locale", {
"DATETIME_FORMATS": {
"AMPMS": {
"0": "ጡዋት",
"1": "ከሳዓት"
"0": "\u1321\u12cb\u1275",
"1": "\u12a8\u1233\u12d3\u1275"
},
"DAY": {
"0": "እሑድ",
"1": "ሰኞ",
"2": "ማክሰኞ",
"3": "ረቡዕ",
"4": "ሐሙስ",
"5": "ዓርብ",
"6": "ቅዳሜ"
"0": "\u12a5\u1211\u12f5",
"1": "\u1230\u129e",
"2": "\u121b\u12ad\u1230\u129e",
"3": "\u1228\u1261\u12d5",
"4": "\u1210\u1219\u1235",
"5": "\u12d3\u122d\u1265",
"6": "\u1245\u12f3\u121c"
},
"MONTH": {
"0": "ጃንዩወሪ",
"1": "ፌብሩወሪ",
"2": "ማርች",
"3": "ኤፕረል",
"4": "ሜይ",
"5": "ጁን",
"6": "ጁላይ",
"7": "ኦገስት",
"8": "ሴፕቴምበር",
"9": "ኦክተውበር",
"10": "ኖቬምበር",
"11": "ዲሴምበር"
"0": "\u1303\u1295\u12e9\u12c8\u122a",
"1": "\u134c\u1265\u1229\u12c8\u122a",
"2": "\u121b\u122d\u127d",
"3": "\u12a4\u1355\u1228\u120d",
"4": "\u121c\u12ed",
"5": "\u1301\u1295",
"6": "\u1301\u120b\u12ed",
"7": "\u12a6\u1308\u1235\u1275",
"8": "\u1234\u1355\u1274\u121d\u1260\u122d",
"9": "\u12a6\u12ad\u1270\u12cd\u1260\u122d",
"10": "\u1296\u126c\u121d\u1260\u122d",
"11": "\u12f2\u1234\u121d\u1260\u122d"
},
"SHORTDAY": {
"0": "እሑድ",
"1": "ሰኞ",
"2": "ማክሰ",
"3": "ረቡዕ",
"4": "ሐሙስ",
"5": "ዓርብ",
"6": "ቅዳሜ"
"0": "\u12a5\u1211\u12f5",
"1": "\u1230\u129e",
"2": "\u121b\u12ad\u1230",
"3": "\u1228\u1261\u12d5",
"4": "\u1210\u1219\u1235",
"5": "\u12d3\u122d\u1265",
"6": "\u1245\u12f3\u121c"
},
"SHORTMONTH": {
"0": "ጃንዩ",
"1": "ፌብሩ",
"2": "ማርች",
"3": "ኤፕረ",
"4": "ሜይ",
"5": "ጁን",
"6": "ጁላይ",
"7": "ኦገስ",
"8": "ሴፕቴ",
"9": "ኦክተ",
"10": "ኖቬም",
"11": "ዲሴም"
"0": "\u1303\u1295\u12e9",
"1": "\u134c\u1265\u1229",
"2": "\u121b\u122d\u127d",
"3": "\u12a4\u1355\u1228",
"4": "\u121c\u12ed",
"5": "\u1301\u1295",
"6": "\u1301\u120b\u12ed",
"7": "\u12a6\u1308\u1235",
"8": "\u1234\u1355\u1274",
"9": "\u12a6\u12ad\u1270",
"10": "\u1296\u126c\u121d",
"11": "\u12f2\u1234\u121d"
},
"fullDate": "EEEE, d MMMM y",
"longDate": "d MMMM y",
Expand Down Expand Up @@ -85,9 +85,9 @@ $provide.value("$locale", {
"maxFrac": 2,
"minFrac": 2,
"minInt": 1,
"negPre": "(\u00A4",
"negPre": "(\u00a4",
"negSuf": ")",
"posPre": "\u00A4",
"posPre": "\u00a4",
"posSuf": ""
}
}
Expand Down
Loading

0 comments on commit 695c54c

Please sign in to comment.