Bugzilla – Attachment 157253 Details for
Bug 35079
Add option to gulp tasks po:update and po:create to control if POT should be built
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35079: Rebuild POT files only if necessary or asked explicitely
Bug-35079-Rebuild-POT-files-only-if-necessary-or-a.patch (text/plain), 4.78 KB, created by
Julian Maurice
on 2023-10-17 14:43:15 UTC
(
hide
)
Description:
Bug 35079: Rebuild POT files only if necessary or asked explicitely
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2023-10-17 14:43:15 UTC
Size:
4.78 KB
patch
obsolete
>From eb732138011555360ef750572da8fb6ae923b644 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Tue, 17 Oct 2023 16:33:37 +0200 >Subject: [PATCH] Bug 35079: Rebuild POT files only if necessary or asked > explicitely > >By default, gulp tasks po:create and po:update won't rebuild the POT >files if they already exist. >Both tasks gained a new option --force-extract to rebuild them >unconditionally > >This makes it possible to create/update PO files for multiple languages >sequentially without rebuilding the POT file for each language. >For instance: > > gulp po:update --lang fr-FR > # do something with the PO files > gulp po:update --lang en-GB > # ... >--- > gulpfile.js | 61 +++++++++++++++++++++++++++++++++++------------------ > 1 file changed, 40 insertions(+), 21 deletions(-) > >diff --git a/gulpfile.js b/gulpfile.js >index 6b3ab44cf8..bd23d2310a 100644 >--- a/gulpfile.js >+++ b/gulpfile.js >@@ -8,6 +8,7 @@ const fs = require('fs'); > const os = require('os'); > const path = require('path'); > const util = require('util'); >+const stream = require('stream/promises'); > > const sass = require('gulp-sass')(require('sass')); > const rtlcss = require('gulp-rtlcss'); >@@ -257,19 +258,26 @@ function po_create_type (type) { > const access = util.promisify(fs.access); > const exec = util.promisify(child_process.exec); > >- const languages = getLanguages(); >- const promises = []; >- for (const language of languages) { >- const locale = language.split('-').filter(s => s.length !== 4).join('_'); >- const po = `misc/translator/po/${language}-${type}.po`; >- const pot = `misc/translator/Koha-${type}.pot`; >+ const pot = `misc/translator/Koha-${type}.pot`; > >- const promise = access(po) >- .catch(() => exec(`msginit -o ${po} -i ${pot} -l ${locale} --no-translator`)) >- promises.push(promise); >- } >+ // Generate .pot only if it doesn't exist or --force-extract is given >+ const extract = () => stream.finished(poTasks[type].extract()); >+ const p = args['force-extract'] ? extract() : access(pot).catch(extract); >+ >+ return p.then(function () { >+ const languages = getLanguages(); >+ const promises = []; >+ for (const language of languages) { >+ const locale = language.split('-').filter(s => s.length !== 4).join('_'); >+ const po = `misc/translator/po/${language}-${type}.po`; >+ >+ const promise = access(po) >+ .catch(() => exec(`msginit -o ${po} -i ${pot} -l ${locale} --no-translator`)) >+ promises.push(promise); >+ } > >- return Promise.all(promises); >+ return Promise.all(promises); >+ }); > } > > function po_create_marc_marc21 () { return po_create_type('marc-MARC21') } >@@ -284,14 +292,25 @@ function po_create_installer_marc21 () { return po_create_type('installer-MARC2 > function po_create_installer_unimarc () { return po_create_type('installer-UNIMARC') } > > function po_update_type (type) { >- const msgmerge_opts = '--backup=off --quiet --sort-output --update'; >- const cmd = `msgmerge ${msgmerge_opts} <%= file.path %> misc/translator/Koha-${type}.pot`; >- const languages = getLanguages(); >- const globs = languages.map(language => `misc/translator/po/${language}-${type}.po`); >- >- return src(globs) >- .pipe(exec(cmd, { continueOnError: true })) >- .pipe(exec.reporter({ err: false, stdout: false })) >+ const access = util.promisify(fs.access); >+ const exec = util.promisify(child_process.exec); >+ >+ const pot = `misc/translator/Koha-${type}.pot`; >+ >+ // Generate .pot only if it doesn't exist or --force-extract is given >+ const extract = () => stream.finished(poTasks[type].extract()); >+ const p = args['force-extract'] ? extract() : access(pot).catch(extract); >+ >+ return p.then(function () { >+ const languages = getLanguages(); >+ const promises = []; >+ for (const language of languages) { >+ const po = `misc/translator/po/${language}-${type}.po`; >+ promises.push(exec(`msgmerge --backup=off --quiet --sort-output --update ${po} ${pot}`)); >+ } >+ >+ return Promise.all(promises); >+ }); > } > > function po_update_marc_marc21 () { return po_update_type('marc-MARC21') } >@@ -379,6 +398,6 @@ exports.watch = function () { > watch(STAFF_CSS_BASE + "/src/**/*.scss", series('staff_css')); > }; > >-exports['po:create'] = parallel(...poTypes.map(type => series(poTasks[type].extract, poTasks[type].create))); >-exports['po:update'] = parallel(...poTypes.map(type => series(poTasks[type].extract, poTasks[type].update))); >+exports['po:create'] = parallel(...poTypes.map(type => poTasks[type].create)); >+exports['po:update'] = parallel(...poTypes.map(type => poTasks[type].update)); > exports['po:extract'] = parallel(...poTypes.map(type => poTasks[type].extract)); >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 35079
:
157253
|
157257
|
157304
|
157305