diff --git a/lib/kolab_chat/locale.ex b/lib/kolab_chat/locale.ex new file mode 100644 --- /dev/null +++ b/lib/kolab_chat/locale.ex @@ -0,0 +1,15 @@ +defmodule KolabChat.Locale do + import Plug.Conn + + def init(opts), do: opts + + def call(conn, _opts) do + case conn.params["locale"] || get_session(conn, :locale) do + nil -> + conn + locale -> + Gettext.put_locale(MyApp.Gettext, locale) + put_session(conn, :locale, locale) + end + end +end diff --git a/web/router.ex b/web/router.ex --- a/web/router.ex +++ b/web/router.ex @@ -7,6 +7,7 @@ plug :fetch_flash plug :protect_from_forgery plug :put_secure_browser_headers + plug KolabChat.Locale end pipeline :api do diff --git a/web/templates/layout/app.html.eex b/web/templates/layout/app.html.eex --- a/web/templates/layout/app.html.eex +++ b/web/templates/layout/app.html.eex @@ -7,7 +7,7 @@ - Kolab Real Time Communication + <%= gettext "Kolab Real Time Communication" %> "> @@ -16,7 +16,7 @@
diff --git a/web/templates/page/index.html.eex b/web/templates/page/index.html.eex --- a/web/templates/page/index.html.eex +++ b/web/templates/page/index.html.eex @@ -1,5 +1,4 @@

<%= gettext "Welcome to %{name}", name: "Kolab Chat!" %>

-

Real-time communication for the Kolab groupware system.

+

<%= gettext "Real-time communication for the Kolab groupware system." %>

-