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

Commit b461551

Browse files
chore(i18n): fix up i18n testing tools
1 parent 63492a0 commit b461551

7 files changed

+624
-638
lines changed

i18n/generate.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -e
55
BASE_DIR=`dirname $0`
66
cd $BASE_DIR
77

8-
./run-tests.sh
8+
npm run test-i18n
99

1010
node src/closureSlurper.js
1111

i18n/run-tests.sh

-6
This file was deleted.

i18n/spec/closureI18nExtractorSpec.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe("findLocaleId", function() {
7373
it("should throw an error otherwise", function() {
7474
expect(function() {
7575
findLocaleId("str", "otherwise")
76-
}).toThrow("unknown type in findLocaleId: otherwise");
76+
}).toThrowError("unknown type in findLocaleId: otherwise");
7777
});
7878
});
7979

@@ -132,7 +132,10 @@ describe("extractCurrencySymbols", function() {
132132
].join('\n');
133133

134134
var localeInfo = {};
135-
expect(extractCurrencySymbols(CONTENT)).toEqual({
135+
var currencySymbols = extractCurrencySymbols(CONTENT);
136+
expect(currencySymbols.GBP).toEqual([2, '£', 'GB£']);
137+
expect(currencySymbols.AOA).toEqual([2, 'Kz', 'Kz']);
138+
expect(currencySymbols).toEqual({
136139
'GBP':[2, '£', 'GB£'],
137140
'AOA':[2, 'Kz', 'Kz']
138141
});

i18n/src/closureI18nExtractor.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ function extractNumberSymbols(content, localeInfo, currencySymbols) {
5050
function extractCurrencySymbols(content) {
5151
//eval script in the current context so that we get access to all the symbols
5252
eval(content.toString());
53-
var currencySymbols = goog.i18n.currency.CurrencyInfo;
54-
currencySymbols.__proto__ = goog.i18n.currency.CurrencyInfoTier2;
53+
// var currencySymbols = goog.i18n.currency.CurrencyInfo;
54+
// currencySymbols.__proto__ = goog.i18n.currency.CurrencyInfoTier2;
5555

56-
return currencySymbols;
56+
return Object.assign({}, goog.i18n.currency.CurrencyInfoTier2, goog.i18n.currency.CurrencyInfo);
5757
}
5858

5959
function extractDateTimeSymbols(content, localeInfo) {
@@ -79,7 +79,7 @@ function pluralExtractor(content, localeInfo) {
7979
goog.LOCALE = localeIds[i].match(/[^_]+/)[0];
8080
try {
8181
eval(contentText);
82-
} catch(e) {
82+
} catch (e) {
8383
console.log("Error in eval(contentText): " + e.stack);
8484
}
8585
if (!goog.i18n.pluralRules.select) {
@@ -133,7 +133,7 @@ function canonicalizeForJsonStringify(unused_key, object) {
133133

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

0 commit comments

Comments
 (0)