Is it possible to change gettext's msgstr in runtime for choosen msgid?

I want to find possibility to change msgstr in runtime, not recompiling the elixir project.


iex(12)> Gettext.get_locale
iex(13)> Hi.wel
"Добро пожаловать!"
iex(14)> Gettext.put_locale("en")
iex(15)> Hi.wel                  
iex(16)> Gettext.put_locale("ru")
do smth...
iex(13)> Hi.wel
"Another msg on ru locale!"

It might be possible for runtime translated text, but usually gettext is used in a way that translations are compiled into the place where they’re selected and those cannot be changed at runtime anymore.

Which library i need to search for this?

Maybe i need trans for this? Can’t say for sure, does this lib solving my problem, because there are no examples in hex or github.

Usually I look at the unit tests in the GitHub repo. If they are testing properly there should be good examples.

1 Like