Make messages i18n for specific directories or exclude directories
django, internationalization, python, terminal
Solution
I have written a short script to iterate over the folders in my project directory and create translations if the folder contains a locale folder. The script which can be easily modified to exclude apps/directories if required
My project folder structure is
Project
--App1
----locale
--App2
----locale
--ProjectRoot - settings.py file is in ProjectRoot folder
----locale
etc
This script (`run_makemessages.py`) lives in the `Project` folder
import os
project_root = "/path/to/your/Project"
dirs = os.listdir(project_root)
for app in dirs:
app_path = os.path.join(project_root, app)
locale_path = os.path.join(app_path, "locale")
if(os.path.exists(locale_path)): #modify this condition for exclusion of specific folders
os.chdir(app_path)
os.system("django-admin.py makemessages -a --no-wrap")
and is called with `python run_makemessages.py` - ie it's called directly and doesn't use django-admin or manage.py
Problem
My site structure looks like this: ``` project --apps ----app1 ----app2 --docs --templates ----module1 ----module2 ----module3 ``` how can I run ``` django-admin.py makemessages --locale=en ``` on all apps and template dirs but leave out module1 and module3?