Cldr.Plug.PutSession (Cldr v2.28.0) View Source

Puts the CLDR locale name in the session.

The session key is fixed to be cldr_locale in order that downstream functions like those in liveview don't have to be passed options.

Examples

# Define a router module that
# sets the locale for the current process
# and then also sets it in the session
defmodule MyAppWeb.Router do
  use MyAppWeb, :router

  pipeline :browser do
    plug :accepts, ["html"]
    plug :fetch_session
    plug Cldr.Plug.SetLocale,
        apps: [:cldr, :gettext],
        from: [:path, :query],
        gettext: MyApp.Gettext,
        cldr: MyApp.Cldr
    plug Cldr.Plug.PutSession
    plug :fetch_flash
    plug :protect_from_forgery
    plug :put_secure_browser_headers
  end
end