Skip to content

Instantly share code, notes, and snippets.

@shankardevy
Last active November 22, 2017 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shankardevy/5019aa5a0a6ddc9458bcfca40485e67f to your computer and use it in GitHub Desktop.
Save shankardevy/5019aa5a0a6ddc9458bcfca40485e67f to your computer and use it in GitHub Desktop.
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