#36142: django.shortcuts.get_object_or_404 does not support translation for
error
messages (i18n)
-------------------------------------+-------------------------------------
Reporter: Abror Izzatullaev | Owner: Joel
Type: | Burns
Cleanup/optimization | Status: assigned
Component: | Version: 5.2
Internationalization |
Severity: Normal | Resolution:
Keywords: i18 | Triage Stage: Accepted
Internationalization |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Joel Burns):
Hi, I'm looking for feedback,
So I think the best way to accomplish this would be to first use:
from django.utils.translation import gettext as _
(the text to be translated needs to be marked with _)
from django.http import HttpResponse
from django.utils.translation import gettext as _
def my_view(request):
output = _("Welcome to my site.")
return HttpResponse(output)
the tagged messages are added to a message file with a .po extension
indicate django.middleware.locale.LocaleMiddleware this must be added to
activate translation features
https://docs.djangoproject.com/en/5.1/topics/i18n/translation/
I'm assuming this file is where this needs to be applied,
https://github.com/django/django/blob/stable/5.1.x/django/shortcuts.py#L65
specifically to the get_object_or_404 or get_list_or_404 methods to
translate the output?
--
Ticket URL: <https://code.djangoproject.com/ticket/36142#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/01070195027834b6-2fbe80ac-d073-48b0-8f9d-359dd2827c9c-000000%40eu-central-1.amazonses.com.