fix: added SetLocale to update LiveViews if language changes
This commit is contained in:
parent
f485f7bd8f
commit
df51731ae8
2 changed files with 14 additions and 1 deletions
13
lib/mv_web/live/set_locale.ex
Normal file
13
lib/mv_web/live/set_locale.ex
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
defmodule MvWeb.Live.SetLocale do
|
||||
@moduledoc """
|
||||
The Module to make the locale available to all LiveViews
|
||||
"""
|
||||
import Phoenix.Component
|
||||
import MvWeb.Gettext
|
||||
|
||||
def on_mount(:default, _params, session, socket) do
|
||||
locale = session["locale"] || "en"
|
||||
Gettext.put_locale(locale)
|
||||
{:cont, assign(socket, :locale, locale)}
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue