build.js now updates locales with local en changes

This commit is contained in:
Ansis Brammanis
2013-03-19 15:31:13 -04:00
parent c12e011b2f
commit f392b3cacc
3 changed files with 15 additions and 2 deletions

View File

@@ -69,6 +69,9 @@ Then, add the new string to `data/core.yaml` or `data/presets.yaml` (depending
on whether it pertains to core code or presets). The translation system,
Transiflex, will automatically detect the change.
Use `make` to build the translations with the local changes.
`make translate` can be used to pull the latest translations from Transifex.
## Javascript
We use the [Airbnb style for Javascript](https://github.com/airbnb/javascript) with

View File

@@ -1,7 +1,8 @@
var fs = require('fs'),
path = require('path'),
glob = require('glob'),
YAML = require('js-yaml');
YAML = require('js-yaml'),
_ = require('./js/lib/lodash');
function read(f) {
return JSON.parse(fs.readFileSync(f));
@@ -60,3 +61,10 @@ fs.writeFileSync('data/data.js', 'iD.data = ' + JSON.stringify({
fields: rp('fields.json')
}
}, null, 4) + ';');
// Push changes from data/core.yaml into data/locales.js
var core = YAML.load(fs.readFileSync('data/core.yaml', 'utf8'));
var presets = YAML.load(fs.readFileSync('data/presets.yaml', 'utf8'));
var en = _.merge(core, presets);
var out = 'locale.en = ' + JSON.stringify(en.en, null, 4) + ';\n';
fs.writeFileSync('data/locales.js', fs.readFileSync('data/locales.js', 'utf8').replace(/locale.en =[^;]*;/, out));

View File

@@ -1,3 +1,5 @@
/* Downloads the latest translations from Transifex */
var request = require('request'),
yaml = require('js-yaml'),
fs = require('fs'),
@@ -32,7 +34,7 @@ asyncMap(resources, getResource, function(err, locales) {
});
for (var i in locale) {
out += 'locale.' + i + ' = ' + JSON.stringify(locale[i], null, 4) + ';';
out += 'locale.' + i + ' = ' + JSON.stringify(locale[i], null, 4) + ';\n';
}
fs.writeFileSync(outfile, out);
});