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

Commit 264beb6

Browse files
committed
more i18n
1 parent d7ae300 commit 264beb6

File tree

6 files changed

+20
-14
lines changed

6 files changed

+20
-14
lines changed

i18n/spec/converterSpec.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var converter = require('../src/converter.js');
24

35
describe("convertNumberData", function() {

i18n/spec/parserSpec.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var parsePattern = require('../src/parser.js').parsePattern;
24

35
describe('parsePattern', function() {

i18n/spec/utilSpec.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var util = require('../src/util.js');
24

35
describe('findLocaleId', function() {

i18n/src/closureI18nExtractor.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function findLocaleId(str, type) {
2020
return (str.match(/^NumberFormatSymbols_(.+)$/) || [])[1];
2121
}
2222

23-
if (type != 'datetime') { throw new Error('unknown type in findLocaleId: ' + type); }
23+
if (type !== 'datetime') { throw new Error('unknown type in findLocaleId: ' + type); }
2424

2525
return (str.match(/^DateTimeSymbols_(.+)$/) || [])[1];
2626
}
@@ -36,6 +36,7 @@ function getInfoForLocale(localeInfo, localeID) {
3636

3737
function extractNumberSymbols(content, localeInfo, currencySymbols) {
3838
//eval script in the current context so that we get access to all the symbols
39+
// eslint-disable-next-line no-eval
3940
eval(content.toString());
4041
for (var propName in goog.i18n) {
4142
var localeID = findLocaleId(propName, 'num');
@@ -49,6 +50,7 @@ function extractNumberSymbols(content, localeInfo, currencySymbols) {
4950

5051
function extractCurrencySymbols(content) {
5152
//eval script in the current context so that we get access to all the symbols
53+
// eslint-disable-next-line no-eval
5254
eval(content.toString());
5355
// var currencySymbols = goog.i18n.currency.CurrencyInfo;
5456
// currencySymbols.__proto__ = goog.i18n.currency.CurrencyInfoTier2;
@@ -58,10 +60,12 @@ function extractCurrencySymbols(content) {
5860

5961
function extractDateTimeSymbols(content, localeInfo) {
6062
//eval script in the current context so that we get access to all the symbols
63+
// eslint-disable-next-line no-eval
6164
eval(content.toString());
6265
for (var propName in goog.i18n) {
6366
var localeID = findLocaleId(propName, 'datetime');
6467
if (localeID) {
68+
// eslint-disable-next-line no-unused-vars
6569
var info = getInfoForLocale(localeInfo, localeID);
6670
localeInfo[localeID].DATETIME_FORMATS =
6771
converter.convertDatetimeData(goog.i18n[propName]);
@@ -78,6 +82,7 @@ function pluralExtractor(content, localeInfo) {
7882
// e.g. plural rules for en_SG is the same as those for en.
7983
goog.LOCALE = localeIds[i].match(/[^_]+/)[0];
8084
try {
85+
// eslint-disable-next-line no-eval
8186
eval(contentText);
8287
} catch (e) {
8388
console.log("Error in eval(contentText): " + e.stack);
@@ -121,7 +126,7 @@ function canonicalizeForJsonStringify(unused_key, object) {
121126
// 2. https://code.google.com/p/v8/issues/detail?id=164
122127
// ECMA-262 does not specify enumeration order. The de facto standard
123128
// is to match insertion order, which V8 also does ...
124-
if (typeof object != "object" || Object.prototype.toString.apply(object) === '[object Array]') {
129+
if (typeof object !== "object" || Object.prototype.toString.apply(object) === '[object Array]') {
125130
return object;
126131
}
127132
var result = {};

i18n/src/closureSlurper.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,8 @@
33

44
var Q = require('q'),
55
qfs = require('q-io/fs'),
6-
converter = require('./converter.js'),
7-
util = require('./util.js'),
86
closureI18nExtractor = require('./closureI18nExtractor.js'),
9-
localeInfo = {},
10-
currencySymbols,
11-
goog = { provide: function() {},
12-
require: function() {},
13-
i18n: {currency: {}, pluralRules: {}} };
7+
localeInfo = {};
148

159

1610
var NG_LOCALE_DIR = '../src/ngLocale/';
@@ -95,7 +89,8 @@ function writeLocaleFiles() {
9589
function createFolder(folder) {
9690
return qfs.isDirectory(folder).then(function(isDir) {
9791
if (!isDir) return qfs.makeDirectory(folder).then(function() {
98-
console.log('Created directory %j', folder); });
92+
console.log('Created directory %j', folder);
93+
});
9994
});
10095
}
10196

i18n/src/converter.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
/**
24
* after obtaining data from closure files, use converter to massage the data into the formats
35
* we want
@@ -10,9 +12,7 @@ var parsePattern = require('./parser').parsePattern;
1012

1113

1214
function convertNumberData(dataObj, currencySymbols) {
13-
var numberFormats = {},
14-
15-
numberFormats = {
15+
var numberFormats = {
1616
DECIMAL_SEP: dataObj.DECIMAL_SEP,
1717
GROUP_SEP: dataObj.GROUP_SEP,
1818
PATTERNS: [parsePattern(dataObj.DECIMAL_PATTERN),
@@ -22,7 +22,7 @@ function convertNumberData(dataObj, currencySymbols) {
2222
if (currencySymbols[dataObj.DEF_CURRENCY_CODE]) {
2323
numberFormats.CURRENCY_SYM = currencySymbols[dataObj.DEF_CURRENCY_CODE][1];
2424
} else {
25-
if (dataObj.DEF_CURRENCY_CODE == 'MTL') {
25+
if (dataObj.DEF_CURRENCY_CODE === 'MTL') {
2626
numberFormats.CURRENCY_SYM = '₤'; //for some reason this is missing in closure
2727
} else {
2828
// if there is no corresponding currency symbol, just use currency code.

0 commit comments

Comments
 (0)