mirror of
https://gh.wpcy.net/https://github.com/WeblateOrg/weblate.git
synced 2026-05-03 10:29:08 +08:00
80 lines
2.4 KiB
Bash
Executable file
80 lines
2.4 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
# Renerates .po files used for translating Weblate
|
|
|
|
# Exit on failure
|
|
set -e
|
|
|
|
export CI_DATABASE=postgresql
|
|
export DJANGO_SETTINGS_MODULE=weblate.settings_test
|
|
|
|
version=`python -c 'import weblate; print(weblate.VERSION_BASE)'`
|
|
|
|
# Lock Weblate
|
|
wlc lock weblate/application
|
|
wlc lock weblate/javascript
|
|
wlc lock weblate/languages
|
|
wlc lock weblate/documentation
|
|
|
|
# Push changes from Weblate to GitHub
|
|
wlc push weblate
|
|
|
|
# Update Weblate remote
|
|
git remote update weblate
|
|
|
|
# Pull changes from GitHub
|
|
git rebase --onto weblate/master
|
|
|
|
# Update po files itself
|
|
./manage.py makemessages --keep-pot -a -i 'data/*' -i 'docs/*' -i 'examples/*' -i 'build/*'
|
|
./manage.py makemessages --keep-pot -a -i 'data/*' -i 'docs/*' -i 'examples/*' -i 'build/*' -d djangojs
|
|
|
|
# Fix Report-Msgid-Bugs-To as it gets removed
|
|
sed \
|
|
-i \
|
|
-e 's/"Report-Msgid-Bugs-To:.*/"Report-Msgid-Bugs-To: weblate@lists.cihar.com\\n"/' \
|
|
-e 's/"Project-Id-Version:.*/"Project-Id-Version: Weblate '$version'\\n"/' \
|
|
weblate/locale/*/*/*.po weblate/locale/*.pot \
|
|
weblate/langdata/locale/*/*/*.po weblate/langdata/locale/*.pot
|
|
|
|
# Include language names from CLDR and iso-codes
|
|
for locale in weblate/langdata/locale/*/LC_MESSAGES/django.po ; do
|
|
code=${locale#weblate/langdata/locale/}
|
|
code=${code%/LC_MESSAGES/django.po}
|
|
for file in scripts/iso-codes/iso_639-2/$code.po scripts/iso-codes/iso_639-2/$code.po scripts/language-data/languages-po/$code.po ; do
|
|
if [ -f $file ] ; then
|
|
msgmerge --previous -C $file -U $locale weblate/langdata/locale/django.pot
|
|
fi
|
|
done
|
|
done
|
|
|
|
# Include translations from Django
|
|
for locale in weblate/locale/*/LC_MESSAGES/django.po ; do
|
|
code=${locale#weblate/locale/}
|
|
code=${code%/LC_MESSAGES/django.po}
|
|
file=~/work/django/django/conf/locale/$code/LC_MESSAGES/django.po
|
|
if [ -f $file ] ; then
|
|
msgmerge --previous -C $file -U $locale weblate/locale/django.pot
|
|
fi
|
|
done
|
|
|
|
# Update PO files for documentation
|
|
make -C docs update-po
|
|
|
|
# Commit changes
|
|
git add weblate/locale/*/*/*.po
|
|
git add weblate/locale/*.pot
|
|
git add weblate/langdata/locale/*/*/*.po
|
|
git add weblate/langdata/locale/*.pot
|
|
git add $(find docs/locales/ -name '*.po' -o -name '*.pot')
|
|
|
|
git commit -m "i18n: Update PO files"
|
|
|
|
# Push changes
|
|
git push
|
|
|
|
# Unlock Weblate
|
|
wlc unlock weblate/application
|
|
wlc unlock weblate/javascript
|
|
wlc unlock weblate/languages
|
|
wlc unlock weblate/documentation
|