Skip to content

Instantly share code, notes, and snippets.

Last active Dec 22, 2015
What would you like to do?
Check the I18N strings in Horizon repository are updated and create a new commit if any
#!/bin/bash -e
# Latest version is available at
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
git checkout master
git pull
# Update PO files
source .venv/bin/activate
cd horizon
echo "horizon:"
../ makemessages -l en --no-obsolete
echo "horizon javascript"
../ makemessages -d djangojs -l en --no-obsolete
cd ../openstack_dashboard
echo "openstack_dashboard"
../ makemessages -l en --ignore=openstack/common/* --no-obsolete
cd ..
for f in $POFILES; do
is_updated $f
if ! git status | grep modified: >/dev/null; then
echo "***** No changes in PO files *****"
exit 1
git checkout -b "update-source-po"
git add -u
git commit -m "Update English PO files."
echo "-----------------------------------------"
git show --stat | cat
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