From 5d6bdeb197713702ad5e50288d621a6bbfe345fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jordi=20Puiggen=C3=A9?= Date: Fri, 17 Jun 2022 19:34:17 +0200 Subject: [PATCH] Sync with transifex --- .../en/LC_MESSAGES/senaite.microorganism.po | 5 +- .../locales/senaite.microorganism.pot | 2 +- templates/update_translations.in | 56 +++++++++++++++++-- 3 files changed, 53 insertions(+), 10 deletions(-) diff --git a/src/senaite/microorganism/locales/en/LC_MESSAGES/senaite.microorganism.po b/src/senaite/microorganism/locales/en/LC_MESSAGES/senaite.microorganism.po index 8035661..cabbabf 100644 --- a/src/senaite/microorganism/locales/en/LC_MESSAGES/senaite.microorganism.po +++ b/src/senaite/microorganism/locales/en/LC_MESSAGES/senaite.microorganism.po @@ -1,10 +1,7 @@ -# --- PLEASE EDIT THE LINES BELOW CORRECTLY --- -# SOME DESCRIPTIVE TITLE. -# FIRST AUTHOR , YEAR. msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2022-06-17 17:23+0000\n" +"POT-Creation-Date: 2022-06-17 17:31+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/src/senaite/microorganism/locales/senaite.microorganism.pot b/src/senaite/microorganism/locales/senaite.microorganism.pot index 92acba6..1cedc9f 100644 --- a/src/senaite/microorganism/locales/senaite.microorganism.pot +++ b/src/senaite/microorganism/locales/senaite.microorganism.pot @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2022-06-17 17:23+0000\n" +"POT-Creation-Date: 2022-06-17 17:31+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/templates/update_translations.in b/templates/update_translations.in index 9a1a865..1973596 100644 --- a/templates/update_translations.in +++ b/templates/update_translations.in @@ -2,7 +2,9 @@ BASE=${buildout:directory} I18N=$BASE/bin/i18ndude -PRODUCT_SRC=${buildout:directory}/src/senaite/microorganism +SRC=$BASE/src/senaite/microorganism +LOCALES=$SRC/locales +DOMAIN=senaite.microorganism function die() { echo "ERROR: $1" @@ -15,17 +17,61 @@ if test ! -x $I18N; then die "i18ndude not installed" fi -DOMAIN=senaite.microorganism -LOCALES=$PRODUCT_SRC/locales +# Check Transifex Installed +function has_tx() { + TX=$(which tx) + if test ! -x $TX || test -z $TX; then + return -1 + else + return 0 + fi +} + +# Transifex Pull Function +function tx_pull() { + if has_tx; then + cd $LOCALES + echo "Transifex Pull" + tx pull -a -f + else + die "Please install the Transifex Client first: $ pip install transifex-client" + fi + cd $BASE +} + +# Transifex Push Function +function tx_push() { + if has_tx; then + cd $LOCALES + echo "Transifex Push" + tx push -s -t --skip + else + die "Please install the Transifex Client first: $ pip install transifex-client" + fi + cd $BASE +} + +# Clean all generated .mo files +find $LOCALES -name "*.mo" -delete + +# Pull Transifex +tx_pull + echo "Processing Domain $DOMAIN" +# Flush the english po files +# If we don't do this, new $DOMAIN-manual.pot translations won't be synced. +echo -n "" > $LOCALES/en/LC_MESSAGES/$DOMAIN.po # Re-scan the source code for new strings and create a temporary $DOMAIN-tmp.pot -$I18N rebuild-pot --pot $LOCALES/$DOMAIN-tmp.pot --exclude "build" --create $DOMAIN $PRODUCT_SRC +$I18N rebuild-pot --pot $LOCALES/$DOMAIN-tmp.pot --exclude "build" --create $DOMAIN $SRC # Merge the manual translations of $DOMAIN-manual.pot into the temporary $DOMAIN-tmp.pot $I18N merge --pot $LOCALES/$DOMAIN-tmp.pot --merge $LOCALES/$DOMAIN-manual.pot -# Merge the content translations of $DOMAIN-manual.pot into the temporary $DOMAIN-tmp.pot +# Merge the content translations of $DOMAIN-content.pot into the temporary $DOMAIN-tmp.pot # $I18N merge --pot $LOCALES/$DOMAIN-tmp.pot --merge $LOCALES/$DOMAIN-content.pot # Overwrite the existing $DOMAIN.pot mv $LOCALES/$DOMAIN-tmp.pot $LOCALES/$DOMAIN.pot # Synchronize all .po files with the new $DOMAIN.pot $I18N sync --pot $LOCALES/$DOMAIN.pot $LOCALES/*/LC_MESSAGES/$DOMAIN.po echo "Processing Domain $DOMAIN [DONE]" + +# Push Transifex +tx_push