Permalink
Browse files

complete i18n feature and upgrade to rails 3.0.11

  • Loading branch information...
1 parent 620720e commit 04f375e07786785b9bfc3cc5d0a56e62872d05b7 @quake committed Dec 30, 2011
Showing with 526 additions and 144 deletions.
  1. +2 −1 .gitignore
  2. +1 −1 Gemfile
  3. +46 −41 Gemfile.lock
  4. +4 −4 app/controllers/authentications_controller.rb
  5. +2 −2 app/controllers/games_controller.rb
  6. +2 −2 app/controllers/moves_controller.rb
  7. +3 −3 app/controllers/sessions_controller.rb
  8. +7 −7 app/controllers/users_controller.rb
  9. +3 −3 app/helpers/application_helper.rb
  10. +3 −3 app/helpers/games_helper.rb
  11. +6 −3 app/mailers/notifications.rb
  12. +5 −5 app/views/authentications/index.html.erb
  13. +13 −13 app/views/games/_form.html.erb
  14. +1 −1 app/views/games/_other_games.html.erb
  15. +17 −17 app/views/games/_panel.html.erb
  16. +1 −1 app/views/games/new.html.erb
  17. +1 −1 app/views/games/show.html.erb
  18. 0 app/views/notifications/{invitation.text.erb → invitation.en.text.erb}
  19. +14 −0 app/views/notifications/invitation.zh-cn.text.erb
  20. 0 app/views/notifications/{message.text.erb → message.en.text.erb}
  21. +14 −0 app/views/notifications/message.zh-cn.text.erb
  22. 0 app/views/notifications/{move.text.erb → move.en.text.erb}
  23. +14 −0 app/views/notifications/move.zh-cn.text.erb
  24. +5 −5 app/views/sessions/new.html.erb
  25. +12 −12 app/views/users/_form.html.erb
  26. +6 −6 app/views/users/edit.html.erb
  27. +3 −3 app/views/users/new.html.erb
  28. +8 −8 app/views/users/show.html.erb
  29. +31 −0 config/locales/controllers.en.yml
  30. +31 −0 config/locales/controllers.zh-cn.yml
  31. +14 −0 config/locales/helpers.en.yml
  32. +14 −0 config/locales/helpers.zh-cn.yml
  33. +108 −0 config/locales/views.en.yml
  34. +133 −0 config/locales/views.zh-cn.yml
  35. +2 −2 lib/controller_authentication.rb
View
@@ -6,4 +6,5 @@ config/database.yml
config/private.yml
config/initializers/development_mail.rb
db/schema.rb
-public/assets
+public/assets
+/nbproject/*
View
@@ -1,6 +1,6 @@
source 'http://rubygems.org'
-gem 'rails', '3.0.3'
+gem 'rails', '3.0.11'
gem 'mysql2'
gem 'omniauth'
gem 'jquery-rails'
View
@@ -16,34 +16,34 @@ GEM
ZenTest (4.4.0)
aaronh-chronic (0.3.9)
abstract (1.0.0)
- actionmailer (3.0.3)
- actionpack (= 3.0.3)
- mail (~> 2.2.9)
- actionpack (3.0.3)
- activemodel (= 3.0.3)
- activesupport (= 3.0.3)
+ actionmailer (3.0.11)
+ actionpack (= 3.0.11)
+ mail (~> 2.2.19)
+ actionpack (3.0.11)
+ activemodel (= 3.0.11)
+ activesupport (= 3.0.11)
builder (~> 2.1.2)
erubis (~> 2.6.6)
- i18n (~> 0.4)
+ i18n (~> 0.5.0)
rack (~> 1.2.1)
- rack-mount (~> 0.6.13)
- rack-test (~> 0.5.6)
+ rack-mount (~> 0.6.14)
+ rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
- activemodel (3.0.3)
- activesupport (= 3.0.3)
+ activemodel (3.0.11)
+ activesupport (= 3.0.11)
builder (~> 2.1.2)
- i18n (~> 0.4)
- activerecord (3.0.3)
- activemodel (= 3.0.3)
- activesupport (= 3.0.3)
- arel (~> 2.0.2)
+ i18n (~> 0.5.0)
+ activerecord (3.0.11)
+ activemodel (= 3.0.11)
+ activesupport (= 3.0.11)
+ arel (~> 2.0.10)
tzinfo (~> 0.3.23)
- activeresource (3.0.3)
- activemodel (= 3.0.3)
- activesupport (= 3.0.3)
- activesupport (3.0.3)
+ activeresource (3.0.11)
+ activemodel (= 3.0.11)
+ activesupport (= 3.0.11)
+ activesupport (3.0.11)
addressable (2.2.2)
- arel (2.0.6)
+ arel (2.0.10)
autotest (4.4.1)
autotest-rails (4.1.0)
ZenTest
@@ -79,16 +79,17 @@ GEM
i18n (0.5.0)
jquery-rails (0.2.4)
rails (~> 3.0)
+ json (1.6.4)
json_pure (1.4.6)
launchy (0.3.7)
configuration (>= 0.0.5)
rake (>= 0.8.1)
- mail (2.2.12)
+ mail (2.2.19)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
- mime-types (1.16)
+ mime-types (1.17.2)
mocha (0.9.9)
rake
mongrel (1.2.0.pre2)
@@ -143,30 +144,33 @@ GEM
oa-openid (= 0.1.5)
open_gem (1.4.2)
launchy (~> 0.3.5)
- polyglot (0.3.1)
+ polyglot (0.3.3)
pyu-ruby-sasl (0.0.3.2)
- rack (1.2.1)
- rack-mount (0.6.13)
+ rack (1.2.5)
+ rack-mount (0.6.14)
rack (>= 1.0.0)
rack-openid (1.1.2)
rack (>= 0.4)
ruby-openid (>= 2.0.3)
- rack-test (0.5.6)
+ rack-test (0.5.7)
rack (>= 1.0)
- rails (3.0.3)
- actionmailer (= 3.0.3)
- actionpack (= 3.0.3)
- activerecord (= 3.0.3)
- activeresource (= 3.0.3)
- activesupport (= 3.0.3)
+ rails (3.0.11)
+ actionmailer (= 3.0.11)
+ actionpack (= 3.0.11)
+ activerecord (= 3.0.11)
+ activeresource (= 3.0.11)
+ activesupport (= 3.0.11)
bundler (~> 1.0)
- railties (= 3.0.3)
- railties (3.0.3)
- actionpack (= 3.0.3)
- activesupport (= 3.0.3)
+ railties (= 3.0.11)
+ railties (3.0.11)
+ actionpack (= 3.0.11)
+ activesupport (= 3.0.11)
rake (>= 0.8.7)
+ rdoc (~> 3.4)
thor (~> 0.14.4)
- rake (0.8.7)
+ rake (0.9.2.2)
+ rdoc (3.12)
+ json (~> 1.4)
rest-client (1.6.1)
mime-types (>= 1.16)
rspec (2.0.1)
@@ -189,9 +193,10 @@ GEM
beanstalk-client
json_pure
thor (0.14.6)
- treetop (1.4.9)
+ treetop (1.4.10)
+ polyglot
polyglot (>= 0.3.1)
- tzinfo (0.3.23)
+ tzinfo (0.3.31)
whenever (0.6.2)
aaronh-chronic (>= 0.3.9)
activesupport (>= 2.3.4)
@@ -217,7 +222,7 @@ DEPENDENCIES
nifty-generators
oily_png (= 0.1.0)
omniauth
- rails (= 3.0.3)
+ rails (= 3.0.11)
rspec-rails (>= 2.0.1)
stalker (= 0.5.0)
whenever
@@ -12,7 +12,7 @@ def create
authentication.user.apply_omniauth(omniauth)
authentication.user.save!
remember_user(authentication.user)
- flash[:notice] = "Signed in as #{authentication.user.username}"
+ flash[:notice] = t("signed_in_as", :username => authentication.user.username, :scope => "controllers.authentications")
redirect_to_target_or_default root_url
else
user = current_user_or_guest
@@ -22,11 +22,11 @@ def create
user.guest = false
if user.save
if was_guest
- flash[:notice] = "Signed in as #{user.username}."
+ flash[:notice] = t("signed_in_as", :username => user.username, :scope => "controllers.authentications")
remember_user(user)
redirect_to_target_or_default root_url
else
- flash[:notice] = "Authentication successful."
+ flash[:notice] = t("create", :scope => "controllers.authentications")
redirect_to edit_current_user_url
end
else
@@ -39,7 +39,7 @@ def create
def destroy
@authentication = current_user.authentications.find(params[:id])
@authentication.destroy
- flash[:notice] = "Successfully destroyed authentication."
+ flash[:notice] = t("destroy", :scope => "controllers.authentications")
redirect_to edit_current_user_path
end
end
@@ -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
@@ -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
@@ -8,17 +8,17 @@ def create
user = User.authenticate(params[:login], params[:password])
if user
remember_user(user)
- flash[:notice] = "Logged in successfully."
+ flash[:notice] = t("create_success", :scope => "controllers.sessions")
redirect_to_target_or_default("/")
else
- flash.now[:alert] = "Invalid login or password."
+ flash.now[:alert] = t("create_fail", :scope => "controllers.sessions")
render :action => 'new'
end
end
def destroy
forget_user
- flash[:notice] = "You have been logged out."
+ flash[:notice] = t("destroy", :scope => "controllers.sessions")
redirect_to root_url
end
end
@@ -10,10 +10,10 @@ def show
def new
if params[:email]
if logged_in?
- flash[:notice] = "Please update your profile below."
+ flash[:notice] = t("new_update", :scope => "controllers.users")
redirect_to edit_current_user_url(:email => params[:email])
elsif User.find_by_email(params[:email])
- flash[:notice] = "It appears you already have an account, please login below."
+ flash[:notice] = t("new_login", :scope => "controllers.users")
redirect_to login_url(:login => params[:email])
end
end
@@ -24,7 +24,7 @@ def create
@user = User.new(params[:user])
if @user.save
remember_user(@user)
- flash[:notice] = "Thank you for signing up! You are now logged in."
+ flash[:notice] = t("create", :scope => "controllers.users")
redirect_to root_url
else
render :action => 'new'
@@ -48,7 +48,7 @@ def update
@user.guest = false
if @user.save
session[:omniauth] = nil
- flash[:notice] = "Your profile has been updated."
+ flash[:notice] = t("update", :scope => "controllers.users")
redirect_to root_url
else
render :action => 'edit'
@@ -58,17 +58,17 @@ def update
def unsubscribe
@user = User.find_by_unsubscribe_token!(params[:token])
@user.update_attributes!(:email_on_invitation => false, :email_on_move => false, :email_on_message => false)
- flash[:notice] = "You have been unsubscribed from further email notifications."
+ flash[:notice] = t("unsubscribe", :scope => "controllers.users")
redirect_to root_url
end
def publicize
if guest?
- redirect_to signin_url, :alert => "You must first sign in to be added to the Looking for Games list."
+ redirect_to signin_url, :alert => t("publicize_guest", :scope => "controllers.users")
else
@user = current_user
@user.update_attribute(:publicized_at, (params[:remove] ? nil : Time.now))
- redirect_to root_url, :notice => "You have been #{params[:remove] ? 'removed from' : 'added to'} the Looking for Games list."
+ redirect_to root_url, :notice => t(params[:remove] ? "publicize_remove" : "publicize_add", :scope => "controllers.users")
end
end
end
@@ -29,9 +29,9 @@ def avatar_url(user)
def link_to_user(user)
if user
- user.guest? ? "Guest" : link_to(user.name_with_rank, user, :class => "subtle")
+ user.guest? ? t("guest", :scope => "helpers.application") : link_to(user.name_with_rank, user, :class => "subtle")
else
- "GNU Go"
+ t("gnu_go", :scope => "helpers.application")
end
end
@@ -44,7 +44,7 @@ def relative_date(date)
if date == today
nil
elsif date == today-1
- t('.yesterday')
+ t("yesterday", :scope => "helpers.application")
elsif date.year == today.year
l(date, :format => "%b %d")
else
@@ -22,12 +22,12 @@ def link_to_game_thumbnail(game)
def game_score(score, finished)
if finished
if score.to_f == 1.0
- t(".won")
+ t("won", :scope => "helpers.games")
elsif score.to_f > 0
- t(".won_by", :score => score)
+ t("won_by", :score => score, :scope => "helpers.games")
end
else
- t(".captured_stone", :count => score.to_i)
+ t("captured_stone", :count => score.to_i, :scope => "helpers.games")
end
end
@@ -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
@@ -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>
Oops, something went wrong.

0 comments on commit 04f375e

Please sign in to comment.