> On 15 Jun 2023, at 16:15, Tobias Kunze <r...@cutebit.de> wrote:
> 
> On 23-06-15 04:29:59, Gergely Kalmár wrote:
>> 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.
>> 
>> 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.
> 
> Agreed that this is annoying behaviour, but as far as I can tell, there's not
> much that Django can do. IIRC we only wrap Python's gettext module¹.
> 
> The relevant method, GNUTranslations.gettext, returns the original message if
> no translation has been found, and it does so without indicating that this is
> a fallback response².
> 
> AIUI this behaviour is rooted in GNU's gettext, which (just like the Python
> version) allows you to set a priority list of languages to fall back to³.

In ‘runtime’ indeed it is difficult to get a warning for an untranslated 
string; the best way to go about it is to generate the translation file and 
check for untranslated string in your translation file via some automated check 
such as a Github Action.

The added benefit this has is that if there is a translation string hiding in a 
lesser used part of your app such as the password reset form or so, it will 
still be spotted by the translation file generation, whereas you might 
otherwise miss this if you’re just clicking around in the app.

—
Michiel

-- 
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/4FE0664B-5E88-460C-826F-F0A85FC09D5B%40x14.nl.

Reply via email to