Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (opt.format === 'flat') {
cb(null, JSON.stringify(flatten(data), null, 2));
return;
}
if (opt.format === 'po' || opt.format === 'gettext') {
const flatData = flatten(data);
const gettextOpt = {
project: 'locize',
language: lng,
potCreationDate: lastModified,
poRevisionDate: lastModified,
ctxSeparator: '_ is default but we set it to something that is never found!!!',
persistMsgIdPlural: true
};
i18nextToPo(lng, JSON.stringify(flatData), gettextOpt).then((ret) => {
cb(null, ret.toString());
}, cb);
return;
}
if (opt.format === 'po_i18next' || opt.format === 'gettext_i18next') {
i18nextToPo(lng, JSON.stringify(flatten(data)), {
project: 'locize',
language: lng,
potCreationDate: lastModified,
poRevisionDate: lastModified
}).then((ret) => {
cb(null, ret.toString());
}, cb);
return;
}
if (opt.format === 'csv') {
const gettextOpt = {
project: 'locize',
language: lng,
potCreationDate: lastModified,
poRevisionDate: lastModified,
ctxSeparator: '_ is default but we set it to something that is never found!!!',
persistMsgIdPlural: true
};
i18nextToPo(lng, JSON.stringify(flatData), gettextOpt).then((ret) => {
cb(null, ret.toString());
}, cb);
return;
}
if (opt.format === 'po_i18next' || opt.format === 'gettext_i18next') {
i18nextToPo(lng, JSON.stringify(flatten(data)), {
project: 'locize',
language: lng,
potCreationDate: lastModified,
poRevisionDate: lastModified
}).then((ret) => {
cb(null, ret.toString());
}, cb);
return;
}
if (opt.format === 'csv') {
opt.getNamespace(opt, opt.referenceLanguage, namespace, (err, refNs) => {
if (err) return cb(err);
const js2CsvData = Object.keys(flatten(data)).reduce((mem, k) => {
const value = data[k] || '';
const line = {