Gettext translations are not extracted when using a dynamic backend

The MyApp.Gettext.*_noop set of macros are designed to help in this situation. They mark the messages for extraction but do not otherwise include any code in your module.

I think the right approach is:

  • Define a Gettext backend in your library in your own namespace
  • Call MyLib.Gettext.dgettext_noop("domain, "message") for each message you want to be extracted.
  • Call the Gettext.dgettext(DemoWeb.Gettext, "domain", "translation") function as you normally would.

This ends up with two calls per message but one is a macro invoked at compile time (to extract the messages only) and the other is a function invoked at runtime to perform the translation.

3 Likes