Last active
December 22, 2015 22:09
-
-
Save amotoki/6537841 to your computer and use it in GitHub Desktop.
Check the I18N strings in Horizon repository are updated and create a new commit if any
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
# Latest version is available at | |
# https://github.com/amotoki/horizon-i18n-tools/blob/master/po-file-update.sh | |
function is_updated() { | |
local file=$1 | |
git diff $file | \ | |
grep -E '^[-+]' | \ | |
grep -v -E '^[-+]#:' | \ | |
grep -v -E '^[-+]"POT-Creation-Date:' | \ | |
grep -v -E '^(\+\+\+|---) [ab]/' >/dev/null || revert_po_file $file | |
} | |
function revert_po_file() { | |
echo "$f is unchanged" | |
git checkout -- $file | |
} | |
cd $HOME/horizon | |
POFILES=$(ls */locale/en/LC_MESSAGES/*.po) | |
if git branch | grep "update-source-po"; then | |
echo "branch 'update-source-po' already exists. Please check it." | |
exit 2 | |
fi | |
git checkout master | |
git pull | |
# Update PO files | |
source .venv/bin/activate | |
cd horizon | |
echo "horizon:" | |
../manage.py makemessages -l en --no-obsolete | |
echo "horizon javascript" | |
../manage.py makemessages -d djangojs -l en --no-obsolete | |
cd ../openstack_dashboard | |
echo "openstack_dashboard" | |
../manage.py makemessages -l en --ignore=openstack/common/* --no-obsolete | |
cd .. | |
deactivate | |
for f in $POFILES; do | |
is_updated $f | |
done | |
if ! git status | grep modified: >/dev/null; then | |
echo "***** No changes in PO files *****" | |
exit 1 | |
fi | |
git checkout -b "update-source-po" | |
git add -u | |
git commit -m "Update English PO files." | |
echo "-----------------------------------------" | |
git show --stat | cat | |
echo | |
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | |
echo "!!!!! English PO files are updated. !!!!!" | |
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment