We’ve found in our modules, and there have been cases in core modules too, that message.xml was not registered. It is also a very easy mistake to make to have a typo in a message id or to add a gettext call without adding it to message.xml.
So I propose we add a standard test for all modules that:
- Ensures all messages referred by gettext() are registered in ir.message (this trivial to implement if we base our code on pygettext parser)
- Ensure the text in ir.message contains the substitutions %(text)s and parameters in the gettext match (would be some more work, but probably doable extending the aforementioned parser)
Unfortunately we cannot raise an error if there are messages registered but not used in the module as one could want to register messages in a module for other modules to use, although, maybe we could add a special field for those (rare) cases.
Something in the line:
<record model="ir.message" id="msg_xxx"> <field name="text">xxx</field> <field name="warn" eval="False"/> </record>
PS: It would also be nice to have a tool that ensures that all translations have the right substitutions, although I understand this is not desirable as a standard test because it could easily fail in core modules.