Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
6,088 additions
and
4,421 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,29 @@ | ||
/* Downloads preset translations from iD editor github repo */ | ||
|
||
var request = require('request'), | ||
fs = require('fs'); | ||
var request = require("request"), fs = require("fs"); | ||
|
||
var api = 'https://github.com/openstreetmap/iD/raw/master/dist/locales/'; | ||
var outdir = './data/'; | ||
var localesdir = './locales/'; | ||
var api = "https://github.com/openstreetmap/iD/raw/master/dist/locales/"; | ||
var outdir = "./data/"; | ||
var localesdir = "./locales/"; | ||
|
||
var locales = fs.readdirSync(localesdir).filter(function(filename) { return filename.match(/\.json$/); }); | ||
var locales = fs.readdirSync(localesdir).filter(function(filename) { | ||
return filename.match(/\.json$/); | ||
}); | ||
|
||
locales.forEach(function(locale) { | ||
locale = locale.replace('.json', ''); | ||
request(api + locale + '.json', function(err, resp, body) { | ||
console.log(locale); | ||
if (err) return; | ||
try { var data = JSON.parse(body); } catch (e) { return; } | ||
data = data.presets.presets; | ||
fs.writeFileSync(outdir + 'iD_presets_' + locale + '.json', JSON.stringify(data, null, 2)); | ||
}); | ||
locale = locale.replace(".json", ""); | ||
request(api + locale + ".json", function(err, resp, body) { | ||
console.log(locale); | ||
if (err) return; | ||
try { | ||
var data = JSON.parse(body); | ||
} catch (e) { | ||
return; | ||
} | ||
data = data.presets.presets; | ||
fs.writeFileSync( | ||
outdir + "iD_presets_" + locale + ".json", | ||
JSON.stringify(data, null, 2) | ||
); | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.