Hello all,

It seems that gettext is currently quite permissive – it falls back to the 
default language whenever a translation file is missing or if the requested 
message ID is missing from the translation file. This can lead to errors 
slipping through easily.

Consider this example from the documentation:

from django.http import HttpResponse
from django.utils.translation import gettext as _

def my_view(request):
    output = _("Welcome to my site.")
    return HttpResponse(output)

Let's also assume there's two languages used in the application: LANGUAGES 
= [('en', 'English'), ('de', 'German')])

Note that even if you display the view with the German language, you will 
see "Welcome to my site." and will not receive any error or warning about 
the fact that the German translation file doesn't even exist yet.

Then create a translation catalog file and translate the sentence. Notice 
that the translated sentence appears now properly. Now change the output 
line to output = _("Welcome to my updated site."). Notice how the 
translated sentence turns back into English even when using German as a 
language and you don't get any warning or error again.

I think it would be great if there was a way to make gettext raise an error 
when the translation file is missing or when the msgid is missing. In order 
to add this feature in a backwards-compatible manner we could consider 
controlling this behavior through a new settings option. Alternatively, a 
warning could be also emitted, I could convert those into errors at least 
during testing. Silently falling back to a different language upon changes 
is just not great, I think.

Thanks,
Gergely

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/875cb2fa-4e69-4184-b5c5-f5d98c66fa8dn%40googlegroups.com.

Reply via email to