How can I collect translation strings outside of my project folder using Django's built-in makemessages
facility? The management command makemessages
is very convenient and I'd like to use it for applications located in site-packages.
Asked
Active
Viewed 5,937 times
6

viam0Zah
- 25,949
- 8
- 77
- 100
3 Answers
12
(1) Activate a virtual environment where Django is installed.
(2) Go directory of the app for which you want the messages to be generated:
$ cd path/to/app/in/site/packages/
(3) Make sure it has "locale" directory. If not - make one.
$ mkdir locale
(4) From your app directory run the following command:
$ django-admin.py makemessages -l [LANGUAGE_CODE]
Example for Dutch:
$ django-admin.py makemessages -l nl
Example for Russian:
$ django-admin.py makemessages -l ru

Artur Barseghyan
- 12,746
- 4
- 52
- 44
-
I'm not sure this is what the OP asks, does this collect strings *outside* of the project? As far as I know, this will just collect strings from html, txt, and py files inside of the project or app. – gdvalderrama Sep 27 '17 at 10:19
-
3Yes, it does collect strings from the package you are running it from. That's why we have ``cd path/to/app/in/site/packages/``. – Artur Barseghyan Sep 27 '17 at 13:47
2
Other than makemessages I found PyBabel very useful. Here is a bind to Django itself: http://babel.edgewall.org/wiki/BabelDjango

yaanno
- 211
- 1
- 5
0
With symbol links (ln -s) but it's not very convenient. Usually if the apps are on PYTHONPATH shouldn't the translations folders be catched by makemessages ?

coulix
- 3,328
- 6
- 55
- 81
-
Now I *do* use symlinks but that's an ugly workaround. It's hard-coded in *makemessages.py* to find files in the current working directory, it skips PYTHONPATH. – viam0Zah Nov 04 '10 at 13:09
-
When using symlinks remember to add the `--symlinks` option to [`makemessages`](https://docs.djangoproject.com/en/dev/ref/django-admin/#django-admin-makemessages) – gdvalderrama Sep 27 '17 at 10:20