Hi,
I'm learning Django Rest Framework but otherwise I'm quite proficient with
Django.
I have a website which uses translations, the usual stuff: {% trans %}, {%
blocktrans %}, but also JavaScriptCatalog for xhr. So far, so good.
Everything is translated into one of the website's languages, English and
Polish.
However, I also have asynchronous pagination using rest framework and xhr.
The dates returned by my xhr / REST requests are not translated, even with
Accept-Language set in request header.
models.py:
pub_date = models.DateTimeField(_("Publication date"),
auto_now_add=True)
mod_date = models.DateTimeField(_("Modification date"), auto_now=True)
in views.py: generics.ListAPIView
serializers.py: (serializers.ModelSerializer)
pub_date = serializers.DateTimeField(format='%d %b %Y')
mod_date = serializers.DateTimeField(format='%d %b %Y')
request, using the commandline tool httpie:
http http://10.7.90.5:8000/karty/api/ Accept:application/json
Accept-Language:pl
I've tried setting it to both 'en' end 'pl'. In the user-facing view I get
either Polish or English depending on the header, that's how I know the
syntax is correct. But in the API views the date is always in english.
Language code is not specified in settings.py, so it uses default.
LocaleMiddleware is enabled and works for the rest of the website. It's a
toy / exercise project so most settings are on their default values.
Am I missing something ? I read the 'internationalization' chapter of the
rest framework documentation, and I don't see anything. Actually, the
opening paragraph and the choice of examples implies that error messages
are the only thing you may want to translate. So it looks like an omission
in design to me.
Cheers,
Marek Onuszko
--
You received this message because you are subscribed to the Google Groups
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.