mirror of
https://github.com/sartography/bpmn-js.git
synced 2025-01-10 17:16:02 +00:00
3ff287266c
This restores the translation reporter that allows us to extract translations from the library, as we test it.
50 lines
1.0 KiB
JavaScript
50 lines
1.0 KiB
JavaScript
var fs = require('fs');
|
|
var path = require('path');
|
|
|
|
var {
|
|
uniqueBy,
|
|
sortBy
|
|
} = require('min-dash');
|
|
|
|
|
|
function TranslationReporter() {
|
|
process.env.TRANSLATIONS = 'enabled';
|
|
|
|
var translationsFile = path.join(__dirname, '../../docs/translations.json');
|
|
|
|
var translations = [];
|
|
|
|
|
|
this.onBrowserLog = function(browser, log, type) {
|
|
|
|
if (log === undefined || typeof log !== 'string') {
|
|
return;
|
|
}
|
|
|
|
if (log.substring(0, 1) === '\'') {
|
|
log = log.substring(1, log.length - 1);
|
|
}
|
|
|
|
try {
|
|
var obj = JSON.parse(log);
|
|
|
|
if (obj.type === 'translations') {
|
|
translations.push(obj.msg);
|
|
}
|
|
} catch (e) {
|
|
return;
|
|
}
|
|
};
|
|
|
|
|
|
this.onRunComplete = function() {
|
|
translations = uniqueBy(function(e) { return e; }, translations);
|
|
translations = sortBy(translations, function(e) { return e; });
|
|
|
|
fs.writeFileSync(translationsFile, JSON.stringify(translations, null, 2));
|
|
};
|
|
}
|
|
|
|
module.exports = {
|
|
'reporter:translation-reporter' : [ 'type', TranslationReporter ]
|
|
}; |