feat: gettext
This commit is contained in:
parent
2ab3332941
commit
ca4ac3a1c0
15 changed files with 998 additions and 51 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue