I included some fields from localflavor.es.forms in a project, and
expected the error messages to appear translated, as localflavor
already has a catalog. However the messages only appeared in English.
Turns out the localflavor catalog is not automatically loaded, it must
be included manually in the LOCALE_PATHS setting as implied by the
internationalization documentation [1], because only the django/conf/
locale catalog is loaded automatically.
The code snippet for settings.py is simple enough:
import django
import os
DJANGO_BASEDIR = os.path.dirname(django.__file__)
LOCALE_PATHS = (
os.path.join(DJANGO_BASEDIR, 'contrib', 'localflavor',
'locale'),
)
I think this is acceptable, but should at least be documented in a
section in the localflavor documentation [2]. Another possibility
would be tweaking the code to make sure that the localflavor catalog
is automatically loaded, but I haven't looked yet into how to do that.
What solution would be better? If there is an easy and clean way to
load the localflavor catalog when required and the USE_I18N settings
is True I think it would be best for users, because it's reasonable to
expect Django catalogs to be loaded automatically.
Either way once a decision is reached I volunteer to open a ticket and
submit a patch.
[1]
http://docs.djangoproject.com/en/1.3/howto/i18n/#using-translations-in-your-own-projects
[2]
http://docs.djangoproject.com/en/1.3/ref/contrib/localflavor/