Last Updated: February 25, 2016
·
258
· breard-r

Inline locale generation for a Django project

Generating the locales for all your application within a Django project can be painful. You have to get into each application directory and invoke "django-admin.py compilemessages". This can be solved by the following shell command which look for apps with a "locale" directory and and generate its locale.

for dir in $(find ./ -maxdepth 1 -mindepth 1 -type d -not -path '*/\.*'); do if [ -d "$dir/locale" ]; then cd "$dir"; django-admin.py compilemessages; cd ..; fi; done

Obviously, a variation of this command can be used with "makemessages" instead of "compilemessages".