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 @@ <meta name="description" content=""> <meta name="author" content=""> - <title>Kolab Real Time Communication</title> + <title><%= gettext "Kolab Real Time Communication" %></title> <link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>"> </head> @@ -16,7 +16,7 @@ <header class="header"> <nav role="navigation"> <ul class="nav nav-pills pull-right"> - <li><a href="/login">Login</a></li> + <li><a href="/login"><%= gettext "Login" %></a></li> </ul> </nav> <span class="logo"></span> 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 @@ <div class="jumbotron"> <h2><%= gettext "Welcome to %{name}", name: "Kolab Chat!" %></h2> - <p class="lead">Real-time communication for the Kolab groupware system.</p> + <p class="lead"><%= gettext "Real-time communication for the Kolab groupware system." %></p> </div> -