Skip to content

Instantly share code, notes, and snippets.

@shankardevy

shankardevy/locale.ex Secret

Last active Nov 22, 2017
Embed
What would you like to do?
defmodule MangoWeb.Plugs.Locale do
import Plug.Conn
def init(opts), do: nil
def call(conn, _opts) do
case conn.params["locale"] || get_session(conn, :locale) do
nil -> conn
locale ->
Gettext.put_locale(MangoWeb.Gettext, locale)
conn |> put_session(:locale, locale)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment