diff --git a/.gitignore b/.gitignore index 2d88cb1..3d5e3da 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ config/database.yml config/private.yml config/initializers/development_mail.rb db/schema.rb -public/assets \ No newline at end of file +public/assets +/nbproject/* \ No newline at end of file diff --git a/Gemfile b/Gemfile index 76a68ee..43c5e44 100644 --- a/Gemfile +++ b/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' diff --git a/Gemfile.lock b/Gemfile.lock index 49c263c..cade88f 100644 --- a/Gemfile.lock +++ b/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 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4c7ed28..61a6976 100644 --- a/app/controllers/application_controller.rb +++ b/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? diff --git a/app/controllers/authentications_controller.rb b/app/controllers/authentications_controller.rb index 1276879..2251df4 100644 --- a/app/controllers/authentications_controller.rb +++ b/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 diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 8ee2154..47e970c 100644 --- a/app/controllers/games_controller.rb +++ b/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 diff --git a/app/controllers/moves_controller.rb b/app/controllers/moves_controller.rb index f08b1e3..8d7a11b 100644 --- a/app/controllers/moves_controller.rb +++ b/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 diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 2ac1e94..3baf5fa 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,4 +1,6 @@ class SessionsController < ApplicationController + after_filter :change_locale, :only => [:create] + def new end @@ -6,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 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 085eb14..74e9dda 100644 --- a/app/controllers/users_controller.rb +++ b/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 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 98f2f2d..caaef24 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -29,14 +29,14 @@ 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) @@ -44,11 +44,11 @@ def relative_date(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 diff --git a/app/helpers/games_helper.rb b/app/helpers/games_helper.rb index f5fc772..3be2cbf 100644 --- a/app/helpers/games_helper.rb +++ b/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 diff --git a/app/mailers/notifications.rb b/app/mailers/notifications.rb index 98a55ab..b3030a1 100644 --- a/app/mailers/notifications.rb +++ b/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 diff --git a/app/models/game.rb b/app/models/game.rb index e3672f3..fc31fad 100644 --- a/app/models/game.rb +++ b/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) diff --git a/app/models/user.rb b/app/models/user.rb index 312c58d..6f908c3 100644 --- a/app/models/user.rb +++ b/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 diff --git a/app/views/authentications/index.html.erb b/app/views/authentications/index.html.erb index 5949055..3bd1eea 100644 --- a/app/views/authentications/index.html.erb +++ b/app/views/authentications/index.html.erb @@ -1,9 +1,9 @@ -<% title "Sign In" %> +<% title t(".sign_in") %> <% stylesheet "authentication" %>
-

Sign in through one of the following services

+

<%= t(".sign_in_services") %>

<%= image_tag "auth/twitter_64.png", :size => "64x64", :alt => "Twitter" %> @@ -19,12 +19,12 @@
-

Don't use these services?
Just enter your email address:

+

<%= t(".not_services") %>
<%= t(".enter_email") %>

<%= form_tag new_user_path, :method => :get do %>

- <%= 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 %>

<% end %>
diff --git a/app/views/games/_form.html.erb b/app/views/games/_form.html.erb index 59d6785..7f439a6 100644 --- a/app/views/games/_form.html.erb +++ b/app/views/games/_form.html.erb @@ -3,22 +3,22 @@ <% if @game.new_record? %> <% if guest? %>

- Playing against computer (GNU Go).
- To play against others you must first <%= link_to "sign in", signin_path %>. + <%= t('.playing_against_computer') %>
+ <%= t('.sign_in', :url => signin_path).html_safe %>

<% else %>

- Play against:
- <%= f.radio_button :chosen_opponent, "gnugo" %> Computer (GNU Go)
- <%= f.radio_button :chosen_opponent, "user" %> Username: + <%= t('.play_against') %>
+ <%= f.radio_button :chosen_opponent, "gnugo" %> <%= t('.computer') %>
+ <%= f.radio_button :chosen_opponent, "user" %> <%= t('.username') %> <%= f.text_field :opponent_username %>

<% end %> <%= div_hidden_if @game.chosen_opponent == "user", :class => "auto_difficulty" do %>

<%= 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 %>

<% end %> <% else %> @@ -26,22 +26,22 @@ <%= f.hidden_field :opponent_username %> <% end %>

- <%= 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]] %>

<%= div_hidden_if @game.new_record? && @game.adjust_difficulty? && @game.chosen_opponent != "user", :class => "manual_difficulty" do %>

- <%= 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"]] %>

- <%= f.label :handicap %> + <%= f.label :handicap, t(".handicap") %> <%= f.select :handicap, [0, 2, 3, 4, 5, 6, 7, 8, 9] %>

- <%= f.label :komi %> + <%= f.label :komi, t(".komi") %> <%= f.select :komi, [0.5, 5.5, 6.5] %>

<% end %> -

<%= f.submit (@game.new_record? ? "Start Game" : "Update Game") %>

+

<%= f.submit (@game.new_record? ? t(".start_game") : t(".update_game")) %>

<% end %> diff --git a/app/views/games/_game.html.erb b/app/views/games/_game.html.erb index dda5964..3d4bb19 100644 --- a/app/views/games/_game.html.erb +++ b/app/views/games/_game.html.erb @@ -5,7 +5,7 @@
<%= link_to_user(profile.user) %> <%= online_status(profile.user) %>
<% end %> <% if game.last_move_at %> -
moved <%= time_ago_in_words(game.last_move_at) %> ago
+
<%= t('.moved_ago', :time => time_ago_in_words(game.last_move_at)) %>
<% end %>
<%= link_to "Go", game, :class => "go_button" %> diff --git a/app/views/games/_other_games.html.erb b/app/views/games/_other_games.html.erb index aa5e799..3512b3a 100644 --- a/app/views/games/_other_games.html.erb +++ b/app/views/games/_other_games.html.erb @@ -1,5 +1,5 @@
-

Watch a Game

+

<%= t(".watch_a_game") %>

<% @other_games.each_with_index do |game, index| %> <% unless index.zero? %>
diff --git a/app/views/games/_panel.html.erb b/app/views/games/_panel.html.erb index bff7431..411330e 100644 --- a/app/views/games/_panel.html.erb +++ b/app/views/games/_panel.html.erb @@ -1,39 +1,39 @@ <% if @game.finished? %>
<% if !@game.started? %> -

Game has been declined.

+

<%= t(".declined") %>

<% elsif current_user && @game.winner == current_user %> -

Congratulations, you won!

-

<%= link_to "Play Again", new_game_path(:board_size => @game.board_size) %>

+

<%= t(".won") %>

+

<%= link_to t(".play_again"), new_game_path(:board_size => @game.board_size) %>

<% elsif current_user && @game.loser == current_user %> -

Sorry, you lost.

-

Need some help? Check out the <%= link_to "Go Resources", go_resources_path %>.

-

<%= link_to "Play Again", new_game_path(:board_size => @game.board_size) %>

+

<%= t(".lost") %>

+

<%= t(".need_help", :url => go_resources_path).html_safe %>

+

<%= link_to t(".play_again"), new_game_path(:board_size => @game.board_size) %>

<% else %> -

<%= @game.winner ? (@game.winner.username || "Guest") : "GNU Go" %> won!

+

<%= t(".winner", :winner_name => @game.winner ? (@game.winner.username || t(".guest")) : t(".gnu_go")) %>

<% end %>
<% elsif @game.started? %>
-

Looks like the game has started, <%= link_to "reload", @game %> to play.

+

<%= t(".started", :url => game_path(@game)).html_safe %>

<% elsif @game.current_player == current_user %>
<%= form_for @game do |f| %> -

Challenge from <%= @game.opponent(current_user).username %>

-

Board Size: <%= @game.board_size %>

-

Playing as: <%= @game.white_player == current_user ? "White" : "Black" %>

-

Komi: <%= @game.komi %>

-

Handicap: <%= @game.handicap %>

-

Want to change something? <%= link_to "Edit Settings", edit_game_path(@game) %>

+

<%= t(".challenge_from", :username => @game.opponent(current_user).username) %>

+

<%= t(".board_size") %>: <%= @game.board_size %>

+

<%= t(".playing_as") %>: <%= @game.white_player == current_user ? "White" : "Black" %>

+

<%= t(".komi") %>: <%= @game.komi %>

+

<%= t(".handicap") %>: <%= @game.handicap %>

+

<%= t(".change_settings", :url => edit_game_path(@game)).html_safe %>

- <%= 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" %>

<% end %>
<% else %>
-

Waiting for opponent to accept game.

+

<%= t(".waiting") %>

<% end %> diff --git a/app/views/games/_profile.html.erb b/app/views/games/_profile.html.erb index 4307b34..e53934a 100644 --- a/app/views/games/_profile.html.erb +++ b/app/views/games/_profile.html.erb @@ -6,16 +6,16 @@ <%= avatar_image_tag(profile.user) %>
-
<%= link_to_user(profile.user) %> as <%= profile.color.to_s.titleize %> <%= online_status(profile.user) %>
- +
<%= link_to_user(profile.user) %> <%= t(".as_#{profile.color}") %> <%= online_status(profile.user) %>
+
<%= profile.last_status %>
-
<%= profile.handicap_or_komi %>
+
<%= t(".#{profile.handicap_or_komi.last}", :count => profile.handicap_or_komi.first) %>
<%= game_score profile.score, @game.finished? %>
<% if profile.user && profile.user == current_user %>
- <%= 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" %>
<% end %>
diff --git a/app/views/games/_side.html.erb b/app/views/games/_side.html.erb index 25441e9..6d96973 100644 --- a/app/views/games/_side.html.erb +++ b/app/views/games/_side.html.erb @@ -6,12 +6,12 @@ <% end %> <% if @game.player?(current_user) && @game.black_player.present? && @game.white_player.present? %>
-

Private Chat

+

<%= t('.private_chat') %>

<%= render @game.messages.order(:created_at) %>
<%= 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 %>
<% else %> diff --git a/app/views/games/_your_games.html.erb b/app/views/games/_your_games.html.erb index 7f3258b..3ae0597 100644 --- a/app/views/games/_your_games.html.erb +++ b/app/views/games/_your_games.html.erb @@ -1,13 +1,13 @@
-

Your Games <%= link_to "New Game", new_game_path(:board_size => 9) %>

+

<%= t '.your_games' %> <%= link_to t('.new_game'), new_game_path(:board_size => 9) %>

<% if @your_games.blank? %>
- You do not have any games yet.
- <%= 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" %>. + <%= t('.no_games') %>
+ <%= 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" %>
- <%= link_to image_tag("screencast.png", :size => "259x278", :alt => "Watch the Screencast"), "http://media.railscasts.com/videos/govsgo.mov", :class => "screencast" %> + <%= link_to image_tag("screencast.png", :size => "259x278", :alt => t('.watch_a_video_tour')), "http://media.railscasts.com/videos/govsgo.mov", :class => "screencast" %>
<% else %> <% @your_games.each_with_index do |game, index| %> diff --git a/app/views/games/index.html.erb b/app/views/games/index.html.erb index 456e3c5..ac12f31 100644 --- a/app/views/games/index.html.erb +++ b/app/views/games/index.html.erb @@ -4,9 +4,9 @@
-

Welcome

-

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.

-

We invite you to <%= link_to "try a game", new_game_path(:board_size => 9) %> against the computer or online with other players.

+

<%= t('.welcome') %>

+

<%= t('.go_description') %>

+

<%= t('.try_a_game', :link => new_game_path(:board_size => 9)).html_safe %>

@@ -22,7 +22,7 @@
-

Looking for Games

+

<%= t('.looking_for_games') %>

<% @users.each_with_index do |user, index| %> <% unless index.zero? %>
@@ -39,11 +39,11 @@ <% end %>
<% 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 %>
diff --git a/app/views/games/new.html.erb b/app/views/games/new.html.erb index 016ecea..4159429 100644 --- a/app/views/games/new.html.erb +++ b/app/views/games/new.html.erb @@ -1,4 +1,4 @@ -<% title "New Go Game" %> +<% title t(".new_go_game") %> <% stylesheet "game" %> <% @hide_footer = true %> diff --git a/app/views/games/show.html.erb b/app/views/games/show.html.erb index 8594209..fa13ddf 100644 --- a/app/views/games/show.html.erb +++ b/app/views/games/show.html.erb @@ -1,4 +1,4 @@ -<% title "Play Go" %> +<% title t(".play_go") %> <% stylesheet "game" %> <% @hide_footer = true %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index ddd3315..e540690 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -10,16 +10,16 @@ diff --git a/app/views/notifications/invitation.text.erb b/app/views/notifications/invitation.en.text.erb similarity index 100% rename from app/views/notifications/invitation.text.erb rename to app/views/notifications/invitation.en.text.erb diff --git a/app/views/notifications/invitation.zh-cn.text.erb b/app/views/notifications/invitation.zh-cn.text.erb new file mode 100644 index 0000000..8379f8c --- /dev/null +++ b/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) %> + diff --git a/app/views/notifications/message.text.erb b/app/views/notifications/message.en.text.erb similarity index 100% rename from app/views/notifications/message.text.erb rename to app/views/notifications/message.en.text.erb diff --git a/app/views/notifications/message.zh-cn.text.erb b/app/views/notifications/message.zh-cn.text.erb new file mode 100644 index 0000000..b1f2f7e --- /dev/null +++ b/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) %> + diff --git a/app/views/notifications/move.text.erb b/app/views/notifications/move.en.text.erb similarity index 100% rename from app/views/notifications/move.text.erb rename to app/views/notifications/move.en.text.erb diff --git a/app/views/notifications/move.zh-cn.text.erb b/app/views/notifications/move.zh-cn.text.erb new file mode 100644 index 0000000..801985a --- /dev/null +++ b/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) %> + diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index 637f1fd..9200147 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -1,20 +1,20 @@ -<% title "Log In" %> +<% title t(".log_in") %> <% stylesheet "authentication" %>
-

Log In

-

Don't have an account? <%= link_to "Sign up!", signup_path %>

+

<%= t(".log_in") %>

+

<%= t(".no_account") %> <%= link_to t(".sign_up"), signup_path %>

<%= form_tag sessions_path do %>

- <%= label_tag :login, "Username or Email" %> + <%= label_tag :login, t(".label_login") %> <%= text_field_tag :login, params[:login] || params[:email] %>

<%= label_tag :password %> <%= password_field_tag :password %>

-

<%= submit_tag "Log in" %>

+

<%= submit_tag t(".log_in") %>

<% end %>
\ No newline at end of file diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb index be29424..7776dfd 100644 --- a/app/views/users/_form.html.erb +++ b/app/views/users/_form.html.erb @@ -1,44 +1,48 @@ <%= form_for @user do |f| %> <%= f.error_messages %>

- <%= f.label :username %> + <%= f.label :username, t(".username") %> <%= f.text_field :username %>

- <%= f.label :email, "Email Address" %> + <%= f.label :email, t(".email") %> <%= f.text_field :email %>

<% unless session[:omniauth] %>

- <%= f.label :password %> + <%= f.label :password, t(".password") %> <%= f.password_field :password %>

- <%= f.label :password_confirmation, "Confirm Password" %> + <%= f.label :password_confirmation, t(".password_confirmation") %> <%= f.password_field :password_confirmation %>

<% end %>

- <%= f.label :rank %> + <%= f.label :rank, t(".rank") %> <%= f.text_field :rank, :size => 10 %> - such as "4k"
- leave blank if unknown + <%= t(".rank_hint") %>
+ <%= t(".rank_blank") %>

- <%= f.label :time_zone, "Time Zone" %> + <%= f.label :time_zone, t(".time_zone") %> <%= f.time_zone_select :time_zone, nil, :include_blank => true %>

+

+ <%= f.label :locale, t('.locale') %> + <%= f.select :locale, [['English', 'en'], ['简体中文', 'zh-cn']] %> +

<%= 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" %>

<%= 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" %>

<%= 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" %>

-

<%= f.submit (@user.new_record? ? "Sign up" : "Update") %>

+

<%= f.submit (@user.new_record? ? t(".sign_up") : t(".update")) %>

<% end %> diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 0bbcdfb..c5a89d0 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -1,28 +1,28 @@ -<% title "Update Profile" %> +<% title t(".update_profile") %> <% stylesheet "authentication" %>
-

Update Profile

+

<%= t(".update_profile") %>

<%= render 'form' %>
-

Sign In Options

+

<%= t(".sign_in_options") %>

<% unless current_user.authentications.empty? %> -

You have signed in with these services:

+

<%= t(".authentication_services") %>

<% for authentication in current_user.authentications %>
<%= image_tag "auth/#{authentication.provider}_32.png", :size => "32x32" %>
<%= authentication.provider_name %>
<%= authentication.uid %>
- <%= 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" %>
<% end %>
<% end %> -

Add another service to sign in with:

+

<%= t(".add_authentication_service") %>

<%= image_tag "auth/twitter_64.png", :size => "64x64", :alt => "Twitter" %> diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index c9c135d..472cc60 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -1,10 +1,10 @@ -<% title "Sign Up" %> +<% title t(".sign_up") %> <% stylesheet "authentication" %>
-

Sign Up

-

Already have an account? <%= link_to "Log in", login_path %>.

+

<%= t(".sign_up") %>

+

<%= t(".already_have_an_account") %> <%= link_to t(".log_in"), login_path %>.

<%= render 'form' %>
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 9de8655..22d7601 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -8,34 +8,34 @@

- Currently: <%= @user.online? ? "Online" : "Offline" %> + <%= t(".currently") %>: <%= @user.online? ? t(".online") : t(".offline") %>

<% if @user.rank.present? %>

- Go Rank: <%= @user.rank %> + <%= t(".rank") %>: <%= @user.rank %>

<% end %>

- GNU Go Auto-level: + <%= t(".gnugo_level") %>: <%= @user.gnugo_level %>

- Games with GNU Go: + <%= t(".games_with_gnugo") %>: <%= @user.games.with_gnugo.size %>

- Games with Others: + <%= t(".games_with_others") %>: <%= @user.games.without_gnugo.size %>

<% if @user == current_user %> -

<%= link_to "Edit Profile", edit_current_user_path %> or <%= link_to "Log Out", logout_path %>

+

<%= link_to t(".edit_profile"), edit_current_user_path %> <%= t(".or") %> <%= link_to t(".log_out"), logout_path %>

<% 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 %>
-

<%= @user.username %>'s Games

+

<%= t(".his_games", :username => @user.username) %>

<% @games.each_with_index do |game, index| %> <% unless index.zero? %>
diff --git a/config/application.rb b/config/application.rb index fe46ccb..152a436 100644 --- a/config/application.rb +++ b/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) diff --git a/config/locales/controllers.en.yml b/config/locales/controllers.en.yml new file mode 100644 index 0000000..69dc2a6 --- /dev/null +++ b/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. + \ No newline at end of file diff --git a/config/locales/controllers.zh-cn.yml b/config/locales/controllers.zh-cn.yml new file mode 100644 index 0000000..a899a08 --- /dev/null +++ b/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: 你已经被添加到 寻找棋友 列表。 + \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml deleted file mode 100644 index a747bfa..0000000 --- a/config/locales/en.yml +++ /dev/null @@ -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" diff --git a/config/locales/helpers.en.yml b/config/locales/helpers.en.yml new file mode 100644 index 0000000..98829b4 --- /dev/null +++ b/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' \ No newline at end of file diff --git a/config/locales/helpers.zh-cn.yml b/config/locales/helpers.zh-cn.yml new file mode 100644 index 0000000..6e00b3a --- /dev/null +++ b/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} 吃子' \ No newline at end of file diff --git a/config/locales/layouts.en.yml b/config/locales/layouts.en.yml new file mode 100644 index 0000000..a18bb8c --- /dev/null +++ b/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 diff --git a/config/locales/layouts.zh-cn.yml b/config/locales/layouts.zh-cn.yml new file mode 100644 index 0000000..e610c98 --- /dev/null +++ b/config/locales/layouts.zh-cn.yml @@ -0,0 +1,8 @@ +zh-cn: + layouts: + application: + home: 首页 + play_a_game: 玩一盘 + go_resources: 围棋资源 + sign_in: 登录 + your_profile: 个人资料 diff --git a/config/locales/rails.zh-cn.yml b/config/locales/rails.zh-cn.yml new file mode 100644 index 0000000..f6b7fc6 --- /dev/null +++ b/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}" diff --git a/config/locales/views.en.yml b/config/locales/views.en.yml new file mode 100644 index 0000000..0bbcdab --- /dev/null +++ b/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
try a game 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 sign in. + + 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 Go Resources. + guest: Guest + winner: '%{winner_name} won!' + gnu_go: GNU Go + started: Looks like the game has started, reload 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? Edit Settings + 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 sign in. + 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}' \ No newline at end of file diff --git a/config/locales/views.zh-cn.yml b/config/locales/views.zh-cn.yml new file mode 100644 index 0000000..3511378 --- /dev/null +++ b/config/locales/views.zh-cn.yml @@ -0,0 +1,148 @@ +zh-cn: + games: + index: + welcome: 欢迎 + go_description: 围棋起源于中国,有超过4000年的历史,在东方它比国际象棋更为流行。它的规则很简单,但是精通它可能需要一生的时间。 + try_a_game: 我们邀请您和电脑或者其他玩家玩一盘。 + + looking_for_games: 和其他人玩一盘 + remove_yourself_from_list: 将我从列表中移除 + add_yourself_to_list: 将我加入到列表 + guest_add_to_list: 您需要先登录,就可以加入到这个列表。 + + new: + new_go_game: 新的一盘 + + show: + play_go: 下围棋 + + panel: + declined: 这盘棋被拒绝了 + won: 祝贺你,你赢了! + play_again: 再来一盘 + lost: 很遗憾,你输了。 + need_help: 需要帮助? 看看相关的 围棋资源吧。 + guest: 访客 + winner: '%{winner_name} 赢了!' + gnu_go: GNU Go + started: 游戏已经开始,刷新一下 开始下棋。 + challenge_from: 来自 %{username} 的挑战 + board_size: 棋盘大小 + playing_as: 作为 + komi: 贴目 + handicap: 让子 + change_settings: 想改一下? 编辑设置 + 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: 你必须先 登录 才能和其他人下棋。 + 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} 的聊天' \ No newline at end of file diff --git a/db/migrate/20111220092137_add_locale_to_users.rb b/db/migrate/20111220092137_add_locale_to_users.rb new file mode 100644 index 0000000..d433eaf --- /dev/null +++ b/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 diff --git a/lib/controller_authentication.rb b/lib/controller_authentication.rb index 0a10cd5..59998da 100644 --- a/lib/controller_authentication.rb +++ b/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 diff --git a/lib/controller_i18n.rb b/lib/controller_i18n.rb new file mode 100644 index 0000000..a7db2ce --- /dev/null +++ b/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 = lang.split(",").first.downcase.to_sym + else + locale = nil + end + I18n.available_locales.include?(locale) ? locale : I18n.default_locale + end +end diff --git a/spec/models/game_spec.rb b/spec/models/game_spec.rb index e824bce..d6554fc 100644 --- a/spec/models/game_spec.rb +++ b/spec/models/game_spec.rb @@ -68,7 +68,7 @@ user = Factory(:user) game = Factory(:game, :current_player => user, :black_player => user, :handicap => 4, :black_score => 3) profile = game.profile_for(:black) - profile.handicap_or_komi.should == "4 handicap" + profile.handicap_or_komi.should == [4, "handicap"] profile.score.should == 3 profile.user.should == user profile.current.should be_true @@ -78,7 +78,7 @@ it "should generate profile for white as GNU Go" do game = Factory(:game, :komi => 6.5, :white_player_id => nil, :white_score => 4, :current_player_id => Factory(:user).id, :moves => "PASS") profile = game.profile_for(:white) - profile.handicap_or_komi.should == "6.5 komi" + profile.handicap_or_komi.should == [6.5, "komi"] profile.score.should == 4 profile.captured.should == 4 profile.user.should be_nil