mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-16 13:59:27 +02:00
Remove lodash merge.. also don't need esm dependency anymore
(re: #6087)
This commit is contained in:
+20
-24
@@ -1,8 +1,4 @@
|
||||
/* Downloads the latest translations from Transifex */
|
||||
|
||||
const requireESM = require('esm')(module);
|
||||
const _merge = requireESM('lodash-es/merge').default;
|
||||
|
||||
const fs = require('fs');
|
||||
const prettyStringify = require('json-stringify-pretty-compact');
|
||||
const request = require('request').defaults({ maxSockets: 1 });
|
||||
@@ -35,25 +31,26 @@ const sourceCommunity = YAML.load(fs.readFileSync('./node_modules/osm-community-
|
||||
asyncMap(resources, getResource, function(err, results) {
|
||||
if (err) return console.log(err);
|
||||
|
||||
var locale = _merge(
|
||||
sourceCore,
|
||||
sourcePresets,
|
||||
sourceImagery,
|
||||
{ en: { community: sourceCommunity.en } } // add namespace
|
||||
);
|
||||
var dataLocales = {};
|
||||
|
||||
results.forEach(function(l) {
|
||||
locale = _merge(locale, l);
|
||||
// merge in strings fetched from transifex
|
||||
var allStrings = {};
|
||||
results.forEach(function(resourceStrings) {
|
||||
Object.keys(resourceStrings).forEach(function(code) {
|
||||
if (!allStrings[code]) { allStrings[code] = {}; }
|
||||
var source = resourceStrings[code];
|
||||
var target = allStrings[code];
|
||||
Object.keys(source).forEach(function(k) { target[k] = source[k]; });
|
||||
});
|
||||
});
|
||||
|
||||
asyncMap(Object.keys(locale),
|
||||
// write files and fetch language info for each locale
|
||||
var dataLocales = {};
|
||||
asyncMap(Object.keys(allStrings),
|
||||
function(code, done) {
|
||||
if (code === 'en' || !Object.keys(locale[code]).length) {
|
||||
if (code === 'en' || !Object.keys(allStrings[code]).length) {
|
||||
done();
|
||||
} else {
|
||||
var obj = {};
|
||||
obj[code] = locale[code];
|
||||
obj[code] = allStrings[code];
|
||||
fs.writeFileSync(outdir + code + '.json', JSON.stringify(obj, null, 4));
|
||||
|
||||
getLanguageInfo(code, function(err, info) {
|
||||
@@ -151,13 +148,12 @@ function getLanguages(resource, callback) {
|
||||
var url = resource + '?details';
|
||||
request.get(url, { auth: auth },
|
||||
function(err, resp, body) {
|
||||
if (err) return callback(err);
|
||||
console.log(resp.statusCode + ': ' + url);
|
||||
callback(null, JSON.parse(body).available_languages.map(function(d) {
|
||||
return d.code.replace(/_/g, '-');
|
||||
}).filter(function(d) {
|
||||
return d !== 'en';
|
||||
}));
|
||||
if (err) return callback(err);
|
||||
console.log(resp.statusCode + ': ' + url);
|
||||
callback(null, JSON.parse(body).available_languages
|
||||
.map(function(d) { return d.code.replace(/_/g, '-'); })
|
||||
.filter(function(d) { return d !== 'en'; })
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,6 @@
|
||||
"ecstatic": "^3.0.0",
|
||||
"editor-layer-index": "github:osmlab/editor-layer-index#gh-pages",
|
||||
"eslint": "^5.15.3",
|
||||
"esm": "^3.2.18",
|
||||
"gaze": "^1.1.1",
|
||||
"glob": "^7.1.0",
|
||||
"happen": "^0.3.1",
|
||||
|
||||
Reference in New Issue
Block a user