1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Tools: Detect missing translation strings on CI (#5688)

This commit is contained in:
Laurent 2021-11-08 17:10:33 +00:00 committed by GitHub
parent 75256613cc
commit 0ab235273b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 7 deletions

View File

@ -81,7 +81,7 @@ fi
# release randomly fail.
# =============================================================================
if [ "$IS_PULL_REQUEST" == "1" ]; then
if [ "$IS_PULL_REQUEST" == "1" ] || [ "$IS_DEV_BRANCH" = "1" ]; then
echo "Step: Running linter..."
npm run linter-ci ./
@ -109,6 +109,27 @@ if [ "$IS_PULL_REQUEST" == "1" ]; then
fi
fi
# =============================================================================
# Check that we didn't lose any string due to gettext not being able to parse
# newly modified or added scripts. This is convenient to quickly view on GitHub
# what commit may have broken translation building. We run this on macOS because
# we need the latest version of gettext (and stable Ubuntu doesn't have it).
# =============================================================================
if [ "$IS_PULL_REQUEST" == "1" ] || [ "$IS_DEV_BRANCH" = "1" ]; then
if [ "$IS_MACOS" == "1" ]; then
echo "Step: Checking for lost translation strings..."
xgettext --version
node packages/tools/build-translation.js --missing-strings-check-only
testResult=$?
if [ $testResult -ne 0 ]; then
exit $testResult
fi
fi
fi
# =============================================================================
# Find out if we should run the build or not. Electron-builder gets stuck when
# building PRs so we disable it in this case. The Linux build should provide
@ -124,13 +145,12 @@ if [ "$IS_PULL_REQUEST" == "1" ]; then
fi
# =============================================================================
# Prepare the Electron app and build it
# Build the Electron app or Docker image depending on the current tag.
#
# If the current tag is a desktop release tag (starts with "v", such as
# "v1.4.7"), we build and publish to github
#
# Otherwise we only build but don't publish to GitHub. It helps finding
# out any issue in pull requests and dev branch.
# "v1.4.7"), we build and publish to GitHub. Otherwise we only build but don't
# publish to GitHub. It helps finding out any issue in pull requests and dev
# branch.
# =============================================================================
cd "$ROOT_DIR/packages/app-desktop"

View File

@ -19,6 +19,14 @@ jobs:
sudo apt-get update || true
sudo apt-get install -y gettext
sudo apt-get install -y libsecret-1-dev
sudo apt-get install -y translate-toolkit
- name: Install macOS dependencies
if: runner.os == 'macOS'
run: |
brew update
brew install gettext
brew install translate-toolkit
- name: Install Docker Engine
if: runner.os == 'Linux' && startsWith(github.ref, 'refs/tags/server-v')

View File

@ -346,7 +346,18 @@ function deletedStrings(oldStrings, newStrings) {
async function main() {
const argv = require('yargs').argv;
const potFilePath = `${localesDir}/joplin.pot`;
const missingStringsCheckOnly = !!argv['missing-strings-check-only'];
let potFilePath = `${localesDir}/joplin.pot`;
let tempPotFilePath = '';
if (missingStringsCheckOnly) {
tempPotFilePath = `${localesDir}/joplin-temp-${Math.floor(Math.random() * 10000000)}.pot`;
await fs.copy(potFilePath, tempPotFilePath);
potFilePath = tempPotFilePath;
}
const jsonLocalesDir = `${libDir}/locales`;
const defaultLocale = 'en_GB';
@ -360,6 +371,8 @@ async function main() {
console.info(`Updated pot file. Total strings: ${oldPotStatus.untranslatedCount} => ${newPotStatus.untranslatedCount}`);
if (tempPotFilePath) await fs.remove(tempPotFilePath);
const deletedCount = oldPotStatus.untranslatedCount - newPotStatus.untranslatedCount;
if (deletedCount >= 5) {
if (argv['skip-missing-strings-check']) {
@ -374,6 +387,8 @@ async function main() {
}
}
if (missingStringsCheckOnly) return;
await execCommand(`cp "${potFilePath}" ` + `"${localesDir}/${defaultLocale}.po"`);
fs.mkdirpSync(jsonLocalesDir, 0o755);