Skip to content

Commit

Permalink
Sync with transifex
Browse files Browse the repository at this point in the history
  • Loading branch information
xispa committed Jun 17, 2022
1 parent a5295a0 commit 5d6bdeb
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# --- PLEASE EDIT THE LINES BELOW CORRECTLY ---
# SOME DESCRIPTIVE TITLE.
# FIRST AUTHOR <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down
56 changes: 51 additions & 5 deletions templates/update_translations.in
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

0 comments on commit 5d6bdeb

Please sign in to comment.