Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

complete i18n feature and upgrade to rails 3.0.11

  • Loading branch information...
commit 04f375e07786785b9bfc3cc5d0a56e62872d05b7 1 parent 620720e
@quake authored
Showing with 526 additions and 144 deletions.
  1. +2 −1  .gitignore
  2. +1 −1  Gemfile
  3. +46 −41 Gemfile.lock
  4. +4 −4 app/controllers/authentications_controller.rb
  5. +2 −2 app/controllers/games_controller.rb
  6. +2 −2 app/controllers/moves_controller.rb
  7. +3 −3 app/controllers/sessions_controller.rb
  8. +7 −7 app/controllers/users_controller.rb
  9. +3 −3 app/helpers/application_helper.rb
  10. +3 −3 app/helpers/games_helper.rb
  11. +6 −3 app/mailers/notifications.rb
  12. +5 −5 app/views/authentications/index.html.erb
  13. +13 −13 app/views/games/_form.html.erb
  14. +1 −1  app/views/games/_other_games.html.erb
  15. +17 −17 app/views/games/_panel.html.erb
  16. +1 −1  app/views/games/new.html.erb
  17. +1 −1  app/views/games/show.html.erb
  18. 0  app/views/notifications/{invitation.text.erb → invitation.en.text.erb}
  19. +14 −0 app/views/notifications/invitation.zh-cn.text.erb
  20. 0  app/views/notifications/{message.text.erb → message.en.text.erb}
  21. +14 −0 app/views/notifications/message.zh-cn.text.erb
  22. 0  app/views/notifications/{move.text.erb → move.en.text.erb}
  23. +14 −0 app/views/notifications/move.zh-cn.text.erb
  24. +5 −5 app/views/sessions/new.html.erb
  25. +12 −12 app/views/users/_form.html.erb
  26. +6 −6 app/views/users/edit.html.erb
  27. +3 −3 app/views/users/new.html.erb
  28. +8 −8 app/views/users/show.html.erb
  29. +31 −0 config/locales/controllers.en.yml
  30. +31 −0 config/locales/controllers.zh-cn.yml
  31. +14 −0 config/locales/helpers.en.yml
  32. +14 −0 config/locales/helpers.zh-cn.yml
  33. +108 −0 config/locales/views.en.yml
  34. +133 −0 config/locales/views.zh-cn.yml
  35. +2 −2 lib/controller_authentication.rb
View
3  .gitignore
@@ -6,4 +6,5 @@ config/database.yml
config/private.yml
config/initializers/development_mail.rb
db/schema.rb
-public/assets
+public/assets
+/nbproject/*
View
2  Gemfile
@@ -1,6 +1,6 @@
source 'http://rubygems.org'
-gem 'rails', '3.0.3'
+gem 'rails', '3.0.11'
gem 'mysql2'
gem 'omniauth'
gem 'jquery-rails'
View
87 Gemfile.lock
@@ -16,34 +16,34 @@ GEM
ZenTest (4.4.0)
aaronh-chronic (0.3.9)
abstract (1.0.0)
- actionmailer (3.0.3)
- actionpack (= 3.0.3)
- mail (~> 2.2.9)
- actionpack (3.0.3)
- activemodel (= 3.0.3)
- activesupport (= 3.0.3)
+ actionmailer (3.0.11)
+ actionpack (= 3.0.11)
+ mail (~> 2.2.19)
+ actionpack (3.0.11)
+ activemodel (= 3.0.11)
+ activesupport (= 3.0.11)
builder (~> 2.1.2)
erubis (~> 2.6.6)
- i18n (~> 0.4)
+ i18n (~> 0.5.0)
rack (~> 1.2.1)
- rack-mount (~> 0.6.13)
- rack-test (~> 0.5.6)
+ rack-mount (~> 0.6.14)
+ rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
- activemodel (3.0.3)
- activesupport (= 3.0.3)
+ activemodel (3.0.11)
+ activesupport (= 3.0.11)
builder (~> 2.1.2)
- i18n (~> 0.4)
- activerecord (3.0.3)
- activemodel (= 3.0.3)
- activesupport (= 3.0.3)
- arel (~> 2.0.2)
+ i18n (~> 0.5.0)
+ activerecord (3.0.11)
+ activemodel (= 3.0.11)
+ activesupport (= 3.0.11)
+ arel (~> 2.0.10)
tzinfo (~> 0.3.23)
- activeresource (3.0.3)
- activemodel (= 3.0.3)
- activesupport (= 3.0.3)
- activesupport (3.0.3)
+ activeresource (3.0.11)
+ activemodel (= 3.0.11)
+ activesupport (= 3.0.11)
+ activesupport (3.0.11)
addressable (2.2.2)
- arel (2.0.6)
+ arel (2.0.10)
autotest (4.4.1)
autotest-rails (4.1.0)
ZenTest
@@ -79,16 +79,17 @@ GEM
i18n (0.5.0)
jquery-rails (0.2.4)
rails (~> 3.0)
+ json (1.6.4)
json_pure (1.4.6)
launchy (0.3.7)
configuration (>= 0.0.5)
rake (>= 0.8.1)
- mail (2.2.12)
+ mail (2.2.19)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
- mime-types (1.16)
+ mime-types (1.17.2)
mocha (0.9.9)
rake
mongrel (1.2.0.pre2)
@@ -143,30 +144,33 @@ GEM
oa-openid (= 0.1.5)
open_gem (1.4.2)
launchy (~> 0.3.5)
- polyglot (0.3.1)
+ polyglot (0.3.3)
pyu-ruby-sasl (0.0.3.2)
- rack (1.2.1)
- rack-mount (0.6.13)
+ rack (1.2.5)
+ rack-mount (0.6.14)
rack (>= 1.0.0)
rack-openid (1.1.2)
rack (>= 0.4)
ruby-openid (>= 2.0.3)
- rack-test (0.5.6)
+ rack-test (0.5.7)
rack (>= 1.0)
- rails (3.0.3)
- actionmailer (= 3.0.3)
- actionpack (= 3.0.3)
- activerecord (= 3.0.3)
- activeresource (= 3.0.3)
- activesupport (= 3.0.3)
+ rails (3.0.11)
+ actionmailer (= 3.0.11)
+ actionpack (= 3.0.11)
+ activerecord (= 3.0.11)
+ activeresource (= 3.0.11)
+ activesupport (= 3.0.11)
bundler (~> 1.0)
- railties (= 3.0.3)
- railties (3.0.3)
- actionpack (= 3.0.3)
- activesupport (= 3.0.3)
+ railties (= 3.0.11)
+ railties (3.0.11)
+ actionpack (= 3.0.11)
+ activesupport (= 3.0.11)
rake (>= 0.8.7)
+ rdoc (~> 3.4)
thor (~> 0.14.4)
- rake (0.8.7)
+ rake (0.9.2.2)
+ rdoc (3.12)
+ json (~> 1.4)
rest-client (1.6.1)
mime-types (>= 1.16)
rspec (2.0.1)
@@ -189,9 +193,10 @@ GEM
beanstalk-client
json_pure
thor (0.14.6)
- treetop (1.4.9)
+ treetop (1.4.10)
+ polyglot
polyglot (>= 0.3.1)
- tzinfo (0.3.23)
+ tzinfo (0.3.31)
whenever (0.6.2)
aaronh-chronic (>= 0.3.9)
activesupport (>= 2.3.4)
@@ -217,7 +222,7 @@ DEPENDENCIES
nifty-generators
oily_png (= 0.1.0)
omniauth
- rails (= 3.0.3)
+ rails (= 3.0.11)
rspec-rails (>= 2.0.1)
stalker (= 0.5.0)
whenever
View
8 app/controllers/authentications_controller.rb
@@ -12,7 +12,7 @@ def create
authentication.user.apply_omniauth(omniauth)
authentication.user.save!
remember_user(authentication.user)
- flash[:notice] = "Signed in as #{authentication.user.username}"
+ flash[:notice] = t("signed_in_as", :username => authentication.user.username, :scope => "controllers.authentications")
redirect_to_target_or_default root_url
else
user = current_user_or_guest
@@ -22,11 +22,11 @@ def create
user.guest = false
if user.save
if was_guest
- flash[:notice] = "Signed in as #{user.username}."
+ flash[:notice] = t("signed_in_as", :username => user.username, :scope => "controllers.authentications")
remember_user(user)
redirect_to_target_or_default root_url
else
- flash[:notice] = "Authentication successful."
+ flash[:notice] = t("create", :scope => "controllers.authentications")
redirect_to edit_current_user_url
end
else
@@ -39,7 +39,7 @@ def create
def destroy
@authentication = current_user.authentications.find(params[:id])
@authentication.destroy
- flash[:notice] = "Successfully destroyed authentication."
+ flash[:notice] = t("destroy", :scope => "controllers.authentications")
redirect_to edit_current_user_path
end
end
View
4 app/controllers/games_controller.rb
@@ -41,8 +41,8 @@ def create
@game.prepare
if @game.save
@game.queue_computer_move
- Notifications.invitation(@game).deliver if @game.send_invitation_email?
- flash[:notice] = "Game started. Click on a point below to place your stone."
+ flash[:notice] = t("create", :scope => "controllers.games")
+ Notifications.invitation(@game).deliver if @game.send_invitation_email?
redirect_to @game
else
fetch_games
View
4 app/controllers/moves_controller.rb
@@ -10,8 +10,8 @@ def create
@game.queue_computer_move
Notifications.move(@game).deliver if @game.current_player && @game.current_player.email.present? && @game.current_player.email_on_move?
rescue GameEngine::IllegalMove
- flash[:alert] = "That is an illegal move."
+ flash[:alert] = t("illegal_move", :scope => "controllers.moves")
rescue GameEngine::OutOfTurn
- flash[:alert] = "It is not your turn to move."
+ flash[:alert] = t("out_of_turn", :scope => "controllers.moves")
end
end
View
6 app/controllers/sessions_controller.rb
@@ -8,17 +8,17 @@ def create
user = User.authenticate(params[:login], params[:password])
if user
remember_user(user)
- flash[:notice] = "Logged in successfully."
+ flash[:notice] = t("create_success", :scope => "controllers.sessions")
redirect_to_target_or_default("/")
else
- flash.now[:alert] = "Invalid login or password."
+ flash.now[:alert] = t("create_fail", :scope => "controllers.sessions")
render :action => 'new'
end
end
def destroy
forget_user
- flash[:notice] = "You have been logged out."
+ flash[:notice] = t("destroy", :scope => "controllers.sessions")
redirect_to root_url
end
end
View
14 app/controllers/users_controller.rb
@@ -10,10 +10,10 @@ def show
def new
if params[:email]
if logged_in?
- flash[:notice] = "Please update your profile below."
+ flash[:notice] = t("new_update", :scope => "controllers.users")
redirect_to edit_current_user_url(:email => params[:email])
elsif User.find_by_email(params[:email])
- flash[:notice] = "It appears you already have an account, please login below."
+ flash[:notice] = t("new_login", :scope => "controllers.users")
redirect_to login_url(:login => params[:email])
end
end
@@ -24,7 +24,7 @@ def create
@user = User.new(params[:user])
if @user.save
remember_user(@user)
- flash[:notice] = "Thank you for signing up! You are now logged in."
+ flash[:notice] = t("create", :scope => "controllers.users")
redirect_to root_url
else
render :action => 'new'
@@ -48,7 +48,7 @@ def update
@user.guest = false
if @user.save
session[:omniauth] = nil
- flash[:notice] = "Your profile has been updated."
+ flash[:notice] = t("update", :scope => "controllers.users")
redirect_to root_url
else
render :action => 'edit'
@@ -58,17 +58,17 @@ def update
def unsubscribe
@user = User.find_by_unsubscribe_token!(params[:token])
@user.update_attributes!(:email_on_invitation => false, :email_on_move => false, :email_on_message => false)
- flash[:notice] = "You have been unsubscribed from further email notifications."
+ flash[:notice] = t("unsubscribe", :scope => "controllers.users")
redirect_to root_url
end
def publicize
if guest?
- redirect_to signin_url, :alert => "You must first sign in to be added to the Looking for Games list."
+ redirect_to signin_url, :alert => t("publicize_guest", :scope => "controllers.users")
else
@user = current_user
@user.update_attribute(:publicized_at, (params[:remove] ? nil : Time.now))
- redirect_to root_url, :notice => "You have been #{params[:remove] ? 'removed from' : 'added to'} the Looking for Games list."
+ redirect_to root_url, :notice => t(params[:remove] ? "publicize_remove" : "publicize_add", :scope => "controllers.users")
end
end
end
View
6 app/helpers/application_helper.rb
@@ -29,9 +29,9 @@ def avatar_url(user)
def link_to_user(user)
if user
- user.guest? ? "Guest" : link_to(user.name_with_rank, user, :class => "subtle")
+ user.guest? ? t("guest", :scope => "helpers.application") : link_to(user.name_with_rank, user, :class => "subtle")
else
- "GNU Go"
+ t("gnu_go", :scope => "helpers.application")
end
end
@@ -44,7 +44,7 @@ def relative_date(date)
if date == today
nil
elsif date == today-1
- t('.yesterday')
+ t("yesterday", :scope => "helpers.application")
elsif date.year == today.year
l(date, :format => "%b %d")
else
View
6 app/helpers/games_helper.rb
@@ -22,12 +22,12 @@ def link_to_game_thumbnail(game)
def game_score(score, finished)
if finished
if score.to_f == 1.0
- t(".won")
+ t("won", :scope => "helpers.games")
elsif score.to_f > 0
- t(".won_by", :score => score)
+ t("won_by", :score => score, :scope => "helpers.games")
end
else
- t(".captured_stone", :count => score.to_i)
+ t("captured_stone", :count => score.to_i, :scope => "helpers.games")
end
end
View
9 app/mailers/notifications.rb
@@ -3,16 +3,19 @@ class Notifications < ActionMailer::Base
def invitation(game)
@game = game
- mail :to => @game.current_player.email, :subject => "[Go vs Go] Invitation from #{@game.opponent.username}"
+ I18n.locale = @game.current_player.locale || I18n.default_locale
+ mail :to => @game.current_player.email, :subject => t("invitation", :username => @game.opponent.username, :scope => "notifications")
end
def move(game)
@game = game
- mail :to => @game.current_player.email, :subject => "[Go vs Go] Move by #{@game.opponent.username}"
+ I18n.locale = @game.current_player.locale || I18n.default_locale
+ mail :to => @game.current_player.email, :subject => t("move", :username => @game.opponent.username, :scope => "notifications")
end
def chat_message(message)
@message = message
- mail :to => @message.recipient.email, :subject => "[Go vs Go] Chat from #{@message.user.username}"
+ I18n.locale = @message.recipient.locale || I18n.default_locale
+ mail :to => @message.recipient.email, :subject => t("chat", :username => @message.user.username, :scope => "notifications")
end
end
View
10 app/views/authentications/index.html.erb
@@ -1,9 +1,9 @@
-<% title "Sign In" %>
+<% title t(".sign_in") %>
<% stylesheet "authentication" %>
<div id="container" class="two_stones">
<div id="sign_in">
- <h2>Sign in through one of the following services</h2>
+ <h2><%= t(".sign_in_services") %></h2>
<a href="/auth/twitter" class="auth_provider">
<%= image_tag "auth/twitter_64.png", :size => "64x64", :alt => "Twitter" %>
@@ -19,12 +19,12 @@
</a>
<div class="clear"></div>
- <h3>Don't use these services?<br /> Just enter your email address:</h3>
+ <h3><%= t(".not_services") %><br /> <%= t(".enter_email") %></h3>
<%= form_tag new_user_path, :method => :get do %>
<p>
- <%= label_tag :email, "Email Address" %>
+ <%= label_tag :email, t(".email") %>
<%= text_field_tag :email, params[:email] %>
- <%= submit_tag "Continue", :name => nil %>
+ <%= submit_tag t(".continue"), :name => nil %>
</p>
<% end %>
</div>
View
26 app/views/games/_form.html.erb
@@ -3,22 +3,22 @@
<% if @game.new_record? %>
<% if guest? %>
<p>
- <strong>Playing against computer (GNU Go).</strong><br />
- To play against others you must first <%= link_to "sign in", signin_path %>.
+ <strong><%= t('.playing_against_computer') %></strong><br />
+ <%= t('.sign_in', :url => signin_path).html_safe %>
</p>
<% else %>
<p class="play_against">
- <strong>Play against:</strong><br />
- <%= f.radio_button :chosen_opponent, "gnugo" %> Computer (GNU Go)<br />
- <%= f.radio_button :chosen_opponent, "user" %> Username:
+ <strong><%= t('.play_against') %></strong><br />
+ <%= f.radio_button :chosen_opponent, "gnugo" %> <%= t('.computer') %><br />
+ <%= f.radio_button :chosen_opponent, "user" %> <%= t('.username') %>
<%= f.text_field :opponent_username %>
</p>
<% end %>
<%= div_hidden_if @game.chosen_opponent == "user", :class => "auto_difficulty" do %>
<p>
<%= f.check_box :adjust_difficulty %>
- <%= f.label :adjust_difficulty, "Automatically adjust difficulty", :class => "inline" %>
- <%= "(Level #{current_user.gnugo_level})" if current_user %>
+ <%= f.label :adjust_difficulty, t('.automatically_adjust_difficulty'), :class => "inline" %>
+ <%= t(".level", :level => current_user.gnugo_level) if current_user %>
</p>
<% end %>
<% else %>
@@ -26,22 +26,22 @@
<%= f.hidden_field :opponent_username %>
<% end %>
<p>
- <%= f.label :board_size %>
+ <%= f.label :board_size, t(".board_size") %>
<%= f.select :board_size, [["19 x 19", 19], ["13 x 13", 13], ["9 x 9", 9]] %>
</p>
<%= div_hidden_if @game.new_record? && @game.adjust_difficulty? && @game.chosen_opponent != "user", :class => "manual_difficulty" do %>
<p>
- <%= f.label :chosen_color, "Play as" %>
- <%= f.select :chosen_color, [["Random", ""], ["Black", "black"], ["White", "white"]] %>
+ <%= f.label :chosen_color, t(".play_as") %>
+ <%= f.select :chosen_color, [[t(".random"), ""], [t(".black"), "black"], [t(".white"), "white"]] %>
</p>
<p>
- <%= f.label :handicap %>
+ <%= f.label :handicap, t(".handicap") %>
<%= f.select :handicap, [0, 2, 3, 4, 5, 6, 7, 8, 9] %>
</p>
<p>
- <%= f.label :komi %>
+ <%= f.label :komi, t(".komi") %>
<%= f.select :komi, [0.5, 5.5, 6.5] %>
</p>
<% end %>
- <p class="field"><%= f.submit (@game.new_record? ? "Start Game" : "Update Game") %></p>
+ <p class="field"><%= f.submit (@game.new_record? ? t(".start_game") : t(".update_game")) %></p>
<% end %>
View
2  app/views/games/_other_games.html.erb
@@ -1,5 +1,5 @@
<div id="other_games">
- <h2>Watch a Game</h2>
+ <h2><%= t(".watch_a_game") %></h2>
<% @other_games.each_with_index do |game, index| %>
<% unless index.zero? %>
<div class="game_divider"></div>
View
34 app/views/games/_panel.html.erb
@@ -1,39 +1,39 @@
<% if @game.finished? %>
<div class="short_panel">
<% if !@game.started? %>
- <h2>Game has been declined.</h2>
+ <h2><%= t(".declined") %></h2>
<% elsif current_user && @game.winner == current_user %>
- <h2>Congratulations, you won!</h2>
- <p><%= link_to "Play Again", new_game_path(:board_size => @game.board_size) %></p>
+ <h2><%= t(".won") %></h2>
+ <p><%= link_to t(".play_again"), new_game_path(:board_size => @game.board_size) %></p>
<% elsif current_user && @game.loser == current_user %>
- <h2>Sorry, you lost.</h2>
- <p class="resources">Need some help? Check out the <%= link_to "Go Resources", go_resources_path %>.</p>
- <p><%= link_to "Play Again", new_game_path(:board_size => @game.board_size) %></p>
+ <h2><%= t(".lost") %></h2>
+ <p class="resources"><%= t(".need_help", :url => go_resources_path).html_safe %></p>
+ <p><%= link_to t(".play_again"), new_game_path(:board_size => @game.board_size) %></p>
<% else %>
- <h2><%= @game.winner ? (@game.winner.username || "Guest") : "GNU Go" %> won!</h2>
+ <h2><%= t(".winner", :winner_name => @game.winner ? (@game.winner.username || t(".guest")) : t(".gnu_go")) %></h2>
<% end %>
</div>
<% elsif @game.started? %>
<div class="short_panel">
- <p>Looks like the game has started, <%= link_to "reload", @game %> to play.</p>
+ <p><%= t(".started", :url => game_path(@game)).html_safe %></p>
</div>
<% elsif @game.current_player == current_user %>
<div class="tall_panel">
<%= form_for @game do |f| %>
- <h2>Challenge from <%= @game.opponent(current_user).username %></h2>
- <p class="game_setting">Board Size: <%= @game.board_size %></p>
- <p class="game_setting">Playing as: <%= @game.white_player == current_user ? "White" : "Black" %></p>
- <p class="game_setting">Komi: <%= @game.komi %></p>
- <p class="game_setting">Handicap: <%= @game.handicap %></p>
- <p>Want to change something? <%= link_to "Edit Settings", edit_game_path(@game) %></p>
+ <h2><%= t(".challenge_from", :username => @game.opponent(current_user).username) %></h2>
+ <p class="game_setting"><%= t(".board_size") %>: <%= @game.board_size %></p>
+ <p class="game_setting"><%= t(".playing_as") %>: <%= @game.white_player == current_user ? "White" : "Black" %></p>
+ <p class="game_setting"><%= t(".komi") %>: <%= @game.komi %></p>
+ <p class="game_setting"><%= t(".handicap") %>: <%= @game.handicap %></p>
+ <p><%= t(".change_settings", :url => edit_game_path(@game)).html_safe %></p>
<p>
- <%= f.submit "Accept", :name => "invitation_button", :id => "accept_button" %>
- <%= f.submit "Decline", :name => "invitation_button", :id => "decline_button" %>
+ <%= f.submit t(".accept"), :name => "invitation_button", :id => "accept_button" %>
+ <%= f.submit t(".decline"), :name => "invitation_button", :id => "decline_button" %>
</p>
<% end %>
</div>
<% else %>
<div class="short_panel">
- <p>Waiting for opponent to accept game.</p>
+ <p><%= t(".waiting") %></p>
</div>
<% end %>
View
2  app/views/games/new.html.erb
@@ -1,4 +1,4 @@
-<% title "New Go Game" %>
+<% title t(".new_go_game") %>
<% stylesheet "game" %>
<% @hide_footer = true %>
View
2  app/views/games/show.html.erb
@@ -1,4 +1,4 @@
-<% title "Play Go" %>
+<% title t(".play_go") %>
<% stylesheet "game" %>
<% @hide_footer = true %>
View
0  app/views/notifications/invitation.text.erb → ...iews/notifications/invitation.en.text.erb
File renamed without changes
View
14 app/views/notifications/invitation.zh-cn.text.erb
@@ -0,0 +1,14 @@
+Hi <%= @game.current_player.username %>,
+
+<%= @game.opponent.username %> 想和你下一盘围棋在 Go vs Go 网站。
+
+棋局: <%= game_url(@game) %>
+
+这是一封来自govsgo.com自动发送的邮件。
+
+--
+
+如果你不想再收到Go vs Go的邮件,你可以退订。
+
+退订地址: <%= unsubscribe_url(@game.current_player.unsubscribe_token) %>
+
View
0  app/views/notifications/message.text.erb → app/views/notifications/message.en.text.erb
File renamed without changes
View
14 app/views/notifications/message.zh-cn.text.erb
@@ -0,0 +1,14 @@
+Hi <%= @message.recipient.username %>,
+
+<%= @message.user.username %> 给你发送了一条聊天信息在 Go vs Go 网站: <%= @message.content %>
+
+棋局: <%= game_url(@game) %>
+
+这是一封来自govsgo.com自动发送的邮件。
+
+--
+
+如果你不想再收到Go vs Go的邮件,你可以退订。
+
+退订地址: <%= unsubscribe_url(@game.current_player.unsubscribe_token) %>
+
View
0  app/views/notifications/move.text.erb → app/views/notifications/move.en.text.erb
File renamed without changes
View
14 app/views/notifications/move.zh-cn.text.erb
@@ -0,0 +1,14 @@
+Hi <%= @game.current_player.username %>,
+
+你的对手 <%= @game.opponent.username %> 新下了一手在 Go vs Go 网站。
+
+棋局: <%= game_url(@game) %>
+
+这是一封来自govsgo.com自动发送的邮件。
+
+--
+
+如果你不想再收到Go vs Go的邮件,你可以退订。
+
+退订地址: <%= unsubscribe_url(@game.current_player.unsubscribe_token) %>
+
View
10 app/views/sessions/new.html.erb
@@ -1,20 +1,20 @@
-<% title "Log In" %>
+<% title t(".log_in") %>
<% stylesheet "authentication" %>
<div id="container" class="two_stones">
<div id="login_page">
- <h2 class="field">Log In</h2>
- <p class="field">Don't have an account? <%= link_to "Sign up!", signup_path %></p>
+ <h2 class="field"><%= t(".log_in") %></h2>
+ <p class="field"><%= t(".no_account") %> <%= link_to t(".sign_up"), signup_path %></p>
<%= form_tag sessions_path do %>
<p>
- <%= label_tag :login, "Username or Email" %>
+ <%= label_tag :login, t(".label_login") %>
<%= text_field_tag :login, params[:login] || params[:email] %>
</p>
<p>
<%= label_tag :password %>
<%= password_field_tag :password %>
</p>
- <p class="field"><%= submit_tag "Log in" %></p>
+ <p class="field"><%= submit_tag t(".log_in") %></p>
<% end %>
</div>
</div>
View
24 app/views/users/_form.html.erb
@@ -1,31 +1,31 @@
<%= form_for @user do |f| %>
<%= f.error_messages %>
<p>
- <%= f.label :username %>
+ <%= f.label :username, t(".username") %>
<%= f.text_field :username %>
</p>
<p>
- <%= f.label :email, "Email Address" %>
+ <%= f.label :email, t(".email") %>
<%= f.text_field :email %>
</p>
<% unless session[:omniauth] %>
<p>
- <%= f.label :password %>
+ <%= f.label :password, t(".password") %>
<%= f.password_field :password %>
</p>
<p>
- <%= f.label :password_confirmation, "Confirm Password" %>
+ <%= f.label :password_confirmation, t(".password_confirmation") %>
<%= f.password_field :password_confirmation %>
</p>
<% end %>
<p>
- <%= f.label :rank %>
+ <%= f.label :rank, t(".rank") %>
<%= f.text_field :rank, :size => 10 %>
- <span class="hint">such as "4k"</span><br>
- <span class="field hint">leave blank if unknown</span>
+ <span class="hint"><%= t(".rank_hint") %></span><br>
+ <span class="field hint"><%= t(".rank_blank") %></span>
</p>
<p>
- <%= f.label :time_zone, "Time Zone" %>
+ <%= f.label :time_zone, t(".time_zone") %>
<%= f.time_zone_select :time_zone, nil, :include_blank => true %>
</p>
<p>
@@ -34,15 +34,15 @@
</p>
<p class="field">
<%= f.check_box :email_on_invitation %>
- <%= f.label :email_on_invitation, "Email me new game invitations", :class => "inline" %>
+ <%= f.label :email_on_invitation, t(".email_on_invitation"), :class => "inline" %>
</p>
<p class="field">
<%= f.check_box :email_on_move %>
- <%= f.label :email_on_move, "Email me when opponent moves", :class => "inline" %>
+ <%= f.label :email_on_move, t(".email_on_move"), :class => "inline" %>
</p>
<p class="field">
<%= f.check_box :email_on_message %>
- <%= f.label :email_on_message, "Email me when opponent chats", :class => "inline" %>
+ <%= f.label :email_on_message, t(".email_on_message"), :class => "inline" %>
</p>
- <p class="field"><%= f.submit (@user.new_record? ? "Sign up" : "Update") %></p>
+ <p class="field"><%= f.submit (@user.new_record? ? t(".sign_up") : t(".update")) %></p>
<% end %>
View
12 app/views/users/edit.html.erb
@@ -1,28 +1,28 @@
-<% title "Update Profile" %>
+<% title t(".update_profile") %>
<% stylesheet "authentication" %>
<div id="container">
<div id="update_profile">
- <h2 class="field">Update Profile</h2>
+ <h2 class="field"><%= t(".update_profile") %></h2>
<%= render 'form' %>
</div>
<div id="authentications">
- <h2>Sign In Options</h2>
+ <h2><%= t(".sign_in_options") %></h2>
<% unless current_user.authentications.empty? %>
- <p><strong>You have signed in with these services:</strong></p>
+ <p><strong><%= t(".authentication_services") %></strong></p>
<div class="authentications">
<% for authentication in current_user.authentications %>
<div class="authentication">
<%= image_tag "auth/#{authentication.provider}_32.png", :size => "32x32" %>
<div class="provider"><%= authentication.provider_name %></div>
<div class="uid"><%= authentication.uid %></div>
- <%= link_to "X", authentication, :confirm => 'Are you sure you want to remove this authentication option?', :method => :delete, :class => "remove" %>
+ <%= link_to "X", authentication, :confirm => t(".remove_authentication_confirm"), :method => :delete, :class => "remove" %>
</div>
<% end %>
</div>
<% end %>
- <p><strong>Add another service to sign in with:</strong></p>
+ <p><strong><%= t(".add_authentication_service") %></strong></p>
<a href="/auth/twitter" class="auth_provider">
<%= image_tag "auth/twitter_64.png", :size => "64x64", :alt => "Twitter" %>
View
6 app/views/users/new.html.erb
@@ -1,10 +1,10 @@
-<% title "Sign Up" %>
+<% title t(".sign_up") %>
<% stylesheet "authentication" %>
<div id="container" class="two_stones">
<div id="sign_up">
- <h2 class="field">Sign Up</h2>
- <p class="field">Already have an account? <%= link_to "Log in", login_path %>.</p>
+ <h2 class="field"><%= t(".sign_up") %></h2>
+ <p class="field"><%= t(".already_have_an_account") %> <%= link_to t(".log_in"), login_path %>.</p>
<%= render 'form' %>
</div>
</div>
View
16 app/views/users/show.html.erb
@@ -8,34 +8,34 @@
<div class="clear"></div>
<div class="details">
<p>
- Currently: <%= @user.online? ? "Online" : "Offline" %>
+ <%= t(".currently") %>: <%= @user.online? ? t(".online") : t(".offline") %>
</p>
<% if @user.rank.present? %>
<p>
- Go Rank: <%= @user.rank %>
+ <%= t(".rank") %>: <%= @user.rank %>
</p>
<% end %>
<p>
- GNU Go Auto-level:
+ <%= t(".gnugo_level") %>:
<%= @user.gnugo_level %>
</p>
<p>
- Games with GNU Go:
+ <%= t(".games_with_gnugo") %>:
<%= @user.games.with_gnugo.size %>
</p>
<p>
- Games with Others:
+ <%= t(".games_with_others") %>:
<%= @user.games.without_gnugo.size %>
</p>
</div>
<% if @user == current_user %>
- <h3><%= link_to "Edit Profile", edit_current_user_path %> or <%= link_to "Log Out", logout_path %></h3>
+ <h3><%= link_to t(".edit_profile"), edit_current_user_path %> <%= t(".or") %> <%= link_to t(".log_out"), logout_path %></h3>
<% else %>
- <%= link_to "Challenge to a Game", new_game_path(:username => @user.username), :class => "button" %>
+ <%= link_to t(".challenge_to_a_game"), new_game_path(:username => @user.username), :class => "button" %>
<% end %>
</div>
<div class="column">
- <h2><%= @user.username %>'s Games</h2>
+ <h2><%= t(".his_games", :username => @user.username) %></h2>
<% @games.each_with_index do |game, index| %>
<% unless index.zero? %>
<div class="game_divider"></div>
View
31 config/locales/controllers.en.yml
@@ -0,0 +1,31 @@
+en:
+ controllers:
+ authentications:
+ signed_in_as: Signed in as %{username}
+ create: Authentication successful.
+ destroy: Successfully destroyed authentication.
+ login_required: You must first log in or sign up before accessing this page.
+ user_required: You must first log in or sign up before accessing this page.
+
+ games:
+ create: Game started. Click on a point below to place your stone.
+
+ moves:
+ illegal_move: That is an illegal move.
+ out_of_turn: It is not your turn to move.
+
+ sessions:
+ create_success: Logged in successfully.
+ create_fail: Invalid login or password.
+ destroy: You have been logged out.
+
+ users:
+ new_update: Please update your profile below.
+ new_login: It appears you already have an account, please login below.
+ create: Thank you for signing up! You are now logged in.
+ update: Your profile has been updated.
+ unsubscribe: You have been unsubscribed from further email notifications.
+ publicize_guest: You must first sign in to be added to the Looking for Games list.
+ publicize_remove: You have been removed from the Looking for Games list.
+ publicize_add: You have been added to the Looking for Games list.
+
View
31 config/locales/controllers.zh-cn.yml
@@ -0,0 +1,31 @@
+zh-cn:
+ controllers:
+ authentications:
+ signed_in_as: 作为 %{username} 登录
+ create: 认证成功。
+ destroy: 成功移除认证。
+ login_required: 你必须先登录或者注册才能访问这个页面。
+ user_required: 你必须先登录或者注册才能访问这个页面。
+
+ games:
+ create: 游戏开始了,点击棋盘上放下你的棋子。
+
+ moves:
+ illegal_move: 无法在这个位置下子。
+ out_of_turn: 不是你的回合。
+
+ sessions:
+ create_success: 登录成功。
+ create_fail: 用户名或者密码错误。
+ destroy: 你已经登出。
+
+ users:
+ new_update: 请更新你的个人资料。
+ new_login: 你好像已经有帐户了,请登录。
+ create: 感谢注册,你已经登录了。
+ update: 你的个人资料已经更新。
+ unsubscribe: 你已经退订了邮件通知。
+ publicize_guest: 你必须先登录才能添加到 寻找棋友 列表。
+ publicize_remove: 你已经从 寻找棋友 列表删除。
+ publicize_add: 你已经被添加到 寻找棋友 列表。
+
View
14 config/locales/helpers.en.yml
@@ -0,0 +1,14 @@
+en:
+ helpers:
+ application:
+ guest: Guest
+ gnu_go: GNU Go
+ yesterday: yesterday
+
+ games:
+ won: won
+ won_by: won by %{score}
+ captured_stone:
+ zero: 0 captured stone
+ one: 1 captured stone
+ other: '%{count} captured stones'
View
14 config/locales/helpers.zh-cn.yml
@@ -0,0 +1,14 @@
+zh-cn:
+ helpers:
+ application:
+ guest: 访客
+ gnu_go: GNU Go
+ yesterday: 昨天
+
+ games:
+ won: 赢了
+ won_by: 赢了 %{score} 分
+ captured_stone:
+ zero: 0 吃子
+ one: 1 吃子
+ other: '%{count} 吃子'
View
108 config/locales/views.en.yml
@@ -9,6 +9,32 @@ en:
remove_yourself_from_list: Remove yourself from list
add_yourself_to_list: Add yourself to list
guest_add_to_list: To add yourself to this list, first <a href="%{url}">sign in</a>.
+
+ new:
+ new_go_game: New Go Game
+
+ show:
+ play_go: Play Go
+
+ panel:
+ declined: Game has been declined
+ won: Congratulations, you won!
+ play_again: Play Again
+ lost: Sorry, you lost.
+ need_help: Need some help? Check out the <a href="%{url}">Go Resources</a>.
+ guest: Guest
+ winner: '%{winner_name} won!'
+ gnu_go: GNU Go
+ started: Looks like the game has started, <a href="%{url}">reload</a> to play.
+ challenge_from: Challenge from %{username}
+ board_size: Board size
+ playing_as: Playing as
+ komi: Komi
+ handicap: Handicap
+ change_settings: Want to change something? <a href="%{url}">Edit Settings</a>
+ accept: Accept
+ decline: Decline
+ waiting: Waiting for opponent to accept game.
your_games:
your_games: Your Games
@@ -17,6 +43,9 @@ en:
try_a_quick_game: Try a quick game
or: or
watch_a_video_tour: Watch a video tour
+
+ other_games:
+ watch_a_game: Watch a Game
game:
moved_ago: Moved %{time} ago
@@ -31,10 +60,89 @@ en:
pass: Pass
resign: Resign
+ form:
+ playing_against_computer: Playing against computer (GNU Go).
+ sign_in: To play against others you must first <a href="%{url}">sign in</a>.
+ play_against: Play against
+ computer: Computer (GNU Go)
+ username: Username
+ automatically_adjust_difficulty: Automatically adjust difficulty
+ level: '(Level: %{level})'
+ board_size: Board size
+ play_as: Play as
+ random: Random
+ black: Black
+ white: White
+ handicap: Handicap
+ komi: Komi
+ start_game: Start game
+ update_game: Update game
+
side:
private_chat: Private Chat
send: Send
users:
form:
+ username: Username
+ email: Email address
+ password: Password
+ password_confirmation: Password confirmation
+ rank: Rank
+ rank_hint: such as "4k"
+ rank_blank: leave blank if unknown
+ time_zone: Time zone
locale: Language
+ email_on_invitation: Email me new game invitations
+ email_on_move: Email me when opponent moves
+ email_on_message: Email me when opponent chats
+ sign_up: Sign up
+ update: Update
+
+ show:
+ currently: Currently
+ online: Online
+ offline: Offline
+ rank: Go Rank
+ gnugo_level: GNU Go Auto-level
+ games_with_gnugo: Games with GNU Go
+ games_with_others: Games with Others
+ edit_profile: Edit Profile
+ or: or
+ log_out: Log Out
+ challenge_to_a_game: Challenge to a Game
+ his_games: "%{username}'s Games"
+
+ edit:
+ update_profile: Update Profile
+ sign_in_options: Sign In Options
+ authentication_services: 'You have signed in with these services:'
+ remove_authentication_confirm: Are you sure you want to remove this authentication option?
+ add_authentication_service: 'Add another service to sign in with:'
+
+ new:
+ sign_up: Sign Up
+ already_have_an_account: Already have an account?
+ log_in: Log in
+
+
+ sessions:
+ new:
+ log_in: Log In
+ no_account: Don't have an account?
+ sign_up: Sign Up!
+ label_login: Username or Email
+
+ authentications:
+ index:
+ sign_in: Sign In
+ sign_in_services: Sign in through one of the following services
+ not_services: Don't use these services?
+ enter_email: 'Just enter your email address:'
+ email: Email Address
+ continue: Continue
+
+ notifications:
+ invitation: '[Go vs Go] Invitation from %{username}'
+ move: '[Go vs Go] Move by %{username}'
+ chat: '[Go vs Go] Chat from %{username}'
View
133 config/locales/views.zh-cn.yml
@@ -9,7 +9,140 @@ zh-cn:
remove_yourself_from_list: 将我从列表中移除
add_yourself_to_list: 将我加入到列表
guest_add_to_list: 您需要先<a href="%{url}">登录</a>,就可以加入到这个列表。
+
+ new:
+ new_go_game: 新的一盘
+
+ show:
+ play_go: 下围棋
+
+ panel:
+ declined: 这盘棋被拒绝了
+ won: 祝贺你,你赢了!
+ play_again: 再来一盘
+ lost: 很遗憾,你输了。
+ need_help: 需要帮助? 看看相关的 <a href="%{url}">围棋资源</a>吧。
+ guest: 访客
+ winner: '%{winner_name} 赢了!'
+ gnu_go: GNU Go
+ started: 游戏已经开始,<a href="%{url}">刷新一下</a> 开始下棋。
+ challenge_from: 来自 %{username} 的挑战
+ board_size: 棋盘大小
+ playing_as: 作为
+ komi: 贴目
+ handicap: 让子
+ change_settings: 想改一下? <a href="%{url}">编辑设置</a>
+ accept: 接受
+ decline: 拒绝
+ waiting: 等待对手接受这盘棋。
+
+ your_games:
+ your_games: 你的棋局
+ new_game: 新的棋局
+ no_games: 你还没有任何棋局
+ try_a_quick_game: 快速来一盘
+ or: 或者
+ watch_a_video_tour: 看一下视频
+
+ other_games:
+ watch_a_game: 看一盘棋
+
+ game:
+ moved_ago: '%{time} 前最后一手'
+
+ profile:
+ as_white: 作为白方
+ as_black: 作为黑方
+ current_player: 当前玩家
+ komi: '%{count} 贴目'
+ handicap: '%{count} 让子'
+ captured_stone: '%{count} 吃子数'
+ pass: 跳过
+ resign: 认输
+
+ form:
+ playing_against_computer: 和电脑对抗 (GNU Go)。
+ sign_in: 你必须先 <a href="%{url}">登录</a> 才能和其他人下棋。
+ play_against: 和谁下
+ computer: 电脑 (GNU Go)
+ username: 用户名
+ automatically_adjust_difficulty: 自动调节难度
+ level: '(等级: %{level})'
+ board_size: 棋盘大小
+ play_as: 作为
+ random: 随机
+ black: 黑方
+ white: 白方
+ handicap: 让子
+ komi: 贴目
+ start_game: 开始游戏
+ update_game: 更新游戏
+
+ side:
+ private_chat: 私聊
+ send: 发送
users:
form:
+ username: 用户名
+ email: 邮件地址
+ password: 密码
+ password_confirmation: 确认密码
+ rank: 等级
+ rank_hint: 比如 "4k"
+ rank_blank: 如果不了解,可以留空
+ time_zone: 时区
locale: 语言
+ email_on_invitation: 如果有新的游戏邀请,发邮件给我
+ email_on_move: 如果对手下了一手,发邮件给我
+ email_on_message: 如果对手发送聊天信息,发邮件给我
+ sign_up: 注册
+ update: 更新
+
+ show:
+ currently: 当前
+ online: 在线
+ offline: 离线
+ rank: 围棋等级
+ gnugo_level: GNU Go 自动等级
+ games_with_gnugo: 和GNU Go下过
+ games_with_others: 和其他人下过
+ edit_profile: 编辑个人资料
+ or: 或者
+ log_out: 登出
+ challenge_to_a_game: 挑战一盘
+ his_games: "%{username} 的棋局"
+
+ edit:
+ update_profile: 更新个人资料
+ sign_in_options: 登录选项
+ authentication_services: 你已经使用下列服务登录:
+ remove_authentication_confirm: 你确定要移除这个认证服务吗?
+ add_authentication_service: 添加其他的认证服务
+
+ new:
+ sign_up: 注册
+ already_have_an_account: 已经有帐号了?
+ log_in: 登录
+
+
+ sessions:
+ new:
+ log_in: 登录
+ no_account: 还没有帐号?
+ sign_up: 注册
+ label_login: 用户名或密码
+
+ authentications:
+ index:
+ sign_in: 登录
+ sign_in_services: 用下列服务登录:
+ not_services: 不使用这些服务?
+ enter_email: 输入你的邮件地址:
+ email: 邮件地址
+ continue: 继续
+
+ notifications:
+ invitation: '[Go vs Go] 来自 %{username} 的邀请'
+ move: '[Go vs Go] %{username} 下了一手'
+ chat: '[Go vs Go] 来自 %{username} 的聊天'
View
4 lib/controller_authentication.rb
@@ -48,7 +48,7 @@ def guest?
current_user.nil? || current_user.guest?
end
- def login_required(message = "You must first log in or sign up before accessing this page.")
+ def login_required(message = t("login_required", :scope => "controllers.authentications"))
unless logged_in?
flash[:alert] = message
store_target_location
@@ -56,7 +56,7 @@ def login_required(message = "You must first log in or sign up before accessing
end
end
- def user_required(message = "You must first log in or sign up before accessing this page.")
+ def user_required(message = t("user_required", :scope => "controllers.authentications"))
if guest?
flash[:alert] = message
store_target_location
Please sign in to comment.
Something went wrong with that request. Please try again.