Skip to content
Browse files

Merge branch 'release/0.1.0'

  • Loading branch information...
2 parents 668b0d6 + bca953f commit 979d5b4851f305cf5225cf8b48929e0393e39c38 @quake committed Dec 30, 2011
Showing with 902 additions and 190 deletions.
  1. +2 −1 .gitignore
  2. +3 −3 Gemfile
  3. +51 −46 Gemfile.lock
  4. +1 −0 app/controllers/application_controller.rb
  5. +6 −4 app/controllers/authentications_controller.rb
  6. +2 −2 app/controllers/games_controller.rb
  7. +2 −2 app/controllers/moves_controller.rb
  8. +5 −3 app/controllers/sessions_controller.rb
  9. +8 −7 app/controllers/users_controller.rb
  10. +6 −6 app/helpers/application_helper.rb
  11. +3 −3 app/helpers/games_helper.rb
  12. +6 −3 app/mailers/notifications.rb
  13. +2 −2 app/models/game.rb
  14. +1 −1 app/models/user.rb
  15. +5 −5 app/views/authentications/index.html.erb
  16. +13 −13 app/views/games/_form.html.erb
  17. +1 −1 app/views/games/_game.html.erb
  18. +1 −1 app/views/games/_other_games.html.erb
  19. +17 −17 app/views/games/_panel.html.erb
  20. +5 −5 app/views/games/_profile.html.erb
  21. +2 −2 app/views/games/_side.html.erb
  22. +5 −5 app/views/games/_your_games.html.erb
  23. +7 −7 app/views/games/index.html.erb
  24. +1 −1 app/views/games/new.html.erb
  25. +1 −1 app/views/games/show.html.erb
  26. +5 −5 app/views/layouts/application.html.erb
  27. 0 app/views/notifications/{invitation.text.erb → invitation.en.text.erb}
  28. +14 −0 app/views/notifications/invitation.zh-cn.text.erb
  29. 0 app/views/notifications/{message.text.erb → message.en.text.erb}
  30. +14 −0 app/views/notifications/message.zh-cn.text.erb
  31. 0 app/views/notifications/{move.text.erb → move.en.text.erb}
  32. +14 −0 app/views/notifications/move.zh-cn.text.erb
  33. +5 −5 app/views/sessions/new.html.erb
  34. +16 −12 app/views/users/_form.html.erb
  35. +6 −6 app/views/users/edit.html.erb
  36. +3 −3 app/views/users/new.html.erb
  37. +8 −8 app/views/users/show.html.erb
  38. +1 −1 config/application.rb
  39. +31 −0 config/locales/controllers.en.yml
  40. +31 −0 config/locales/controllers.zh-cn.yml
  41. +0 −5 config/locales/en.yml
  42. +14 −0 config/locales/helpers.en.yml
  43. +14 −0 config/locales/helpers.zh-cn.yml
  44. +8 −0 config/locales/layouts.en.yml
  45. +8 −0 config/locales/layouts.zh-cn.yml
  46. +213 −0 config/locales/rails.zh-cn.yml
  47. +148 −0 config/locales/views.en.yml
  48. +148 −0 config/locales/views.zh-cn.yml
  49. +9 −0 db/migrate/20111220092137_add_locale_to_users.rb
  50. +2 −2 lib/controller_authentication.rb
  51. +32 −0 lib/controller_i18n.rb
  52. +2 −2 spec/models/game_spec.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
6 Gemfile
@@ -1,16 +1,16 @@
source 'http://rubygems.org'
-gem 'rails', '3.0.3'
+gem 'rails', '3.0.11'
gem 'mysql2'
gem 'omniauth'
gem 'jquery-rails'
gem 'bcrypt-ruby', :require => 'bcrypt'
gem 'will_paginate', '3.0.pre2'
gem 'whenever', :require => false
-gem 'go_gtp', '0.0.4', :require => 'go/gtp', :git => "git://github.com/JEG2/go_gtp.git"
+gem 'go_gtp', :require => 'go/gtp', :git => "http://github.com/JEG2/go_gtp.git"
gem 'stalker', '0.5.0'
gem 'oily_png', '0.1.0'
-gem 'exception_notification', :git => 'git://github.com/rails/exception_notification.git', :require => 'exception_notifier'
+gem 'exception_notification', :git => 'http://github.com/rails/exception_notification.git', :require => 'exception_notifier'
group :development, :test do
gem 'mocha'
View
97 Gemfile.lock
@@ -1,11 +1,11 @@
GIT
- remote: git://github.com/JEG2/go_gtp.git
- revision: 2753f3ebeb3c058bfc05eca20810df67557844c6
+ remote: http://github.com/JEG2/go_gtp.git
+ revision: a1cc912436c8e0bac10bca693ce583c8baf2a0c4
specs:
- go_gtp (0.0.4)
+ go_gtp (0.0.5.alpha)
GIT
- remote: git://github.com/rails/exception_notification.git
+ remote: http://github.com/rails/exception_notification.git
revision: 192a49a02d63d28b23ed41cebadfedd490929cf1
specs:
exception_notification (1.0.0)
@@ -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)
@@ -207,7 +212,7 @@ DEPENDENCIES
capistrano
exception_notification!
factory_girl_rails
- go_gtp (= 0.0.4)!
+ go_gtp!
guard
guard-rspec
jquery-rails
@@ -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
1 app/controllers/application_controller.rb
@@ -1,5 +1,6 @@
class ApplicationController < ActionController::Base
include ControllerAuthentication
+ include ControllerI18n
protect_from_forgery
before_filter :mark_user_request, :if => :logged_in?
before_filter :set_user_time_zone, :if => :logged_in?
View
10 app/controllers/authentications_controller.rb
@@ -1,4 +1,6 @@
class AuthenticationsController < ApplicationController
+ after_filter :change_locale, :only => [:create]
+
def index
end
@@ -10,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
@@ -20,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
@@ -37,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
8 app/controllers/sessions_controller.rb
@@ -1,22 +1,24 @@
class SessionsController < ApplicationController
+ after_filter :change_locale, :only => [:create]
+
def new
end
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
15 app/controllers/users_controller.rb
@@ -1,5 +1,6 @@
class UsersController < ApplicationController
before_filter :login_required, :except => [:show, :new, :create, :unsubscribe]
+ after_filter :change_locale, :only => [:create, :update]
def show
@user = User.where(:guest => false).find(params[:id])
@@ -9,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
@@ -23,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'
@@ -47,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'
@@ -57,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
12 app/helpers/application_helper.rb
@@ -29,26 +29,26 @@ 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
def relative_time(time)
- [relative_date(time.to_date), time.strftime("%I:%M %p")].compact.join(" ")
+ [relative_date(time.to_date), l(time, :format => '%I:%M %p')].compact.join(" ")
end
def relative_date(date)
today = Time.zone.now.to_date
if date == today
nil
elsif date == today-1
- "yesterday"
+ t("yesterday", :scope => "helpers.application")
elsif date.year == today.year
- date.strftime("%b %d")
+ l(date, :format => "%b %d")
else
- date.strftime("%b %d, %Y")
+ l(date, :format => "%b %d, %Y")
end
end
end
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
- "won"
+ t("won", :scope => "helpers.games")
elsif score.to_f > 0
- "won by #{score}"
+ t("won_by", :score => score, :scope => "helpers.games")
end
else
- pluralize(score.to_i, "captured stone")
+ 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
4 app/models/game.rb
@@ -155,9 +155,9 @@ def active?
def profile_for(color)
Profile.new(color).tap do |profile|
if color.to_sym == :white
- profile.handicap_or_komi = "#{komi} komi"
+ profile.handicap_or_komi = [komi, 'komi']
else
- profile.handicap_or_komi = "#{handicap} handicap"
+ profile.handicap_or_komi = [handicap, 'handicap']
end
profile.score = send("#{color}_score")
profile.captured = captured(color)
View
2 app/models/user.rb
@@ -1,5 +1,5 @@
class User < ActiveRecord::Base
- attr_accessible :username, :email, :password, :password_confirmation, :guest, :rank, :email_on_invitation, :email_on_move, :email_on_message, :time_zone
+ attr_accessible :username, :email, :password, :password_confirmation, :guest, :rank, :email_on_invitation, :email_on_move, :email_on_message, :time_zone, :locale
has_many :authentications
has_many :messages
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,45 +3,45 @@
<% 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 %>
<%= f.hidden_field :chosen_opponent %>
<%= 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/_game.html.erb
@@ -5,7 +5,7 @@
<div class="player <%= profile.color %>"><%= link_to_user(profile.user) %> <%= online_status(profile.user) %></div>
<% end %>
<% if game.last_move_at %>
- <div class="status">moved <%= time_ago_in_words(game.last_move_at) %> ago</div>
+ <div class="status"><%= t('.moved_ago', :time => time_ago_in_words(game.last_move_at)) %></div>
<% end %>
</div>
<%= link_to "Go", game, :class => "go_button" %>
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
10 app/views/games/_profile.html.erb
@@ -6,16 +6,16 @@
<%= avatar_image_tag(profile.user) %>
<div class="profile">
<div class="details">
- <div class="name"><%= link_to_user(profile.user) %> as <%= profile.color.to_s.titleize %> <%= online_status(profile.user) %></div>
- <div id="turn_<%= profile.user_id %>" class="turn"<%= raw ' style="display: none;"' unless profile.current && !@game.finished? %>>current player</div>
+ <div class="name"><%= link_to_user(profile.user) %> <%= t(".as_#{profile.color}") %> <%= online_status(profile.user) %></div>
+ <div id="turn_<%= profile.user_id %>" class="turn"<%= raw ' style="display: none;"' unless profile.current && !@game.finished? %>><%= t('.current_player') %></div>
<div id="<%= profile.color.to_s[0] %>_status" class="status"><%= profile.last_status %></div>
- <div class="komi_or_handicap"><%= profile.handicap_or_komi %></div>
+ <div class="komi_or_handicap"><%= t(".#{profile.handicap_or_komi.last}", :count => profile.handicap_or_komi.first) %></div>
<div id="score_<%= profile.user_id %>" class="score"><%= game_score profile.score, @game.finished? %></div>
</div>
<% if profile.user && profile.user == current_user %>
<div id="player_actions">
- <%= link_to "Pass", '#', :id => "play_pass" %>
- <%= link_to "Resign", '#', :id => "play_resign" %>
+ <%= link_to t('.pass'), '#', :id => "play_pass" %>
+ <%= link_to t('.resign'), '#', :id => "play_resign" %>
</div>
<% end %>
</div>
View
4 app/views/games/_side.html.erb
@@ -6,12 +6,12 @@
<% end %>
<% if @game.player?(current_user) && @game.black_player.present? && @game.white_player.present? %>
<div class="column">
- <h2>Private Chat</h2>
+ <h2><%= t('.private_chat') %></h2>
<div id="messages"><%= render @game.messages.order(:created_at) %></div>
<%= form_for Message.new(:game_id => @game.id) do |f| %>
<%= f.hidden_field :game_id %>
<%= f.text_field :content %>
- <%= f.submit "Send" %>
+ <%= f.submit t('.send') %>
<% end %>
</div>
<% else %>
View
10 app/views/games/_your_games.html.erb
@@ -1,13 +1,13 @@
<div id="your_games">
- <h2>Your Games <%= link_to "New Game", new_game_path(:board_size => 9) %></h2>
+ <h2><%= t '.your_games' %> <%= link_to t('.new_game'), new_game_path(:board_size => 9) %></h2>
<% if @your_games.blank? %>
<div class="no_games">
<div class="details">
- <strong>You do not have any games yet.</strong><br />
- <%= link_to "Try a quick game", new_game_path(:board_size => 9) %>
- or <%= link_to "watch a video tour", "http://media.railscasts.com/videos/govsgo.mov" %>.
+ <strong><%= t('.no_games') %></strong><br />
+ <%= link_to t('.try_a_quick_game'), new_game_path(:board_size => 9) %>
+ <%= t('.or') %> <%= link_to t('.watch_a_video_tour'), "http://media.railscasts.com/videos/govsgo.mov" %>
</div>
- <a href="http://media.railscasts.com/videos/govsgo.mov"><%= link_to image_tag("screencast.png", :size => "259x278", :alt => "Watch the Screencast"), "http://media.railscasts.com/videos/govsgo.mov", :class => "screencast" %></a>
+ <a href="http://media.railscasts.com/videos/govsgo.mov"><%= link_to image_tag("screencast.png", :size => "259x278", :alt => t('.watch_a_video_tour')), "http://media.railscasts.com/videos/govsgo.mov", :class => "screencast" %></a>
</div>
<% else %>
<% @your_games.each_with_index do |game, index| %>
View
14 app/views/games/index.html.erb
@@ -4,9 +4,9 @@
<div id="container" class="two_stones">
<div id="welcome">
- <h2>Welcome</h2>
- <p>Go is a board game invented in China more than 4,000 years ago. It is more popular in the far East than Chess in the West. The rules are simple but mastering the game can take a lifetime.</p>
- <p>We invite you to <%= link_to "try a game", new_game_path(:board_size => 9) %> against the computer or online with other players.</p>
+ <h2><%= t('.welcome') %></h2>
+ <p><%= t('.go_description') %></p>
+ <p><%= t('.try_a_game', :link => new_game_path(:board_size => 9)).html_safe %></p>
</div>
<div class="columns">
@@ -22,7 +22,7 @@
</div>
<div class="column">
<div class="column_padding">
- <h2>Looking for Games</h2>
+ <h2><%= t('.looking_for_games') %></h2>
<% @users.each_with_index do |user, index| %>
<% unless index.zero? %>
<div class="user_divider"></div>
@@ -39,11 +39,11 @@
<% end %>
<div class="buttons">
<% if guest? %>
- To add yourself to this list, first <%= link_to "sign in", signin_url %>.
+ <%= t('.guest_add_to_list', :url => signin_url).html_safe %>
<% elsif @users.include? current_user %>
- <%= link_to "Remove Yourself from List", publicize_path(:remove => true), :method => :put, :class => "button" %>
+ <%= link_to t('.remove_yourself_from_list'), publicize_path(:remove => true), :method => :put, :class => "button" %>
<% else %>
- <%= link_to "Add Yourself to List", publicize_path, :method => :put, :class => "button" %>
+ <%= link_to t('.add_yourself_to_list'), publicize_path, :method => :put, :class => "button" %>
<% end %>
</div>
</div>
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
10 app/views/layouts/application.html.erb
@@ -10,16 +10,16 @@
<body>
<a href="/" id="logo"><img src="/images/layout/logo.png" width="241" height="96" alt="Go vs Go" /></a>
<ul id="nav">
- <li class="banner blue"><%= link_to "Home", root_path %></li>
+ <li class="banner blue"><%= link_to t(".home"), root_path %></li>
<li class="gap"></li>
- <li class="banner purple"><%= link_to "Play a Game", new_game_path %></li>
+ <li class="banner purple"><%= link_to t(".play_a_game"), new_game_path %></li>
<li class="gap"></li>
- <li class="banner red"><%= link_to "Go Resources", go_resources_path %></li>
+ <li class="banner red"><%= link_to t(".go_resources"), go_resources_path %></li>
<li class="gap"></li>
<% if guest? %>
- <li class="banner brown"><%= link_to "Sign In", signin_path %></li>
+ <li class="banner brown"><%= link_to t(".sign_in"), signin_path %></li>
<% else %>
- <li class="banner brown"><%= link_to "Your Profile", current_user %></li>
+ <li class="banner brown"><%= link_to t(".your_profile"), current_user %></li>
<% end %>
<div class="clear">
</ul>
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
28 app/views/users/_form.html.erb
@@ -1,44 +1,48 @@
<%= 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>
+ <%= f.label :locale, t('.locale') %>
+ <%= f.select :locale, [['English', 'en'], ['简体中文', 'zh-cn']] %>
+ </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
2 config/application.rb
@@ -32,7 +32,7 @@ class Application < Rails::Application
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
- # config.i18n.default_locale = :de
+ config.i18n.default_locale = :en
# JavaScript files you want as :defaults (application.js is always included).
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
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
5 config/locales/en.yml
@@ -1,5 +0,0 @@
-# Sample localization file for English. Add more files in this directory for other locales.
-# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
-
-en:
- hello: "Hello world"
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
8 config/locales/layouts.en.yml
@@ -0,0 +1,8 @@
+en:
+ layouts:
+ application:
+ home: Home
+ play_a_game: Play a Game
+ go_resources: Go Resources
+ sign_in: Sign In
+ your_profile: Your Profile
View
8 config/locales/layouts.zh-cn.yml
@@ -0,0 +1,8 @@
+zh-cn:
+ layouts:
+ application:
+ home: 首页
+ play_a_game: 玩一盘
+ go_resources: 围棋资源
+ sign_in: 登录
+ your_profile: 个人资料
View
213 config/locales/rails.zh-cn.yml
@@ -0,0 +1,213 @@
+# Chinese (China) translations for Ruby on Rails
+# by tsechingho (http://github.com/tsechingho)
+
+zh-cn:
+ date:
+ formats:
+ default: "%Y-%m-%d"
+ short: "%b%d日"
+ long: "%Y年%b%d日"
+ day_names:
+ - 星期日
+ - 星期一
+ - 星期二
+ - 星期三
+ - 星期四
+ - 星期五
+ - 星期六
+ abbr_day_names:
+ -
+ -
+ -
+ -
+ -
+ -
+ -
+ month_names:
+ - ~
+ - 一月
+ - 二月
+ - 三月
+ - 四月
+ - 五月
+ - 六月
+ - 七月
+ - 八月
+ - 九月
+ - 十月
+ - 十一月
+ - 十二月
+ abbr_month_names:
+ - ~
+ - 1月
+ - 2月
+ - 3月
+ - 4月
+ - 5月
+ - 6月
+ - 7月
+ - 8月
+ - 9月
+ - 10月
+ - 11月
+ - 12月
+ order:
+ - :year
+ - :month
+ - :day
+
+ time:
+ formats:
+ default: "%Y年%b%d日 %A %H:%M:%S %Z"
+ short: "%b%d日 %H:%M"
+ long: "%Y年%b%d日 %H:%M"
+ am: "上午"
+ pm: "下午"
+
+ datetime:
+ distance_in_words:
+ half_a_minute: "半分钟"
+ less_than_x_seconds:
+ one: "不到一秒"
+ other: "不到 %{count} 秒"
+ x_seconds:
+ one: "一秒"
+ other: "%{count} 秒"
+ less_than_x_minutes:
+ one: "不到一分钟"
+ other: "不到 %{count} 分钟"
+ x_minutes:
+ one: "一分钟"
+ other: "%{count} 分钟"
+ about_x_hours:
+ one: "大约一小时"
+ other: "大约 %{count} 小时"
+ x_days:
+ one: "一天"
+ other: "%{count} 天"
+ about_x_months:
+ one: "大约一个月"
+ other: "大约 %{count} 个月"
+ x_months:
+ one: "一个月"
+ other: "%{count} 个月"
+ about_x_years:
+ one: "大约一年"
+ other: "大约 %{count} 年"
+ over_x_years:
+ one: "一年多"
+ other: "%{count} 年多"
+ almost_x_years:
+ one: "接近一年"
+ other: "接近 %{count} 年"
+ prompts:
+ year: ""
+ month: ""
+ day: ""
+ hour: ""
+ minute: ""
+ second: ""
+
+ number:
+ format:
+ separator: "."
+ delimiter: ","
+ precision: 3
+ significant: false
+ strip_insignificant_zeros: false
+ currency:
+ format:
+ format: "%u %n"
+ unit: "CN¥"
+ separator: "."
+ delimiter: ","
+ precision: 2
+ significant: false
+ strip_insignificant_zeros: false
+ percentage:
+ format:
+ delimiter: ""
+ precision:
+ format:
+ delimiter: ""
+ human:
+ format:
+ delimiter: ""
+ precision: 1
+ significant: false
+ strip_insignificant_zeros: false
+ storage_units:
+ format: "%n %u"
+ units:
+ byte:
+ one: "Byte"
+ other: "Bytes"
+ kb: "KB"
+ mb: "MB"
+ gb: "GB"
+ tb: "TB"
+ decimal_units:
+ format: "%n %u"
+ units:
+ unit: ""
+ thousand: "" # 10^3 kilo
+ million: "百万" # 10^6 mega
+ billion: "十亿" # 10^9 giga
+ trillion: "" # 10^12 tera
+ quadrillion: "千兆" # 10^15 peta
+ # 10^18 exa, 10^21 zetta, 10^24 yotta
+
+ support:
+ array:
+ words_connector: ", "
+ two_words_connector: ""
+ last_word_connector: ", 和 "
+ select:
+ prompt: "请选择"
+
+ errors:
+ format: "%{attribute} %{message}"
+ messages: &errors_messages
+ inclusion: "不包含于列表中"
+ exclusion: "是保留关键字"
+ invalid: "是无效的"
+ confirmation: "与确认值不匹配"
+ accepted: "必须是可被接受的"
+ empty: "不能留空"
+ blank: "不能为空字符"
+ too_long: "过长(最长为 %{count} 个字符)"
+ too_short: "过短(最短为 %{count} 个字符)"
+ wrong_length: "长度非法(必须为 %{count} 个字符)"
+ not_a_number: "不是数字"
+ not_an_integer: "必须是整数"
+ greater_than: "必须大于 %{count}"
+ greater_than_or_equal_to: "必须大于或等于 %{count}"
+ equal_to: "必须等于 %{count}"
+ less_than: "必须小于 %{count}"
+ less_than_or_equal_to: "必须小于或等于 %{count}"
+ odd: "必须为单数"
+ even: "必须为双数"
+ taken: "已经被使用"
+ record_invalid: "验证失败: %{errors}"
+ template: &errors_template
+ header:
+ one: "有 1 个错误发生导致「%{model}」无法被保存。"
+ other: "有 %{count} 个错误发生导致「%{model}」无法被保存。"
+ body: "如下字段出现错误:"
+
+ activerecord:
+ errors:
+ full_messages:
+ format: "%{attribute} %{message}"
+ messages:
+ <<: *errors_messages
+ template:
+ <<: *errors_template
+
+ helpers:
+ select:
+ prompt: "请选择"
+ submit:
+ create: "新增%{model}"
+ update: "更新%{model}"
+ submit: "储存%{model}"
View
148 config/locales/views.en.yml
@@ -0,0 +1,148 @@
+en:
+ games:
+ index:
+ welcome: Welcome
+ go_description: Go is a board game invented in China more than 4,000 years ago. It is more popular in the far East than Chess in the West. The rules are simple but mastering the game can take a lifetime.
+ try_a_game: We invite you to <a href="%{link}">try a game</a> against the computer or online with other players.
+
+ looking_for_games: Looking for games
+ 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
+ new_game: New Game
+ no_games: You do not have any games yet.
+ 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
+
+ profile:
+ as_white: as White
+ as_black: as Black
+ current_player: current player
+ komi: '%{count} komi'
+ handicap: '%{count} handicap'
+ captured_stone: '%{count} captured stone'
+ 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
148 config/locales/views.zh-cn.yml
@@ -0,0 +1,148 @@
+zh-cn:
+ games:
+ index:
+ welcome: 欢迎
+ go_description: 围棋起源于中国,有超过4000年的历史,在东方它比国际象棋更为流行。它的规则很简单,但是精通它可能需要一生的时间。
+ try_a_game: 我们邀请您和电脑或者其他玩家<a href="%{link}">玩一盘</a>。
+
+ looking_for_games: 和其他人玩一盘
+ 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
9 db/migrate/20111220092137_add_locale_to_users.rb
@@ -0,0 +1,9 @@
+class AddLocaleToUsers < ActiveRecord::Migration
+ def self.up
+ add_column :users, :locale, :string
+ end
+
+ def self.down
+ remove_column :users, :locale
+ end
+end
View
4 lib/controller_authentication.rb
@@ -48,15 +48,15 @@ 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
redirect_to signin_url
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
View
32 lib/controller_i18n.rb
@@ -0,0 +1,32 @@
+module ControllerI18n
+ def self.included(controller)
+ controller.send :before_filter, :set_locale
+ end
+
+ private
+ def set_locale
+ I18n.locale = cookies[:locale] || setup_cookies_locale
+ end
+
+ def change_locale
+ cookies[:locale] = current_user.locale if logged_in? && current_user.locale.present?
+ end
+
+ def setup_cookies_locale
+ if logged_in?
+ current_user.update_attribute(:locale, extract_locale_from_accept_language_header) if current_user.locale.blank?
+ cookies[:locale] = current_user.locale
+ else
+ cookies[:locale] = extract_locale_from_accept_language_header
+ end
+ end
+
+ def extract_locale_from_accept_language_header
+ if lang = request.accept_language
+ locale