aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--i18n/README.md3
-rwxr-xr-xi18n/generate.sh7
-rwxr-xr-xi18n/run-tests.sh3
-rwxr-xr-xi18n/src/closureSlurper.js40
-rwxr-xr-xi18n/update-closure.sh11
5 files changed, 43 insertions, 21 deletions
diff --git a/i18n/README.md b/i18n/README.md
index 9bff2adf..d0626463 100644
--- a/i18n/README.md
+++ b/i18n/README.md
@@ -1,11 +1,10 @@
# i18n directory overview:
- closure/ - closure files we use for ruleset generation
-- locale/ - angular's locale ruleset files
- src/ - source files
- spec/ - spec files for stuff in src directory
- generate.sh - runs src scripts on closure dir and stores output in locale dir
-- update-closure.sh - downloads the latest version of closure files from public svn repo
+- update-closure.sh - downloads the latest version of closure files from public git repo
The closure files (maintained by Shanjian Li (shanjian)) change very rarely, so we don't need to
regenerate locale files very often.
diff --git a/i18n/generate.sh b/i18n/generate.sh
index 3b3f4442..4c5db440 100755
--- a/i18n/generate.sh
+++ b/i18n/generate.sh
@@ -1,7 +1,12 @@
#!/bin/bash
+set -e
+
BASE_DIR=`dirname $0`
cd $BASE_DIR
+./run-tests.sh
+
+node src/closureSlurper.js
+
-../node_modules/.bin/jasmine-node spec/ --noColor && node src/closureSlurper.js
diff --git a/i18n/run-tests.sh b/i18n/run-tests.sh
index 68b13401..3f710c02 100755
--- a/i18n/run-tests.sh
+++ b/i18n/run-tests.sh
@@ -2,4 +2,5 @@
set -e
PARENT_DIR="$(dirname "$0")"
-jasmine-node "$PARENT_DIR"/spec/
+
+../node_modules/.bin/jasmine-node "$PARENT_DIR"/spec/
diff --git a/i18n/src/closureSlurper.js b/i18n/src/closureSlurper.js
index 9f236cf2..02a1d9ef 100755
--- a/i18n/src/closureSlurper.js
+++ b/i18n/src/closureSlurper.js
@@ -2,7 +2,7 @@
'use strict';
var Q = require('q'),
- qfs = require('q-fs'),
+ qfs = require('q-io/fs'),
converter = require('./converter.js'),
util = require('./util.js'),
closureI18nExtractor = require('./closureI18nExtractor.js'),
@@ -47,24 +47,40 @@ function extractPlurals() {
function writeLocaleFiles() {
console.log('Final stage: Writing angular locale files to directory: %j', NG_LOCALE_DIR);
- var writePromises = [];
+ var result = Q.defer();
var localeIds = Object.keys(localeInfo);
var num_files = 0;
- localeIds.forEach(function(localeID) {
+
+ console.log('Generated %j locale files.', localeIds.length);
+ loop();
+ return result.promise;
+
+ // Need to use a loop and not write the files in parallel,
+ // as otherwise we will get the error EMFILE, which means
+ // we have too many open files.
+ function loop() {
+ var nextPromise;
+ if (localeIds.length) {
+ nextPromise = process(localeIds.pop()) || Q.when();
+ nextPromise.then(loop, result.reject);
+ } else {
+ result.resolve(num_files);
+ }
+ }
+
+ function process(localeID) {
var content = closureI18nExtractor.outputLocale(localeInfo, localeID);
if (!content) return;
var correctedLocaleId = closureI18nExtractor.correctedLocaleId(localeID);
var filename = NG_LOCALE_DIR + 'angular-locale_' + correctedLocaleId + '.js'
- writePromises.push(
- qfs.write(filename, content)
- .then(function () {
- console.log('Wrote ' + filename);
- ++num_files;
- }));
console.log('Writing ' + filename);
- });
- console.log('Generated %j locale files.', localeIds.length);
- return Q.all(writePromises).then(function() { return num_files });
+ return qfs.write(filename, content)
+ .then(function () {
+ console.log('Wrote ' + filename);
+ ++num_files;
+ });
+ }
+
}
/**
diff --git a/i18n/update-closure.sh b/i18n/update-closure.sh
index 2ddf8892..e8f7cb5c 100755
--- a/i18n/update-closure.sh
+++ b/i18n/update-closure.sh
@@ -7,8 +7,9 @@ cd $BASE_DIR
set -x # Trace commands as they're executed.
-curl http://closure-library.googlecode.com/svn/trunk/closure/goog/i18n/currency.js > closure/currencySymbols.js
-curl http://closure-library.googlecode.com/svn/trunk/closure/goog/i18n/datetimesymbols.js > closure/datetimeSymbols.js
-curl http://closure-library.googlecode.com/svn/trunk/closure/goog/i18n/datetimesymbolsext.js > closure/datetimeSymbolsExt.js
-curl http://closure-library.googlecode.com/svn/trunk/closure/goog/i18n/numberformatsymbols.js > closure/numberSymbols.js
-curl http://closure-library.googlecode.com/svn/trunk/closure/goog/i18n/pluralrules.js > closure/pluralRules.js
+# use the github repo as it is more up to date than the svn repo
+curl https://closure-library.googlecode.com/git/closure/goog/i18n/currency.js > closure/currencySymbols.js
+curl https://closure-library.googlecode.com/git/closure/goog/i18n/datetimesymbols.js > closure/datetimeSymbols.js
+curl https://closure-library.googlecode.com/git/closure/goog/i18n/datetimesymbolsext.js > closure/datetimeSymbolsExt.js
+curl https://closure-library.googlecode.com/git/closure/goog/i18n/numberformatsymbols.js > closure/numberSymbols.js
+curl https://closure-library.googlecode.com/git/closure/goog/i18n/pluralrules.js > closure/pluralRules.js