feat: gettext

This commit is contained in:
Moritz 2025-06-17 19:02:35 +02:00
parent 2ab3332941
commit ca4ac3a1c0
Signed by: moritz
GPG key ID: 1020A035E5DD0824
15 changed files with 998 additions and 51 deletions

View file

@ -8,6 +8,7 @@ defmodule MvWeb.Router do
plug :put_root_layout, html: {MvWeb.Layouts, :root}
plug :protect_from_forgery
plug :put_secure_browser_headers
plug :set_locale
end
pipeline :api do
@ -35,6 +36,8 @@ defmodule MvWeb.Router do
live "/properties/:id/edit", PropertyLive.Index, :edit
live "/properties/:id", PropertyLive.Show, :show
live "/properties/:id/show/edit", PropertyLive.Show, :edit
post "/set_locale", LocaleController, :set_locale
end
# Other scopes may use custom stacks.
@ -68,4 +71,10 @@ defmodule MvWeb.Router do
ash_admin "/"
end
end
defp set_locale(conn, _opts) do
locale = get_session(conn, :locale) || "en"
Gettext.put_locale(MvWeb.Gettext, locale)
conn
end
end