View Source Cldr.Plug.PutSession (Cldr Plug v1.0.0)

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.



# 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