Repository navigation
Document reporting missing messages with the backend callbacks - #447
Conversation
|
Perhaps I am missing something, but why not use the handle_missing_translation and handle_missing_plural_translation callbacks? |
|
Not missing anything, the callbacks can do this, and I checked that overriding both and calling super covers the same cases (missing keys, empty msgstr, unknown domains and locales, plurals, split_module_by). I went with the option because of the discussion in #410, where @maennchen and @whatyouhide were in favor of an The docs don't mention the callbacks in the "Missing messages" section, so that part is easy to miss. If you prefer, I can turn this PR into a docs-only change with an example of warning or raising from the override, plus the default-domain fallback from the issue. Just tell me which way you want to go. |
|
I'd prefer to use the callbacks but let's def er to @maennchen and @whatyouhide's decision. |
|
When I suggested that option I was not thinking of callbacks, which in general are a good approach here I think. I would personally go for this:
Thoughts? |
|
Sounds good, I agree callbacks are the better fit here. I'll rework this PR into docs only and drop the option. The docs will show how to override handle_missing_translation/5 and handle_missing_plural_translation/7 to log a warning. For the Phoenix template, I'm happy to open that PR in the Phoenix repo once the docs are in, if that works for you. |
Missing messages are returned silently. Show how to override handle_missing_translation/5 and handle_missing_plural_translation/7 and call super to log a warning.
f92d604 to
df67fd9
Compare
|
Thank you @olehgerus 🫶 |
Refs #410.
Following the discussion here, this is now docs only and the
:on_missing_translationoption is gone.It adds a "Reporting missing messages" section to the "Missing messages" docs in
Gettext. It shows how to overridehandle_missing_translation/5andhandle_missing_plural_translation/7in a backend, log a warning and callsuper, and mentions that the callbacks run for every locale that lacks the message, including the source one.I ran the example from the docs: it logs the warning and still returns the msgid.