fp/services/bright/lib/bright_web/plugs/locale.ex

16 lines
319 B
Elixir

defmodule BrightWeb.Plugs.Locale do
import Plug.Conn
@locales ["en", "jp"]
def init(default), do: default
def call(%Plug.Conn{params: %{"locale" => loc}} = conn, _default) when loc in @locales do
assign(conn, :locale, loc)
end
def call(conn, default) do
assign(conn, :locale, default)
end
end