mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-29 05:15:38 +08:00
chore(build): Update closure i18n integration
Use git repo as source and use q-io instead of q-fs
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2,4 +2,5 @@
|
||||
|
||||
set -e
|
||||
PARENT_DIR="$(dirname "$0")"
|
||||
jasmine-node "$PARENT_DIR"/spec/
|
||||
|
||||
../node_modules/.bin/jasmine-node "$PARENT_DIR"/spec/
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user