Skip to content

Commit

Permalink
Adding gettext support
Browse files Browse the repository at this point in the history
This comes with a pretty terrible French translation as well, if you
want french-speaking people to cry when reading the site!
  • Loading branch information
knewter committed Dec 22, 2015
1 parent 0e46bcd commit 995d9e3
Show file tree
Hide file tree
Showing 7 changed files with 197 additions and 7 deletions.
28 changes: 28 additions & 0 deletions priv/gettext/default.pot
Original file line number Diff line number Diff line change
@@ -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 ""
31 changes: 31 additions & 0 deletions priv/gettext/en/LC_MESSAGES/default.po
Original file line number Diff line number Diff line change
@@ -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 ""
31 changes: 31 additions & 0 deletions priv/gettext/fr/LC_MESSAGES/default.po
Original file line number Diff line number Diff line change
@@ -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"
86 changes: 86 additions & 0 deletions priv/gettext/fr/LC_MESSAGES/errors.po
Original file line number Diff line number Diff line change
@@ -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] ""
14 changes: 14 additions & 0 deletions web/controllers/locale.ex
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions web/templates/shared/sidebar.html.eex
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

<div class="sidebar">
<div class="container">
<div class="sidebar-header">
<a href="/"><img src="<%= static_path(@conn, "/images/logo.png") %>" class="logo"/></a>
<h1><a href="/">elixirstatus</a></h1>
<p>Announce your new project, blog post or version update.</p>
<p><%= gettext "Announce your new project, blog post or version update." %></p>
</div>
</div>
<div class="container sidebar-nav-container">
Expand All @@ -15,13 +14,13 @@
<input type="checkbox" class="sidebar-checkbox" id="sidebar-checkbox">

<nav class="sidebar-nav">
<a class="sidebar-nav-item active" href="/">Home</a>
<a class="sidebar-nav-item" href="<%= page_path(@conn, :about) %>">About</a>
<span class="sidebar-nav-item">You can follow via</span>
<a class="sidebar-nav-item active" href="/"><%= gettext "Home" %></a>
<a class="sidebar-nav-item" href="<%= page_path(@conn, :about) %>"><%= gettext "About" %></a>
<span class="sidebar-nav-item"><%= gettext "You can follow via" %></span>
<a class="sidebar-nav-item" href="https://twitter.com/elixirstatus" target="_blank">Twitter</a>
<a class="sidebar-nav-item" href="/rss">RSS</a>
<span class="sidebar-nav-item">Running on Phoenix!</span>
<a class="sidebar-nav-item" href="https://github.com/rrrene/elixirstatus-web" target="_blank">Open Source</a>
<span class="sidebar-nav-item"><%= gettext "Running on Phoenix!" %></span>
<a class="sidebar-nav-item" href="https://github.com/rrrene/elixirstatus-web" target="_blank"><%= gettext "Open Source" %></a>
</nav>
</div>
</div>

0 comments on commit 995d9e3

Please sign in to comment.