mirror of
https://github.com/laurent22/joplin.git
synced 2025-03-29 21:21:15 +02:00
Tools: Improve how translations are built to make sure no translation is missed
This commit is contained in:
parent
794c8dd051
commit
21fcaf621d
@ -79,7 +79,45 @@ async function removePoHeaderDate(filePath) {
|
|||||||
await execCommand(`${sedPrefix} -e'/PO-Revision-Date:/d' "${filePath}"`);
|
await execCommand(`${sedPrefix} -e'/PO-Revision-Date:/d' "${filePath}"`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createPotFile(potFilePath, sources) {
|
async function createPotFile(potFilePath) {
|
||||||
|
const excludedDirs = [
|
||||||
|
'./.git/*',
|
||||||
|
'./.github/*',
|
||||||
|
'./Assets/*',
|
||||||
|
'./CliClient/build/*',
|
||||||
|
'./CliClient/locales-build/*',
|
||||||
|
'./CliClient/locales/*',
|
||||||
|
'./CliClient/node_modules/*',
|
||||||
|
'./CliClient/tests-build/*',
|
||||||
|
'./CliClient/tests/*',
|
||||||
|
'./Clipper/*',
|
||||||
|
'./docs/*',
|
||||||
|
'./ElectronClient/dist/*',
|
||||||
|
'./ElectronClient/gui/style/*',
|
||||||
|
'./ElectronClient/lib/*',
|
||||||
|
'./ElectronClient/node_modules/*',
|
||||||
|
'./ElectronClient/pluginAssets/*',
|
||||||
|
'./ElectronClient/tools/*',
|
||||||
|
'./ElectronClient/gui/note-viewer/pluginAssets/*',
|
||||||
|
'./ReactNativeClient/lib/joplin-renderer/assets/*',
|
||||||
|
'./Modules/*',
|
||||||
|
'./node_modules/*',
|
||||||
|
'./ReactNativeClient/lib/joplin-renderer/node_modules/*',
|
||||||
|
'./patches/*',
|
||||||
|
'./ReactNativeClient/android/*',
|
||||||
|
'./ReactNativeClient/ios/*',
|
||||||
|
'./ReactNativeClient/node_modules/*',
|
||||||
|
'./ReactNativeClient/pluginAssets/*',
|
||||||
|
'./ReactNativeClient/tools/*',
|
||||||
|
'./readme/*',
|
||||||
|
'./Tools/*',
|
||||||
|
];
|
||||||
|
|
||||||
|
const findCommand = `find ./ -iname '*.js' -not -path '${excludedDirs.join('\' -not -path \'')}'`;
|
||||||
|
|
||||||
|
process.chdir(`${__dirname}/..`);
|
||||||
|
const files = (await execCommand(findCommand)).split('\n');
|
||||||
|
|
||||||
const baseArgs = [];
|
const baseArgs = [];
|
||||||
baseArgs.push('--from-code=utf-8');
|
baseArgs.push('--from-code=utf-8');
|
||||||
baseArgs.push(`--output="${potFilePath}"`);
|
baseArgs.push(`--output="${potFilePath}"`);
|
||||||
@ -90,17 +128,14 @@ async function createPotFile(potFilePath, sources) {
|
|||||||
// baseArgs.push('--no-location');
|
// baseArgs.push('--no-location');
|
||||||
baseArgs.push('--keyword=_n:1,2');
|
baseArgs.push('--keyword=_n:1,2');
|
||||||
|
|
||||||
for (let i = 0; i < sources.length; i++) {
|
let args = baseArgs.slice();
|
||||||
const args = baseArgs.slice();
|
args = args.concat(files);
|
||||||
if (i > 0) args.push('--join-existing');
|
let xgettextPath = 'xgettext';
|
||||||
args.push(sources[i]);
|
if (isMac()) xgettextPath = executablePath('xgettext'); // Needs to have been installed with `brew install gettext`
|
||||||
let xgettextPath = 'xgettext';
|
const cmd = `${xgettextPath} ${args.join(' ')}`;
|
||||||
if (isMac()) xgettextPath = executablePath('xgettext'); // Needs to have been installed with `brew install gettext`
|
const result = await execCommand(cmd);
|
||||||
const cmd = `${xgettextPath} ${args.join(' ')}`;
|
if (result) console.error(result);
|
||||||
const result = await execCommand(cmd);
|
await removePoHeaderDate(potFilePath);
|
||||||
if (result) console.error(result);
|
|
||||||
await removePoHeaderDate(potFilePath);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function mergePotToPo(potFilePath, poFilePath) {
|
async function mergePotToPo(potFilePath, poFilePath) {
|
||||||
@ -252,20 +287,7 @@ async function main() {
|
|||||||
|
|
||||||
const oldPotStatus = await translationStatus(false, potFilePath);
|
const oldPotStatus = await translationStatus(false, potFilePath);
|
||||||
|
|
||||||
await createPotFile(potFilePath, [
|
await createPotFile(potFilePath);
|
||||||
`${cliDir}/app/*.js`,
|
|
||||||
`${cliDir}/app/gui/*.js`,
|
|
||||||
`${electronDir}/*.js`,
|
|
||||||
`${electronDir}/gui/*.js`,
|
|
||||||
`${electronDir}/gui/utils/*.js`,
|
|
||||||
`${electronDir}/plugins/*.js`,
|
|
||||||
`${rnDir}/lib/*.js`,
|
|
||||||
`${rnDir}/lib/models/*.js`,
|
|
||||||
`${rnDir}/lib/services/*.js`,
|
|
||||||
`${rnDir}/lib/components/*.js`,
|
|
||||||
`${rnDir}/lib/components/shared/*.js`,
|
|
||||||
`${rnDir}/lib/components/screens/*.js`,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const newPotStatus = await translationStatus(false, potFilePath);
|
const newPotStatus = await translationStatus(false, potFilePath);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user