What's the recommended way to use cldr with a liveview app? Right now I'm passign the locale into the session like this:
# in the router
plug Cldr.Plug.SetLocale,
apps: [:cldr, :gettext],
cldr: App.Cldr,
from: [:query, :accept_language]
live "/some_live_path", AppLive,
session: {__MODULE__, :localized_session, []}
@doc false
def localized_session(conn) do
%Cldr.LanguageTag{language: language} =
Cldr.Plug.SetLocale.get_cldr_locale(conn) || App.Cldr.default_locale()
%{"locale" => language}
end
but it doesn't seem to work correctly since the locales are different in the ssr'ed page and when the live view mounts: in ssr the locale is correct (e.g. en), but then in live view it becomes en-001.
So I wonder what exactly should I pass into the live view session to then restore the same exact locale as the one set by SetLocale plug.
What's the recommended way to use cldr with a liveview app? Right now I'm passign the locale into the session like this:
but it doesn't seem to work correctly since the locales are different in the ssr'ed page and when the live view mounts: in ssr the locale is correct (e.g.
en
), but then in live view it becomesen-001
.So I wonder what exactly should I pass into the live view session to then restore the same exact locale as the one set by
SetLocale
plug.