mirror of
https://github.com/jazzband/django-admin2.git
synced 2026-05-03 21:14:46 +00:00
Replaced shell script with fabfile
This commit is contained in:
parent
bed88973d7
commit
fd98d91614
2 changed files with 46 additions and 97 deletions
46
fabfile.py
vendored
Normal file
46
fabfile.py
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import print_function, division, absolute_import, unicode_literals
|
||||
|
||||
from fabric.api import local, lcd
|
||||
from fabric.contrib.console import confirm
|
||||
|
||||
|
||||
DIRS = ['djadmin2', 'example/blog', 'example2/polls']
|
||||
|
||||
|
||||
def _run(command, directory):
|
||||
with lcd(directory):
|
||||
print('\n### Processing %s...' % directory)
|
||||
local(command)
|
||||
|
||||
|
||||
def makemessages():
|
||||
command = 'django-admin.py makemessages -a'
|
||||
for d in DIRS:
|
||||
_run(command, d)
|
||||
|
||||
|
||||
def compilemessages():
|
||||
command = 'django-admin.py compilemessages'
|
||||
for d in DIRS:
|
||||
_run(command, d)
|
||||
|
||||
|
||||
def checkmessages():
|
||||
command = 'ls -1 locale/*/LC_MESSAGES/django.po | xargs -I {} msgfmt -c {}'
|
||||
for d in DIRS:
|
||||
_run(command, d)
|
||||
|
||||
|
||||
def pulltx():
|
||||
print('\n### Pulling new translations from Transifex...')
|
||||
local('tx pull -a')
|
||||
|
||||
|
||||
def pushtx():
|
||||
print('\n### Pushing translations and sources to Transifex...')
|
||||
print('Warning: This might destroy existing translations. Probably you should pull first.')
|
||||
if confirm('Continue anyways?', default=False):
|
||||
local('tx push -s -t')
|
||||
else:
|
||||
print('Aborting.')
|
||||
97
i18n.sh
97
i18n.sh
|
|
@ -1,97 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
### Helper functions
|
||||
|
||||
function assert_django {
|
||||
hash django-admin.py 2>/dev/null ||
|
||||
{ echo >&2 "django-admin.py not found. Please install Django."; exit 1; }
|
||||
}
|
||||
|
||||
function assert_tx {
|
||||
hash tx 2>/dev/null ||
|
||||
{ echo >&2 "tx not found. Please install transifex-client."; exit 1; }
|
||||
}
|
||||
|
||||
function are_you_sure {
|
||||
read -r -p "$1 Are you sure? [y/n] " response
|
||||
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]
|
||||
then
|
||||
:
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
### Command functions
|
||||
|
||||
function makemessages {
|
||||
assert_django
|
||||
echo "### Processing djadmin2..."
|
||||
( cd djadmin2; django-admin.py makemessages -a )
|
||||
echo "### Processing example app..."
|
||||
( cd example/blog; django-admin.py makemessages -a )
|
||||
echo "### Processing example2 app..."
|
||||
( cd example2/polls; django-admin.py makemessages -a )
|
||||
}
|
||||
|
||||
function compilemessages {
|
||||
assert_django
|
||||
echo "### Processing djadmin2..."
|
||||
( cd djadmin2; django-admin.py compilemessages )
|
||||
echo "### Processing example app..."
|
||||
( cd example/blog; django-admin.py compilemessages )
|
||||
echo "### Processing example2 app..."
|
||||
( cd example2/polls; django-admin.py compilemessages )
|
||||
}
|
||||
|
||||
function checkmessages {
|
||||
ls -1 djadmin2/locale/*/LC_MESSAGES/django.po | xargs -I {} msgfmt -c {}
|
||||
ls -1 example/blog/locale/*/LC_MESSAGES/django.po | xargs -I {} msgfmt -c {}
|
||||
ls -1 example2/polls/locale/*/LC_MESSAGES/django.po | xargs -I {} msgfmt -c {}
|
||||
}
|
||||
|
||||
function pulltx {
|
||||
assert_tx
|
||||
echo "### Pulling new translations from Transifex..."
|
||||
tx pull -a
|
||||
}
|
||||
|
||||
function pushtx {
|
||||
assert_tx
|
||||
are_you_sure "Warning: This might destroy existing translations. Probably you should pull first."
|
||||
echo "### Pushing translations and sources to Transifex..."
|
||||
tx push -s -t
|
||||
}
|
||||
|
||||
|
||||
### Parse arguments
|
||||
|
||||
case $1 in
|
||||
"")
|
||||
echo "Available commands:"
|
||||
echo "--- makemessages: Generate or update .po files"
|
||||
echo "--- compilemessages: Compile .po files to .mo files";
|
||||
echo "--- checkmessages: Check .po files for syntax errors";
|
||||
echo "--- pulltx: Pull new translations from Transifex";
|
||||
echo "--- pushtx: Push translations and sources to Transifex";
|
||||
;;
|
||||
"makemessages")
|
||||
makemessages
|
||||
;;
|
||||
"compilemessages")
|
||||
compilemessages
|
||||
;;
|
||||
"checkmessages")
|
||||
checkmessages
|
||||
;;
|
||||
"pulltx")
|
||||
pulltx
|
||||
;;
|
||||
"pushtx")
|
||||
pushtx
|
||||
;;
|
||||
*)
|
||||
echo "Unknown command: $1"
|
||||
;;
|
||||
esac
|
||||
Loading…
Reference in a new issue