Skip to content

Commit fcf4393

Browse files
committed
chore(build): Update closure i18n integration
Use git repo as source and use q-io instead of q-fs
1 parent 16301be commit fcf4393

File tree

5 files changed

+43
-21
lines changed

5 files changed

+43
-21
lines changed

i18n/README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# i18n directory overview:
22

33
- closure/ - closure files we use for ruleset generation
4-
- locale/ - angular's locale ruleset files
54
- src/ - source files
65
- spec/ - spec files for stuff in src directory
76
- generate.sh - runs src scripts on closure dir and stores output in locale dir
8-
- update-closure.sh - downloads the latest version of closure files from public svn repo
7+
- update-closure.sh - downloads the latest version of closure files from public git repo
98

109
The closure files (maintained by Shanjian Li (shanjian)) change very rarely, so we don't need to
1110
regenerate locale files very often.

i18n/generate.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
#!/bin/bash
22

3+
set -e
4+
35
BASE_DIR=`dirname $0`
46
cd $BASE_DIR
57

8+
./run-tests.sh
9+
10+
node src/closureSlurper.js
11+
612

7-
../node_modules/.bin/jasmine-node spec/ --noColor && node src/closureSlurper.js

i18n/run-tests.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
set -e
44
PARENT_DIR="$(dirname "$0")"
5-
jasmine-node "$PARENT_DIR"/spec/
5+
6+
../node_modules/.bin/jasmine-node "$PARENT_DIR"/spec/

i18n/src/closureSlurper.js

+28-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
'use strict';
33

44
var Q = require('q'),
5-
qfs = require('q-fs'),
5+
qfs = require('q-io/fs'),
66
converter = require('./converter.js'),
77
util = require('./util.js'),
88
closureI18nExtractor = require('./closureI18nExtractor.js'),
@@ -47,24 +47,40 @@ function extractPlurals() {
4747

4848
function writeLocaleFiles() {
4949
console.log('Final stage: Writing angular locale files to directory: %j', NG_LOCALE_DIR);
50-
var writePromises = [];
50+
var result = Q.defer();
5151
var localeIds = Object.keys(localeInfo);
5252
var num_files = 0;
53-
localeIds.forEach(function(localeID) {
53+
54+
console.log('Generated %j locale files.', localeIds.length);
55+
loop();
56+
return result.promise;
57+
58+
// Need to use a loop and not write the files in parallel,
59+
// as otherwise we will get the error EMFILE, which means
60+
// we have too many open files.
61+
function loop() {
62+
var nextPromise;
63+
if (localeIds.length) {
64+
nextPromise = process(localeIds.pop()) || Q.when();
65+
nextPromise.then(loop, result.reject);
66+
} else {
67+
result.resolve(num_files);
68+
}
69+
}
70+
71+
function process(localeID) {
5472
var content = closureI18nExtractor.outputLocale(localeInfo, localeID);
5573
if (!content) return;
5674
var correctedLocaleId = closureI18nExtractor.correctedLocaleId(localeID);
5775
var filename = NG_LOCALE_DIR + 'angular-locale_' + correctedLocaleId + '.js'
58-
writePromises.push(
59-
qfs.write(filename, content)
60-
.then(function () {
61-
console.log('Wrote ' + filename);
62-
++num_files;
63-
}));
6476
console.log('Writing ' + filename);
65-
});
66-
console.log('Generated %j locale files.', localeIds.length);
67-
return Q.all(writePromises).then(function() { return num_files });
77+
return qfs.write(filename, content)
78+
.then(function () {
79+
console.log('Wrote ' + filename);
80+
++num_files;
81+
});
82+
}
83+
6884
}
6985

7086
/**

i18n/update-closure.sh

+6-5
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ cd $BASE_DIR
77

88
set -x # Trace commands as they're executed.
99

10-
curl http://closure-library.googlecode.com/svn/trunk/closure/goog/i18n/currency.js > closure/currencySymbols.js
11-
curl http://closure-library.googlecode.com/svn/trunk/closure/goog/i18n/datetimesymbols.js > closure/datetimeSymbols.js
12-
curl http://closure-library.googlecode.com/svn/trunk/closure/goog/i18n/datetimesymbolsext.js > closure/datetimeSymbolsExt.js
13-
curl http://closure-library.googlecode.com/svn/trunk/closure/goog/i18n/numberformatsymbols.js > closure/numberSymbols.js
14-
curl http://closure-library.googlecode.com/svn/trunk/closure/goog/i18n/pluralrules.js > closure/pluralRules.js
10+
# use the github repo as it is more up to date than the svn repo
11+
curl https://closure-library.googlecode.com/git/closure/goog/i18n/currency.js > closure/currencySymbols.js
12+
curl https://closure-library.googlecode.com/git/closure/goog/i18n/datetimesymbols.js > closure/datetimeSymbols.js
13+
curl https://closure-library.googlecode.com/git/closure/goog/i18n/datetimesymbolsext.js > closure/datetimeSymbolsExt.js
14+
curl https://closure-library.googlecode.com/git/closure/goog/i18n/numberformatsymbols.js > closure/numberSymbols.js
15+
curl https://closure-library.googlecode.com/git/closure/goog/i18n/pluralrules.js > closure/pluralRules.js

0 commit comments

Comments
 (0)