parallelize locale compilation (#21889)
This commit is contained in:
Родитель
72a2f69493
Коммит
e374a72d68
|
@ -5,6 +5,19 @@
|
||||||
# Make this script fail if any command exits wit exit code != 0
|
# Make this script fail if any command exits wit exit code != 0
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
function process_po_file() {
|
||||||
|
pofile=$1
|
||||||
|
dir=$(dirname "$pofile")
|
||||||
|
lang=$(echo "$pofile" | cut -d "/" -f2)
|
||||||
|
stem=$(basename "$pofile" .po)
|
||||||
|
touch "${dir}/${stem}.mo"
|
||||||
|
dennis-cmd lint --errorsonly "$pofile" && msgfmt -o "${dir}/${stem}.mo" "$pofile"
|
||||||
|
}
|
||||||
|
|
||||||
|
# We are spawning sub processes with `xargs`
|
||||||
|
# and the function needs to be available in that sub process
|
||||||
|
export -f process_po_file
|
||||||
|
|
||||||
function usage() {
|
function usage() {
|
||||||
echo "syntax:"
|
echo "syntax:"
|
||||||
echo "compile-mo.sh locale-dir/"
|
echo "compile-mo.sh locale-dir/"
|
||||||
|
@ -17,34 +30,7 @@ if [[ ($# -ne 1) || (! -d "$1") ]]; then usage; fi
|
||||||
hash dennis-cmd 2>/dev/null || source $VENV/bin/activate
|
hash dennis-cmd 2>/dev/null || source $VENV/bin/activate
|
||||||
|
|
||||||
echo "compiling django.po..."
|
echo "compiling django.po..."
|
||||||
for pofile in `find $1 -type f -name "django.po"`; do
|
find $1 -type f -name "django.po" -print0 | xargs -0 -n1 -P4 bash -c 'process_po_file "$@"' _
|
||||||
dir=`dirname $pofile`
|
|
||||||
lang=`echo $pofile | cut -d "/" -f2`
|
|
||||||
stem=`basename $pofile .po`
|
|
||||||
# lint the .po file
|
|
||||||
dennis-cmd lint --errorsonly "$pofile"
|
|
||||||
|
|
||||||
if [ $? -ne 0 ]
|
|
||||||
then
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
msgfmt -o ${dir}/${stem}.mo $pofile
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "compiling djangojs.po..."
|
echo "compiling djangojs.po..."
|
||||||
for pofile in `find $1 -type f -name "djangojs.po"`; do
|
find $1 -type f -name "djangojs.po" -print0 | xargs -0 -n1 -P4 bash -c 'process_po_file "$@"' _
|
||||||
dir=`dirname $pofile`
|
|
||||||
lang=`echo $pofile | cut -d "/" -f2`
|
|
||||||
stem=`basename $pofile .po`
|
|
||||||
touch "${dir}/${stem}.mo"
|
|
||||||
# lint the .po file
|
|
||||||
dennis-cmd lint --errorsonly "$pofile"
|
|
||||||
if [ $? -ne 0 ]
|
|
||||||
then
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
msgfmt -o ${dir}/${stem}.mo $pofile
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче