From 86bb6760074af12e8d3078226a5397ad46a3a59a Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 3 Jan 2020 08:24:59 +1000 Subject: [PATCH] integrate i18n into new structure --- qt/Makefile | 6 +++++- qt/i18n/Makefile | 21 --------------------- qt/i18n/build-mo-files | 2 +- qt/i18n/copy-qt-files | 4 ++-- qt/i18n/update-crowdin | 4 ++++ qt/i18n/update-from-crowdin | 10 ++++++++++ qt/i18n/update-pot | 4 ++-- scripts.inc | 5 +---- 8 files changed, 25 insertions(+), 31 deletions(-) delete mode 100644 qt/i18n/Makefile diff --git a/qt/Makefile b/qt/Makefile index c987f7298..90e355d5a 100644 --- a/qt/Makefile +++ b/qt/Makefile @@ -26,13 +26,17 @@ all: check ./tools/build_ui.sh @touch $@ +.build/i18n: $(wildcard i18n/translations/anki.pot/*) + (cd i18n && ./build-mo-files && ./copy-qt-files) + @touch $@ + TSDEPS := $(wildcard ts/src/*.ts) .build/js: $(TSDEPS) (cd ts && npm i && npm run build) @touch $@ -BUILD_STEPS := .build/run-deps .build/dev-deps .build/js .build/ui +BUILD_STEPS := .build/run-deps .build/dev-deps .build/js .build/ui .build/i18n # Checking ###################### diff --git a/qt/i18n/Makefile b/qt/i18n/Makefile deleted file mode 100644 index c2d6607a9..000000000 --- a/qt/i18n/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -SHELL := bash -.SHELLFLAGS := -eu -o pipefail -c -.DELETE_ON_ERROR: -MAKEFLAGS += --warn-undefined-variables -MAKEFLAGS += --no-builtin-rules - -$(shell mkdir -p .build) - -.PHONY: develop -develop: .build/develop - -.PHONY: clean -clean: - -.PHONY: build -build: - -.build/develop: $(wildcard translations/anki.pot/*) - ./build-mo-files - ./copy-qt-files - @touch $@ diff --git a/qt/i18n/build-mo-files b/qt/i18n/build-mo-files index 5de6492b6..6b9ba288f 100755 --- a/qt/i18n/build-mo-files +++ b/qt/i18n/build-mo-files @@ -3,7 +3,7 @@ # build mo files # -targetDir="../anki-qt/aqt_data/locale" +targetDir="../aqt_data/locale" mkdir -p $targetDir echo "Compiling *.po..." diff --git a/qt/i18n/copy-qt-files b/qt/i18n/copy-qt-files index 8ad7e21b4..a6de40fe2 100755 --- a/qt/i18n/copy-qt-files +++ b/qt/i18n/copy-qt-files @@ -2,8 +2,8 @@ set -e -out=../anki-qt/aqt_data/locale +out=../aqt_data/locale mkdir -p $out qtTranslations=$(python -c "from PyQt5.QtCore import *; print(QLibraryInfo.location(QLibraryInfo.TranslationsPath))") -rsync -av $qtTranslations/qt* $out +rsync -a $qtTranslations/qt* $out diff --git a/qt/i18n/update-crowdin b/qt/i18n/update-crowdin index fc9b8d341..a0b070c3c 100755 --- a/qt/i18n/update-crowdin +++ b/qt/i18n/update-crowdin @@ -1,4 +1,8 @@ #!/bin/bash +# +# Sends the latest strings from the source code to crowdin. +# To use this, key must be set to a crowdin API key. +# set -e diff --git a/qt/i18n/update-from-crowdin b/qt/i18n/update-from-crowdin index af1495d1d..ddaae89a3 100755 --- a/qt/i18n/update-from-crowdin +++ b/qt/i18n/update-from-crowdin @@ -1,4 +1,9 @@ #!/bin/bash +# +# Pulls the latest translations from crowdin and commits them here. +# To use this, key must be set to a crowdin API key. +# Aborts if there are any uncommited changes prior to running. +# set -e @@ -9,6 +14,11 @@ if [ "$key" = "" ]; then exit 1 fi +if ! git diff-index --quiet HEAD --; then + echo "working directory is not clean" + exit 1 +fi + # fetch translations from crowdin if [ ! -f all.zip ]; then curl https://api.crowdin.com/api/project/$proj/export?key=$key diff --git a/qt/i18n/update-pot b/qt/i18n/update-pot index a90c8c7b0..f2e7fdb6e 100755 --- a/qt/i18n/update-pot +++ b/qt/i18n/update-pot @@ -5,10 +5,10 @@ all=all.files echo "Updating anki.pot..." -for i in ../anki-lib-python/anki/{*.py,importing/*.py,template/*.py}; do +for i in ../../pylib/anki/{*.py,importing/*.py,template/*.py}; do echo $i >> $all done -for i in ../anki-qt/aqt/{*.py,forms/*.py}; do +for i in ../aqt/{*.py,forms/*.py}; do echo $i >> $all done diff --git a/scripts.inc b/scripts.inc index 1beb98a2b..3c031766c 100644 --- a/scripts.inc +++ b/scripts.inc @@ -3,7 +3,7 @@ set -e CHECKABLE="rslib pylib qt" -DEVEL="rspy pylib qt i18n" +DEVEL="rspy pylib qt" if [ "$UNOPT" = "" ]; then BUILDFLAGS="--release --strip" @@ -23,6 +23,3 @@ fi # add qt if missing python -c 'import PyQt5' 2>/dev/null || pip install -r qt/requirements.qt - -# fetch i18n files -test -d i18n || git clone --depth 1 https://github.com/ankitects/anki-i18n i18n