Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

build.js now updates locales with local en changes

  • Loading branch information...
commit f392b3cacca3629bece772a1adef94b42e4fdce9 1 parent c12e011
Ansis Brammanis ansis authored
Showing with 15 additions and 2 deletions.
  1. +3 −0  CONTRIBUTING.md
  2. +9 −1 build.js
  3. +3 −1 data/update_locales.js
3  CONTRIBUTING.md
View
@@ -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
View
@@ -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));
4 data/update_locales.js
View
@@ -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);
});
Please sign in to comment.
Something went wrong with that request. Please try again.