|
Lines 8-13
const fs = require('fs');
Link Here
|
| 8 |
const os = require('os'); |
8 |
const os = require('os'); |
| 9 |
const path = require('path'); |
9 |
const path = require('path'); |
| 10 |
const util = require('util'); |
10 |
const util = require('util'); |
|
|
11 |
const stream = require('stream/promises'); |
| 11 |
|
12 |
|
| 12 |
const sass = require('gulp-sass')(require('sass')); |
13 |
const sass = require('gulp-sass')(require('sass')); |
| 13 |
const rtlcss = require('gulp-rtlcss'); |
14 |
const rtlcss = require('gulp-rtlcss'); |
|
Lines 257-275
function po_create_type (type) {
Link Here
|
| 257 |
const access = util.promisify(fs.access); |
258 |
const access = util.promisify(fs.access); |
| 258 |
const exec = util.promisify(child_process.exec); |
259 |
const exec = util.promisify(child_process.exec); |
| 259 |
|
260 |
|
| 260 |
const languages = getLanguages(); |
261 |
const pot = `misc/translator/Koha-${type}.pot`; |
| 261 |
const promises = []; |
|
|
| 262 |
for (const language of languages) { |
| 263 |
const locale = language.split('-').filter(s => s.length !== 4).join('_'); |
| 264 |
const po = `misc/translator/po/${language}-${type}.po`; |
| 265 |
const pot = `misc/translator/Koha-${type}.pot`; |
| 266 |
|
262 |
|
| 267 |
const promise = access(po) |
263 |
// Generate .pot only if it doesn't exist or --force-extract is given |
| 268 |
.catch(() => exec(`msginit -o ${po} -i ${pot} -l ${locale} --no-translator`)) |
264 |
const extract = () => stream.finished(poTasks[type].extract()); |
| 269 |
promises.push(promise); |
265 |
const p = args['force-extract'] ? extract() : access(pot).catch(extract); |
| 270 |
} |
266 |
|
|
|
267 |
return p.then(function () { |
| 268 |
const languages = getLanguages(); |
| 269 |
const promises = []; |
| 270 |
for (const language of languages) { |
| 271 |
const locale = language.split('-').filter(s => s.length !== 4).join('_'); |
| 272 |
const po = `misc/translator/po/${language}-${type}.po`; |
| 273 |
|
| 274 |
const promise = access(po) |
| 275 |
.catch(() => exec(`msginit -o ${po} -i ${pot} -l ${locale} --no-translator`)) |
| 276 |
promises.push(promise); |
| 277 |
} |
| 271 |
|
278 |
|
| 272 |
return Promise.all(promises); |
279 |
return Promise.all(promises); |
|
|
280 |
}); |
| 273 |
} |
281 |
} |
| 274 |
|
282 |
|
| 275 |
function po_create_marc_marc21 () { return po_create_type('marc-MARC21') } |
283 |
function po_create_marc_marc21 () { return po_create_type('marc-MARC21') } |
|
Lines 284-297
function po_create_installer_marc21 () { return po_create_type('installer-MARC2
Link Here
|
| 284 |
function po_create_installer_unimarc () { return po_create_type('installer-UNIMARC') } |
292 |
function po_create_installer_unimarc () { return po_create_type('installer-UNIMARC') } |
| 285 |
|
293 |
|
| 286 |
function po_update_type (type) { |
294 |
function po_update_type (type) { |
| 287 |
const msgmerge_opts = '--backup=off --quiet --sort-output --update'; |
295 |
const access = util.promisify(fs.access); |
| 288 |
const cmd = `msgmerge ${msgmerge_opts} <%= file.path %> misc/translator/Koha-${type}.pot`; |
296 |
const exec = util.promisify(child_process.exec); |
| 289 |
const languages = getLanguages(); |
297 |
|
| 290 |
const globs = languages.map(language => `misc/translator/po/${language}-${type}.po`); |
298 |
const pot = `misc/translator/Koha-${type}.pot`; |
| 291 |
|
299 |
|
| 292 |
return src(globs) |
300 |
// Generate .pot only if it doesn't exist or --force-extract is given |
| 293 |
.pipe(exec(cmd, { continueOnError: true })) |
301 |
const extract = () => stream.finished(poTasks[type].extract()); |
| 294 |
.pipe(exec.reporter({ err: false, stdout: false })) |
302 |
const p = args['force-extract'] ? extract() : access(pot).catch(extract); |
|
|
303 |
|
| 304 |
return p.then(function () { |
| 305 |
const languages = getLanguages(); |
| 306 |
const promises = []; |
| 307 |
for (const language of languages) { |
| 308 |
const po = `misc/translator/po/${language}-${type}.po`; |
| 309 |
promises.push(exec(`msgmerge --backup=off --quiet --sort-output --update ${po} ${pot}`)); |
| 310 |
} |
| 311 |
|
| 312 |
return Promise.all(promises); |
| 313 |
}); |
| 295 |
} |
314 |
} |
| 296 |
|
315 |
|
| 297 |
function po_update_marc_marc21 () { return po_update_type('marc-MARC21') } |
316 |
function po_update_marc_marc21 () { return po_update_type('marc-MARC21') } |
|
Lines 379-384
exports.watch = function () {
Link Here
|
| 379 |
watch(STAFF_CSS_BASE + "/src/**/*.scss", series('staff_css')); |
398 |
watch(STAFF_CSS_BASE + "/src/**/*.scss", series('staff_css')); |
| 380 |
}; |
399 |
}; |
| 381 |
|
400 |
|
| 382 |
exports['po:create'] = parallel(...poTypes.map(type => series(poTasks[type].extract, poTasks[type].create))); |
401 |
exports['po:create'] = parallel(...poTypes.map(type => poTasks[type].create)); |
| 383 |
exports['po:update'] = parallel(...poTypes.map(type => series(poTasks[type].extract, poTasks[type].update))); |
402 |
exports['po:update'] = parallel(...poTypes.map(type => poTasks[type].update)); |
| 384 |
exports['po:extract'] = parallel(...poTypes.map(type => poTasks[type].extract)); |
403 |
exports['po:extract'] = parallel(...poTypes.map(type => poTasks[type].extract)); |
| 385 |
- |
|
|