Hi,
I am trying to test a registration form where I’d like to capture the user’s locale. I can test my code manually and this works fine, but I cannot figure out how to change the locale in a test.
Gettext.with_locale(MyApp.Gettext, "de", fn ->
{:ok, lv, _html} = live(conn, ~p"/register")
[INSERT OTHER TEST CODE HERE]
end)
I also tried Gettext.put_locale(MyApp.Gettext, "de")
and setting the locale on conn via conn = Plug.Conn.put_session(conn, :locale, "de")
.
What am I missing? Any other ways to get this done?
Background on capturing locale: I put MyApp.get_locale(PetalProWeb.Gettext)
in a @locale
and capture it via a hidden field in the registration form.
Thanks in advance!