Django i18n: makemessages only on site level possible?
I have several strings in my site that don't belong to any app, for example
{% block title %}{% trans "Login" %}{% endblock %}
or a modified authentication form used to set the locale cookie
class AuthenticationFormWithLocaleOption(AuthenticationForm):
locale = forms.ChoiceField(choices = settings.LANGUAGES,
required = False,
initial = preselectedLocale,
label = _("Locale/language"))
Now when I execute django-admin.py makemessages --all -e .html,.template
in the site directory, it extracts the strings from all Python, .html and .template files, including those in my apps. That is because I develop my apps inside that directory:
Directory structure: sitename myapp1 myapp2
Is there any way to extract all strings that a开发者_开发问答re not in my apps?
The only solution I found is to move the app directories outside the site directory structure, but I'm using bzr-externals (similar to git submodules or svn externals) so that doesn't make sense in my case.
Moving stuff that needs translation into a new app is also possible but I don't know if that is the only reasonable solution.
According to the documentation you could run makemessages
from the app you like to translate, creating only the message files for that specific app. It is also possible to filter out some specific folders by using makemessages' --ignore
argument. The results between those two would be quite different, though.
精彩评论