Skip to content

Commit

Permalink
Update templates
Browse files Browse the repository at this point in the history
  • Loading branch information
luthando5 committed Nov 1, 2023
1 parent 65570a1 commit 7f5d0ac
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 47 deletions.
63 changes: 19 additions & 44 deletions templates/update_translations.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

BASE=${buildout:directory}
I18N=$BASE/bin/i18ndude
SRC=$BASE/src/senaite/core
SRC=$BASE/src/bika/extras
SRC_BIKA=$BASE/src/bika/lims
LOCALES=$SRC/locales
EXCLUDE="build *.html"
Expand Down Expand Up @@ -58,51 +58,26 @@ find $LOCALES -name "*.mo" -delete
# Pull Transifex
tx_pull

# Generate the senaite.core Domain
echo "Processing domain: senaite.core"
# Generate the bika.extras Domain
echo "Processing domain: bika.extras"
# Flush the english (transifex source language) po files
# If we don't do this, new senaite.core-manual.pot translations won't be synced.
echo -n "" > $LOCALES/en/LC_MESSAGES/senaite.core.po
# Re-scan the source code for new strings and create a temporary senaite.core-bika.pot
$I18N rebuild-pot --pot $LOCALES/senaite.core-bika.pot --exclude "$EXCLUDE" --create senaite.core $SRC_BIKA
# Re-scan the source code for new strings and create a temporary senaite.core-tmp.pot
$I18N rebuild-pot --pot $LOCALES/senaite.core-tmp.pot --exclude "$EXCLUDE" --create senaite.core $SRC
# Merge the manual translations of senaite.core-bika.pot into the temporary senaite.core-tmp.pot
$I18N merge --pot $LOCALES/senaite.core-tmp.pot --merge $LOCALES/senaite.core-bika.pot
rm $LOCALES/senaite.core-bika.pot
# Merge the manual translations of senaite.core-manual.pot into the temporary senaite.core-tmp.pot
$I18N merge --pot $LOCALES/senaite.core-tmp.pot --merge $LOCALES/senaite.core-manual.pot
# Overwrite the existing senaite.core.pot
mv $LOCALES/senaite.core-tmp.pot $LOCALES/senaite.core.pot
# Synchronize all .po files with the new senaite.core.pot
$I18N sync --pot $LOCALES/senaite.core.pot $LOCALES/*/LC_MESSAGES/senaite.core.po
echo "Processing domain: senaite.core [DONE]"
# If we don't do this, new bika.extras-manual.pot translations won't be synced.
echo -n "" > $LOCALES/en/LC_MESSAGES/bika.extras.po
# Re-scan the source code for new strings and create a temporary bika.extras-bika.pot
$I18N rebuild-pot --pot $LOCALES/bika.extras-bika.pot --exclude "$EXCLUDE" --create bika.extras $SRC_BIKA
# Re-scan the source code for new strings and create a temporary bika.extras-tmp.pot
$I18N rebuild-pot --pot $LOCALES/bika.extras-tmp.pot --exclude "$EXCLUDE" --create bika.extras $SRC
# Merge the manual translations of nika.extras-bika.pot into the temporary bika.extras-tmp.pot
$I18N merge --pot $LOCALES/bika.extras-tmp.pot --merge $LOCALES/bika.extras-bika.pot
rm $LOCALES/bika.extras-bika.pot
# Merge the manual translations of bika.extras-manual.pot into the temporary bika.extras-tmp.pot
$I18N merge --pot $LOCALES/bika.extras-tmp.pot --merge $LOCALES/bika.extras-manual.pot
# Overwrite the existing bika.extras.pot
mv $LOCALES/bika.extras-tmp.pot $LOCALES/bika.extras.pot
# Synchronize all .po files with the new bika.extras.pot
$I18N sync --pot $LOCALES/bika.extras.pot $LOCALES/*/LC_MESSAGES/bika.extras.po
echo "Processing domain: bika.extras [DONE]"
echo ""

# Generate Plone Domain
echo "Processing domain: plone"
# Flush the english (transifex source language) po files
# If we don't do this, new plone-manual.pot translations won't be synced.
echo -n "" > $LOCALES/en/LC_MESSAGES/plone.po
# Re-scan the source code for new strings and create a temporary senaite.core-bika.pot
$I18N rebuild-pot --pot $LOCALES/plone-bika.pot --exclude "$EXCLUDE" --create plone $SRC_BIKA
# Re-scan the source code for new strings and create a temporary senaite.core-tmp.pot
$I18N rebuild-pot --pot $LOCALES/plone-tmp.pot --exclude "$EXCLUDE" --create plone $SRC
# Merge the manual translations of senaite.core-bika.pot into the temporary senaite.core-tmp.pot
$I18N merge --pot $LOCALES/plone-tmp.pot --merge $LOCALES/plone-bika.pot
rm $LOCALES/plone-bika.pot
# Remove those resources that already exists in senaite.core domain
# We need this because in Python files, i18ndude simply looks for text within an
# underscore method: _("...") without known the domain. Therefore, resources
# from senaite.core domain are also grabbed inside plone-tmp.pot
# Store the difference to plone.pot
$I18N filter $LOCALES/plone-tmp.pot $LOCALES/senaite.core.pot > $LOCALES/plone.pot
# Remove plone-tmp.pot
rm $LOCALES/plone-tmp.pot
# Synchronize all .po files with the new plone.pot
$I18N sync --pot $LOCALES/plone.pot $LOCALES/*/LC_MESSAGES/plone.po
echo "Processing domain: plone [DONE]"


# Push Transifex
tx_push
4 changes: 2 additions & 2 deletions templates/write_code_headers.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ SRC_DIR = "${buildout:directory}/src/senaite"
YEAR_FROM = "2018"
TEMPLATE = """# -*- coding: utf-8 -*-
#
# This file is part of SENAITE.CORE.
# This file is part of BIKA.EXTRAS.
#
# SENAITE.CORE is free software: you can redistribute it and/or modify it under
# BIKA.EXTRAS is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, version 2.
#
Expand Down
2 changes: 1 addition & 1 deletion templates/write_contributors.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import subprocess
import sys

SRC = "${buildout:directory}"
LOCALES = SRC + '/src/senaite/core/locales'
LOCALES = SRC + '/src/bika/extras/locales'
OUTFILE = SRC + '/CONTRIBUTORS.rst'

# User names or emails to be replaced. If the value is None, the committer will
Expand Down

0 comments on commit 7f5d0ac

Please sign in to comment.