mirror of
https://github.com/danbee/chess
synced 2025-03-04 08:39:06 +00:00
Add gettext calls for i18n
This commit is contained in:
parent
6a72e5f404
commit
1f9b9e02e2
@ -6,6 +6,7 @@ defmodule Chess.Store.Game do
|
|||||||
|
|
||||||
import Ecto.Changeset
|
import Ecto.Changeset
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
|
import ChessWeb.Gettext
|
||||||
|
|
||||||
alias Chess.Board
|
alias Chess.Board
|
||||||
alias Chess.Store.Game
|
alias Chess.Store.Game
|
||||||
@ -52,7 +53,7 @@ defmodule Chess.Store.Game do
|
|||||||
changeset
|
changeset
|
||||||
|> add_error(
|
|> add_error(
|
||||||
:board,
|
:board,
|
||||||
"That move would leave your king in check"
|
gettext("That move would leave your king in check")
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
changeset
|
changeset
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
<%= form_for @changeset, @action, fn f -> %>
|
<%= form_for @changeset, @action, fn f -> %>
|
||||||
<%= if @changeset.action do %>
|
<%= if @changeset.action do %>
|
||||||
<div class="alert alert-danger">
|
<div class="alert alert-danger">
|
||||||
<p>Oops, something went wrong! Please check the errors below.</p>
|
<p>
|
||||||
|
<%= gettext "Oops, something went wrong! Please check the errors below." %>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
@ -1,21 +1,30 @@
|
|||||||
<h2>Listing games</h2>
|
<h2><%= gettext "Listing games" %></h2>
|
||||||
|
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tbody>
|
<tbody>
|
||||||
<%= for game <- @games do %>
|
<%= for game <- @games do %>
|
||||||
<tr class="<%= turn_class(@conn, game) %>">
|
<tr class="<%= turn_class(@conn, game) %>">
|
||||||
<td>
|
<td>
|
||||||
<span class="player-indicator"><img src="images/pawn_<%= player_colour(@conn, game) %>.svg"></span>
|
<span class="player-indicator">
|
||||||
<%= link "Game with #{opponent(@conn, game).name}", to: game_path(@conn, :show, game), class: "btn btn-default btn-xs" %>
|
<img src="images/pawn_<%= player_colour(@conn, game) %>.svg">
|
||||||
|
</span>
|
||||||
|
<%= link gettext("Game with %{name}",
|
||||||
|
name: opponent(@conn, game).name),
|
||||||
|
to: game_path(@conn, :show, game),
|
||||||
|
class: "btn btn-default btn-xs" %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<%= if your_turn?(@conn, game) do %>Your turn<% end %>
|
<%= if your_turn?(@conn, game), do: gettext("Your turn") %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
Started on <%= Timex.format!(game.inserted_at, "%b %e at %I:%M %P", :strftime) %>
|
Started on <%= Timex.format!(game.inserted_at, "%b %e at %I:%M %P", :strftime) %>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
<%= link "Delete", to: game_path(@conn, :delete, game), method: :delete, data: [confirm: "Are you sure?"], class: "btn btn-danger btn-xs" %>
|
<%= link gettext("Delete"),
|
||||||
|
to: game_path(@conn, :delete, game),
|
||||||
|
method: :delete,
|
||||||
|
data: [confirm: gettext("Are you sure?")],
|
||||||
|
class: "btn btn-danger btn-xs" %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
@ -23,5 +32,5 @@
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<%= link "New game", to: game_path(@conn, :new), class: "button" %>
|
<%= link gettext("New game"), to: game_path(@conn, :new), class: "button" %>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@ -1,14 +1,17 @@
|
|||||||
<h2>New game</h2>
|
<h2><%= gettext "New game" %></h2>
|
||||||
|
|
||||||
<%= form_for @changeset, game_path(@conn, :create), [class: "create-game"],
|
<%= form_for @changeset, game_path(@conn, :create), [class: "create-game"],
|
||||||
fn form -> %>
|
fn form -> %>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= label form, :opponent_id %>
|
<%= label form, :opponent_id %>
|
||||||
<%= select form, :opponent_id, @opponents, prompt: "Choose an opponent" %>
|
<%= select form,
|
||||||
|
:opponent_id,
|
||||||
|
@opponents,
|
||||||
|
prompt: gettext("Choose an opponent") %>
|
||||||
<%= error_tag form, :opponent_id %>
|
<%= error_tag form, :opponent_id %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= submit "Create game", class: "button" %>
|
<%= submit gettext("Create game"), class: "button" %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
<p><%= link "Back to games", to: game_path(@conn, :index) %></p>
|
<p><%= link gettext("Back to games"), to: game_path(@conn, :index) %></p>
|
||||||
|
|
||||||
<h2>Game with <%= opponent(@conn, @game).name %></h2>
|
<h2>Game with <%= opponent(@conn, @game).name %></h2>
|
||||||
|
|
||||||
|
|||||||
@ -7,32 +7,38 @@
|
|||||||
<meta name="description" content="">
|
<meta name="description" content="">
|
||||||
<meta name="author" content="">
|
<meta name="author" content="">
|
||||||
|
|
||||||
<title>Shall We Play a Game?</title>
|
<title><%= gettext "Shall We Play a Game?" %></title>
|
||||||
<link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>">
|
<link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<header role="banner">
|
<header role="banner">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h1>Chess</h1>
|
<h1><%= gettext "Chess" %></h1>
|
||||||
|
|
||||||
<nav class="user-nav" role="user">
|
<nav class="user-nav" role="user">
|
||||||
<%= if current_user(@conn) do %>
|
<%= if current_user(@conn) do %>
|
||||||
<%= current_user(@conn).name %> (<%= current_user(@conn).email %>)
|
<%= current_user(@conn).name %> (<%= current_user(@conn).email %>)
|
||||||
|
|
|
|
||||||
<%= link("Log out", to: session_path(@conn, :delete), method: :delete) %>
|
<%= link gettext("Log out"),
|
||||||
|
to: session_path(@conn, :delete),
|
||||||
|
method: :delete %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= link("Register", to: registration_path(@conn, :new)) %>
|
<%= link gettext("Register"), to: registration_path(@conn, :new) %>
|
||||||
|
|
|
|
||||||
<%= link("Log in", to: session_path(@conn, :new)) %>
|
<%= link gettext("Log in"), to: session_path(@conn, :new) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="container alerts">
|
<div class="container alerts">
|
||||||
<p class="alert alert-info" role="alert"><%= get_flash(@conn, :info) %></p>
|
<p class="alert alert-info" role="alert">
|
||||||
<p class="alert alert-danger" role="alert"><%= get_flash(@conn, :error) %></p>
|
<%= get_flash(@conn, :info) %>
|
||||||
|
</p>
|
||||||
|
<p class="alert alert-danger" role="alert">
|
||||||
|
<%= get_flash(@conn, :error) %>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<main role="main">
|
<main role="main">
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
<h2>Register</h2>
|
<h2><%= gettext "Register" %></h2>
|
||||||
|
|
||||||
<%= form_for @changeset, registration_path(@conn, :create), [class: "create-registration"], fn f -> %>
|
<%= form_for @changeset, registration_path(@conn, :create), [class: "create-registration"], fn f -> %>
|
||||||
<%= if @changeset.action do %>
|
<%= if @changeset.action do %>
|
||||||
<div class="alert alert-danger">
|
<div class="alert alert-danger">
|
||||||
<p>Oops, something went wrong! Please check the errors below.</p>
|
<p>
|
||||||
|
<%= gettext "Oops, something went wrong! Please check the errors below." %>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
@ -19,6 +21,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= submit "Register", class: "btn btn-primary" %>
|
<%= submit gettext("Register"), class: "btn btn-primary" %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
<h2>Log in</h2>
|
<h2><%= gettext "Log in" %></h2>
|
||||||
|
|
||||||
<%= form_for @changeset, session_path(@conn, :create), [class: "create-session"], fn f -> %>
|
<%= form_for @changeset, session_path(@conn, :create), [class: "create-session"], fn f -> %>
|
||||||
<%= if @changeset.action do %>
|
<%= if @changeset.action do %>
|
||||||
<div class="alert alert-danger">
|
<div class="alert alert-danger">
|
||||||
<p>Oops, something went wrong! Please check the errors below.</p>
|
<p>
|
||||||
|
<%= gettext "Oops, something went wrong! Please check the errors below." %>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
@ -16,6 +18,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= submit "Log in", class: "btn btn-primary" %>
|
<%= submit gettext("Log in"), class: "btn btn-primary" %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@ -2,11 +2,11 @@ defmodule ChessWeb.ErrorView do
|
|||||||
use ChessWeb, :view
|
use ChessWeb, :view
|
||||||
|
|
||||||
def render("404.html", _assigns) do
|
def render("404.html", _assigns) do
|
||||||
"Page not found"
|
gettext "Page not found"
|
||||||
end
|
end
|
||||||
|
|
||||||
def render("500.html", _assigns) do
|
def render("500.html", _assigns) do
|
||||||
"Internal server error"
|
gettext "Internal server error"
|
||||||
end
|
end
|
||||||
|
|
||||||
# In case no render clause matches or no
|
# In case no render clause matches or no
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user