Hi all,
I am not able to extract translation strings into a pot file using the mix gettext.extract
task.
The task exits without errors, but does nothing.
I am following the README at GitHub - elixir-gettext/gettext: Internationalization and localization support for Elixir.
I set up a basic mix project to test it out:
PS: it works fine in a Phoenix project, so I am suspecting some black magic going on…?
Did you run mix gettext.merge priv/gettext --locale {locale}
to create a locales’ folder? This creates a priv/gettext/{locale} folder with the files.
Once you have done so for each locale you want to support, you can use mix gettext.extract --merge
.
2 Likes
That is working, thank you.
It’s a bit different from GitHub - elixir-gettext/gettext: Internationalization and localization support for Elixir. though.
Could the README be improved maybe?
You could propose they clarify the instructions. You are not the first on (neither was I) who tripped over this
Merge .pot into all locales
mix gettext.merge priv/gettext
It never mentions when or where ‘all locales’ are defined.
3 Likes
Ah, mix gettext.extract
works on main and v0.18.2, not working on v0.19.1
interesting
For me mix gettext.extract
did nothing, until I configured a default locale and translations directory, e.g.
defmodule DemoAppWeb.Gettext do
use Gettext,
otp_app: :demo_app,
default_locale: :en,
priv: "priv/gettext"
end
If you’re on elixir 1.15 then I think you’re running into this issue: Running `mix gettext.extract` doesn't extract new messages with Elixir 1.15 · Issue #367 · elixir-gettext/gettext · GitHub
It’s fixed on the main branch, but not yet released. You can temporarily depend on the github version in your mix.exs, it my hypothesis is correct.
You don’t need to configure :priv
(and :default_locale
?) if they are default like that. You probably triggered a full recompilation somehow.
If you’re not on Elixir 1.15 then all the above doesn’t hold.
2 Likes
Thanks @linusdm !
Yes, that was it. I installed the latest main then it started working as expected, without needing to specify a default locale / directory.
So the workaround at the moment: In mix.exs, install the latest gettext as
{git: "https://github.com/elixir-lang/gettext.git", branch: "main", override: true},
2 Likes