diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot new file mode 100644 index 0000000..15a39d3 --- /dev/null +++ b/priv/gettext/default.pot @@ -0,0 +1,28 @@ +## This file is a PO Template file. `msgid`s here are often extracted from +## source code; add new translations manually only if they're dynamic +## translations that can't be statically extracted. Run `mix +## gettext.extract` to bring this file up to date. Leave `msgstr`s empty as +## changing them here as no effect; edit them in PO (`.po`) files instead. +#: web/views/shared_view.ex:18 +msgid "About" +msgstr "" + +#: web/views/shared_view.ex:6 +msgid "Announce your new project, blog post or version update." +msgstr "" + +#: web/views/shared_view.ex:17 +msgid "Home" +msgstr "" + +#: web/views/shared_view.ex:23 +msgid "Open Source" +msgstr "" + +#: web/views/shared_view.ex:22 +msgid "Running on Phoenix!" +msgstr "" + +#: web/views/shared_view.ex:19 +msgid "You can follow via" +msgstr "" diff --git a/priv/gettext/en/LC_MESSAGES/default.po b/priv/gettext/en/LC_MESSAGES/default.po new file mode 100644 index 0000000..900e301 --- /dev/null +++ b/priv/gettext/en/LC_MESSAGES/default.po @@ -0,0 +1,31 @@ +## `msgid`s in this file come from POT (.pot) files. Do not add, change, or +## remove `msgid`s manually here as they're tied to the ones in the +## corresponding POT file (with the same domain). Use `mix gettext.extract +## --merge` or `mix gettext.merge` to merge POT files into PO files. +msgid "" +msgstr "" +"Language: en\n" + +#: web/views/shared_view.ex:18 +msgid "About" +msgstr "" + +#: web/views/shared_view.ex:6 +msgid "Announce your new project, blog post or version update." +msgstr "" + +#: web/views/shared_view.ex:17 +msgid "Home" +msgstr "" + +#: web/views/shared_view.ex:23 +msgid "Open Source" +msgstr "" + +#: web/views/shared_view.ex:22 +msgid "Running on Phoenix!" +msgstr "" + +#: web/views/shared_view.ex:19 +msgid "You can follow via" +msgstr "" diff --git a/priv/gettext/fr/LC_MESSAGES/default.po b/priv/gettext/fr/LC_MESSAGES/default.po new file mode 100644 index 0000000..7bfa9d1 --- /dev/null +++ b/priv/gettext/fr/LC_MESSAGES/default.po @@ -0,0 +1,31 @@ +## `msgid`s in this file come from POT (.pot) files. Do not add, change, or +## remove `msgid`s manually here as they're tied to the ones in the +## corresponding POT file (with the same domain). Use `mix gettext.extract +## --merge` or `mix gettext.merge` to merge POT files into PO files. +msgid "" +msgstr "" +"Language: fr\n" + +#: web/views/shared_view.ex:18 +msgid "About" +msgstr "Concernant" + +#: web/views/shared_view.ex:6 +msgid "Announce your new project, blog post or version update." +msgstr "Annoncer votre nouveau projet, post de blog ou une version mise à jour." + +#: web/views/shared_view.ex:17 +msgid "Home" +msgstr "Maison" + +#: web/views/shared_view.ex:23 +msgid "Open Source" +msgstr "Code Source Libre" + +#: web/views/shared_view.ex:22 +msgid "Running on Phoenix!" +msgstr "Fonctionnant sur Phoenix!" + +#: web/views/shared_view.ex:19 +msgid "You can follow via" +msgstr "Vous pouvez suivre via" diff --git a/priv/gettext/fr/LC_MESSAGES/errors.po b/priv/gettext/fr/LC_MESSAGES/errors.po new file mode 100644 index 0000000..eb2c2fb --- /dev/null +++ b/priv/gettext/fr/LC_MESSAGES/errors.po @@ -0,0 +1,86 @@ +## `msgid`s in this file come from POT (.pot) files. Do not add, change, or +## remove `msgid`s manually here as they're tied to the ones in the +## corresponding POT file (with the same domain). Use `mix gettext.extract +## --merge` or `mix gettext.merge` to merge POT files into PO files. +msgid "" +msgstr "" +"Language: fr\n" + +msgid "can't be blank" +msgstr "" + +msgid "is invalid" +msgstr "" + +msgid "has invalid format" +msgstr "" + +msgid "has an invalid entry" +msgstr "" + +msgid "is reserved" +msgstr "" + +msgid "does not match confirmation" +msgstr "" + +msgid "is still associated to this entry" +msgstr "" + +msgid "are still associated to this entry" +msgstr "" + +msgid "should be %{count} character(s)" +msgid_plural "should be %{count} character(s)" +msgstr[0] "" +msgstr[1] "" + +msgid "should have %{count} item(s)" +msgid_plural "should have %{count} item(s)" +msgstr[0] "" +msgstr[1] "" + +msgid "should be at least %{count} character(s)" +msgid_plural "should be at least %{count} character(s)" +msgstr[0] "" +msgstr[1] "" + +msgid "should have at least %{count} item(s)" +msgid_plural "should have at least %{count} item(s)" +msgstr[0] "" +msgstr[1] "" + +msgid "should be at most %{count} character(s)" +msgid_plural "should be at most %{count} character(s)" +msgstr[0] "" +msgstr[1] "" + +msgid "should have at most %{count} item(s)" +msgid_plural "should have at most %{count} item(s)" +msgstr[0] "" +msgstr[1] "" + +msgid "must be less than %{count}" +msgid_plural "must be less than %{count}" +msgstr[0] "" +msgstr[1] "" + +msgid "must be greater than %{count}" +msgid_plural "must be greater than %{count}" +msgstr[0] "" +msgstr[1] "" + +msgid "must be less than or equal to %{count}" +msgid_plural "must be less than or equal to %{count}" +msgstr[0] "" +msgstr[1] "" + +msgid "must be greater than or equal to %{count}" +msgid_plural "must be greater than or equal to %{count}" +msgstr[0] "" +msgstr[1] "" + +msgid "must be equal to %{count}" +msgid_plural "must be equal to %{count}" +msgstr[0] "" +msgstr[1] "" diff --git a/web/controllers/locale.ex b/web/controllers/locale.ex new file mode 100644 index 0000000..5dffe44 --- /dev/null +++ b/web/controllers/locale.ex @@ -0,0 +1,14 @@ +defmodule ElixirStatus.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(ElixirStatus.Gettext, locale) + conn |> put_session(:locale, locale) + end + end +end diff --git a/web/router.ex b/web/router.ex index c374254..b45f18c 100644 --- a/web/router.ex +++ b/web/router.ex @@ -8,6 +8,7 @@ defmodule ElixirStatus.Router do plug :protect_from_forgery plug :put_secure_browser_headers plug :assign_current_user + plug ElixirStatus.Locale end pipeline :api do diff --git a/web/templates/shared/sidebar.html.eex b/web/templates/shared/sidebar.html.eex index 89e4bfa..0ee0554 100644 --- a/web/templates/shared/sidebar.html.eex +++ b/web/templates/shared/sidebar.html.eex @@ -1,10 +1,9 @@ -