mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
build.js now updates locales with local en changes
This commit is contained in:
@@ -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
|
||||
|
||||
10
build.js
10
build.js
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user