Bug 35103: Add option to gulp tasks to pass a list of tasks
You can now generate the messages.po for all languages with: gulp po:update --task messages or for only es-ES gulp po:update --task messages --lang es-ES It may be helpful for the "update po" script that will be used on weblate. Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
3f01f6cafc
commit
6be4e96a3a
1 changed files with 26 additions and 4 deletions
30
gulpfile.js
30
gulpfile.js
|
@ -141,7 +141,29 @@ const poTasks = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const poTypes = Object.keys(poTasks);
|
function getPoTasks () {
|
||||||
|
let tasks = [];
|
||||||
|
|
||||||
|
let all_tasks = Object.keys(poTasks);
|
||||||
|
|
||||||
|
if (args.task) {
|
||||||
|
tasks = [args.task].flat(Infinity);
|
||||||
|
} else {
|
||||||
|
return all_tasks;
|
||||||
|
}
|
||||||
|
|
||||||
|
let invalid_tasks = tasks.filter( function( el ) {
|
||||||
|
return all_tasks.indexOf( el ) < 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
if ( invalid_tasks.length ) {
|
||||||
|
console.error("Invalid task");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return tasks;
|
||||||
|
}
|
||||||
|
const poTypes = getPoTasks();
|
||||||
|
|
||||||
function po_extract_marc (type) {
|
function po_extract_marc (type) {
|
||||||
return src(`koha-tmpl/*-tmpl/*/en/**/*${type}*`, { read: false, nocase: true })
|
return src(`koha-tmpl/*-tmpl/*/en/**/*${type}*`, { read: false, nocase: true })
|
||||||
|
@ -387,11 +409,11 @@ function getLanguages () {
|
||||||
return [args.lang];
|
return [args.lang];
|
||||||
}
|
}
|
||||||
|
|
||||||
const filenames = fs.readdirSync('misc/translator/po')
|
const filenames = fs.readdirSync('misc/translator/po/')
|
||||||
.filter(filename => filename.endsWith('.po'))
|
.filter(filename => filename.endsWith('-installer.po'))
|
||||||
.filter(filename => !filename.startsWith('.'))
|
.filter(filename => !filename.startsWith('.'))
|
||||||
|
|
||||||
const re = new RegExp('-(' + poTypes.join('|') + ')\.po$');
|
const re = new RegExp('-installer.po');
|
||||||
languages = filenames.map(filename => filename.replace(re, ''))
|
languages = filenames.map(filename => filename.replace(re, ''))
|
||||||
|
|
||||||
return Array.from(new Set(languages));
|
return Array.from(new Set(languages));
|
||||||
|
|
Loading…
Reference in a new issue