1
0
mirror of https://github.com/danbee/chess synced 2025-03-04 08:39:06 +00:00

Gettextify!

This commit is contained in:
Daniel Barber 2018-04-13 11:25:28 -04:00
parent f03692c9b9
commit f19b30dfaf
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8
3 changed files with 12 additions and 9 deletions

View File

@ -8,8 +8,10 @@
<span class="player-indicator"> <span class="player-indicator">
<img src="images/pawn_<%= player_colour(@conn, game) %>.svg"> <img src="images/pawn_<%= player_colour(@conn, game) %>.svg">
</span> </span>
<%= link gettext("Game with %{name}", <%= link gettext(
name: opponent(@conn, game).name), "Game with %{name}",
name: opponent(@conn, game).name
),
to: game_path(@conn, :show, game), to: game_path(@conn, :show, game),
class: "btn btn-default btn-xs" %> class: "btn btn-default btn-xs" %>
</td> </td>

View File

@ -1,6 +1,6 @@
<p><%= link gettext("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><%= gettext "Game with %{name}", name: opponent(@conn, @game).name %></h2>
<div id="app" data-game-id="<%= @game.id %>"> <div id="app" data-game-id="<%= @game.id %>">
</div> </div>

View File

@ -1,14 +1,15 @@
defmodule ChessWeb.GameView do defmodule ChessWeb.GameView do
use ChessWeb, :view use ChessWeb, :view
alias Chess.Store.Game
alias Chess.GameState alias Chess.GameState
import Chess.Auth, only: [current_user: 1] import Chess.Auth, only: [current_user: 1]
def won_lost(conn, game) do def won_lost(conn, game) do
if game_over?(game) && game.state == "checkmate" do if game_over?(game) && game.state == "checkmate" do
your_turn?(conn, game) && "You lost" || "You won" your_turn?(conn, game) &&
gettext("You lost") ||
gettext("You won")
end end
end end
@ -21,7 +22,7 @@ defmodule ChessWeb.GameView do
GameState.game_over?(game) -> GameState.game_over?(game) ->
states[game.state] states[game.state]
your_turn?(conn, game) -> your_turn?(conn, game) ->
"Your turn" gettext("Your turn")
true -> nil true -> nil
end end
end end
@ -50,9 +51,9 @@ defmodule ChessWeb.GameView do
defp states do defp states do
%{ %{
"checkmate" => "Checkmate!", "checkmate" => gettext("Checkmate!"),
"stalemate" => "Stalemate", "stalemate" => gettext("Stalemate"),
"check" => "Check", "check" => gettext("Check"),
} }
end end
end end