I have a template which uses {{date|date:"l j F"}}
to localize a date. When I use it in a view this works fine (served from either ./manage.py runserver
or uwsgi.
When I use this template to send an email from the command line using a management/commands command however, it falls back to the en_US locale. (Friday instead of Vrijdag etc)
I've included settings.LANGUAGE_CODE
, settings.USE_L10N
and settings.USE_I18N
in the template to make sure which locale is being used, and then it says nl_NL in both cases, as expected.
Any ideas on how to fix this?
It turns out one has to manually activate translation in management commands:
from django.utils import translation
translation.activate(settings.LANGUAGE_CODE)
did the trick. See https://code.djangoproject.com/ticket/10078
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With