From 46fadc2a8221514d7b3d60094c42e5aac32c55bf Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 26 Feb 2020 17:47:02 +1000 Subject: [PATCH] don't abort build if mo file fails; rename files for consistency Issues are now checked for in CI, so there's no need to break the build for everyone each time there's a problem with the gettext catalogs. --- Makefile | 4 ++-- qt/Makefile | 6 ++++-- qt/i18n/build-mo-files | 18 ----------------- qt/i18n/pull-git | 11 ---------- qt/i18n/sync-po-git | 9 --------- qt/{i18n => po}/.gitignore | 2 +- qt/{i18n => po}/plurals.json | 0 qt/{i18n => po}/requirements.txt | 0 qt/po/scripts/build-mo-files | 20 +++++++++++++++++++ qt/{i18n => po/scripts}/copy-qt-files | 0 qt/{tools => po/scripts}/extract-po-string.py | 0 qt/po/scripts/fetch-latest-translations | 9 +++++++++ qt/{i18n => po/scripts}/update-po-template | 2 +- qt/po/scripts/upload-latest-template | 6 ++++++ 14 files changed, 43 insertions(+), 44 deletions(-) delete mode 100755 qt/i18n/build-mo-files delete mode 100755 qt/i18n/pull-git delete mode 100755 qt/i18n/sync-po-git rename qt/{i18n => po}/.gitignore (68%) rename qt/{i18n => po}/plurals.json (100%) rename qt/{i18n => po}/requirements.txt (100%) create mode 100755 qt/po/scripts/build-mo-files rename qt/{i18n => po/scripts}/copy-qt-files (100%) rename qt/{tools => po/scripts}/extract-po-string.py (100%) create mode 100755 qt/po/scripts/fetch-latest-translations rename qt/{i18n => po/scripts}/update-po-template (83%) create mode 100755 qt/po/scripts/upload-latest-template diff --git a/Makefile b/Makefile index f1a22e879..b74c1f877 100644 --- a/Makefile +++ b/Makefile @@ -112,10 +112,10 @@ add-buildhash: pull-i18n: (cd rslib/ftl && scripts/fetch-latest-translations) (cd qt/ftl && scripts/fetch-latest-translations) - (cd qt/i18n && ./pull-git) + (cd qt/po && scripts/fetch-latest-translations) .PHONY: push-i18n push-i18n: pull-i18n (cd rslib/ftl && scripts/upload-latest-templates) (cd qt/ftl && scripts/upload-latest-templates) - (cd qt/i18n && ./sync-po-git) + (cd qt/po && scripts/upload-latest-template) diff --git a/qt/Makefile b/qt/Makefile index 457d0012c..85a8db955 100644 --- a/qt/Makefile +++ b/qt/Makefile @@ -25,8 +25,10 @@ all: check ./tools/build_ui.sh @touch $@ -.build/i18n: $(wildcard i18n/po/desktop/*/anki.po) - (cd i18n && ./pull-git && ./build-mo-files && ./copy-qt-files) +.build/i18n: $(wildcard po/repo/desktop/*/anki.po) + (cd po && ./scripts/fetch-latest-translations && \ + ./scripts/build-mo-files && \ + ./scripts/copy-qt-files) @touch $@ TSDEPS := $(wildcard ts/src/*.ts) $(wildcard ts/scss/*.scss) diff --git a/qt/i18n/build-mo-files b/qt/i18n/build-mo-files deleted file mode 100755 index 8feaf7cfe..000000000 --- a/qt/i18n/build-mo-files +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# -# build mo files -# -set -eo pipefail - -targetDir="../aqt_data/locale/gettext" -mkdir -p $targetDir - -echo "Compiling *.po..." -for file in po/desktop/*/anki.po -do - outdir=$(echo "$file" | \ - perl -pe "s%po/desktop/(.*)/anki.po%$targetDir/\1/LC_MESSAGES%") - outfile="$outdir/anki.mo" - mkdir -p $outdir - msgmerge -q "$file" po/desktop/anki.pot | msgfmt - --output-file="$outfile" -done diff --git a/qt/i18n/pull-git b/qt/i18n/pull-git deleted file mode 100755 index aea1c5c43..000000000 --- a/qt/i18n/pull-git +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -if [ ! -d po ]; then - git clone https://github.com/ankitects/anki-desktop-i18n po -fi - -echo "Updating translations from git..." -(cd po && git pull) - -# make sure gettext translations haven't broken something -(cd po && python check-po-files.py) diff --git a/qt/i18n/sync-po-git b/qt/i18n/sync-po-git deleted file mode 100755 index 5d5910185..000000000 --- a/qt/i18n/sync-po-git +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -set -eo pipefail - -# pull any pending changes from git repos -./pull-git - -# upload changes to .pot -./update-po-template -(cd po && git add desktop; git commit -m update; git push) diff --git a/qt/i18n/.gitignore b/qt/po/.gitignore similarity index 68% rename from qt/i18n/.gitignore rename to qt/po/.gitignore index ce405b957..cf4a945f6 100644 --- a/qt/i18n/.gitignore +++ b/qt/po/.gitignore @@ -1,3 +1,3 @@ .build -po +repo ftl diff --git a/qt/i18n/plurals.json b/qt/po/plurals.json similarity index 100% rename from qt/i18n/plurals.json rename to qt/po/plurals.json diff --git a/qt/i18n/requirements.txt b/qt/po/requirements.txt similarity index 100% rename from qt/i18n/requirements.txt rename to qt/po/requirements.txt diff --git a/qt/po/scripts/build-mo-files b/qt/po/scripts/build-mo-files new file mode 100755 index 000000000..d0653351e --- /dev/null +++ b/qt/po/scripts/build-mo-files @@ -0,0 +1,20 @@ +#!/bin/bash +# +# build mo files +# +set -eo pipefail + +targetDir="../aqt_data/locale/gettext" +mkdir -p $targetDir + +echo "Compiling *.repo..." +for file in repo/desktop/*/anki.po +do + outdir=$(echo "$file" | \ + perl -pe "s%repo/desktop/(.*)/anki.po%$targetDir/\1/LC_MESSAGES%") + outfile="$outdir/anki.mo" + mkdir -p $outdir + (msgmerge -q "$file" repo/desktop/anki.pot | msgfmt - --output-file="$outfile") || ( + echo "error building $file" + ) +done diff --git a/qt/i18n/copy-qt-files b/qt/po/scripts/copy-qt-files similarity index 100% rename from qt/i18n/copy-qt-files rename to qt/po/scripts/copy-qt-files diff --git a/qt/tools/extract-po-string.py b/qt/po/scripts/extract-po-string.py similarity index 100% rename from qt/tools/extract-po-string.py rename to qt/po/scripts/extract-po-string.py diff --git a/qt/po/scripts/fetch-latest-translations b/qt/po/scripts/fetch-latest-translations new file mode 100755 index 000000000..286745fe4 --- /dev/null +++ b/qt/po/scripts/fetch-latest-translations @@ -0,0 +1,9 @@ +#!/bin/bash + +echo "Downloading latest translations..." + +if [ ! -d repo ]; then + git clone https://github.com/ankitects/anki-desktop-i18n repo +fi + +(cd repo && git pull) diff --git a/qt/i18n/update-po-template b/qt/po/scripts/update-po-template similarity index 83% rename from qt/i18n/update-po-template rename to qt/po/scripts/update-po-template index a67197e01..de9f425e5 100755 --- a/qt/i18n/update-po-template +++ b/qt/po/scripts/update-po-template @@ -16,5 +16,5 @@ for i in qt/aqt/{*.py,forms/*.py}; do echo $i >> $all done -xgettext -cT: -s --no-wrap --files-from=$all --output=qt/i18n/po/desktop/anki.pot +xgettext -cT: -s --no-wrap --files-from=$all --output=qt/po/repo/desktop/anki.pot rm $all diff --git a/qt/po/scripts/upload-latest-template b/qt/po/scripts/upload-latest-template new file mode 100755 index 000000000..aec43a2d9 --- /dev/null +++ b/qt/po/scripts/upload-latest-template @@ -0,0 +1,6 @@ +#!/bin/bash + +set -eo pipefail + +./update-po-template +(cd repo && git add desktop; git commit -m update; git push)