Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import shell from 'shelljs'; import { assert } from '@amalia/ext/typescript'; const escape = (path: string) => `"${path.replaceAll('"', String.raw`\"`)}"`; const asyncOpts = { silent: true, async: false } as const; const updatePoFile = (poFilePath: string, potFilePath: string) => { shell // Update po file with new strings. .exec(`msgmerge -U --no-fuzzy-matching --backup=none ${escape(poFilePath)} ${escape(potFilePath)}`, asyncOpts) // Remove obsolete strings (they are in Weblate database if we add them back later). .exec(`msgattrib --no-obsolete -o ${escape(poFilePath)} ${escape(poFilePath)}`, asyncOpts) // Remove duplicate strings (happens with faulty git merges). .exec(`msguniq ${escape(poFilePath)} -o ${escape(poFilePath)}`, asyncOpts); }; export function updatePoFiles(poFilePaths: string[], potFilePath: string) { assert(shell.which('msgmerge'), 'msgmerge: command not found'); assert(shell.which('msgattrib'), 'msgattrib: command not found'); poFilePaths.forEach((poFilePath) => { updatePoFile(poFilePath, potFilePath); }); } |