]> git.openstreetmap.org Git - rails.git/commitdiff
Some more of the user account translations. Custom generate method for languages...
authorShaun McDonald <shaun@shaunmcdonald.me.uk>
Sat, 30 May 2009 14:04:42 +0000 (14:04 +0000)
committerShaun McDonald <shaun@shaunmcdonald.me.uk>
Sat, 30 May 2009 14:04:42 +0000 (14:04 +0000)
app/controllers/diary_entry_controller.rb
app/controllers/user_controller.rb
app/models/language.rb
app/views/user/account.rhtml
app/views/user/confirm.rhtml
app/views/user/confirm_email.rhtml
config/locales/en.yml

index 9bbadb29dfbee1f48409e7bbe5cf1b08359fa87e..9ce5409d6a6da5818d11d5a085fb08ae87bc5aa9 100644 (file)
@@ -13,6 +13,8 @@ class DiaryEntryController < ApplicationController
     if params[:diary_entry]     
       @diary_entry = DiaryEntry.new(params[:diary_entry])
       @diary_entry.user = @user
     if params[:diary_entry]     
       @diary_entry = DiaryEntry.new(params[:diary_entry])
       @diary_entry.user = @user
+      @diary_entry.language = Language.find_by_code(params[:language])
+      @diary_entry.language = Language.find_by_code("en") if @diary_entry.language.nil?
 
       if @diary_entry.save 
         redirect_to :controller => 'diary_entry', :action => 'list', :display_name => @user.display_name 
 
       if @diary_entry.save 
         redirect_to :controller => 'diary_entry', :action => 'list', :display_name => @user.display_name 
@@ -31,6 +33,8 @@ class DiaryEntryController < ApplicationController
     if @user != @diary_entry.user
       redirect_to :controller => 'diary_entry', :action => 'view', :id => params[:id]
     elsif params[:diary_entry]
     if @user != @diary_entry.user
       redirect_to :controller => 'diary_entry', :action => 'view', :id => params[:id]
     elsif params[:diary_entry]
+      params[:diary_entry][:language] = Language.find_by_code(params[:diary_entry][:language])
+      params[:diary_entry][:language] = Language.find_by_code("en") if params[:diary_entry][:language].nil?
       if @diary_entry.update_attributes(params[:diary_entry])
         redirect_to :controller => 'diary_entry', :action => 'view', :id => params[:id]
       end
       if @diary_entry.update_attributes(params[:diary_entry])
         redirect_to :controller => 'diary_entry', :action => 'view', :id => params[:id]
       end
index 36516f60f05698c93bb32d00a374cc3440ab3f5b..0b2ec168a061e2cb97de9cb08e8798442b9f6352 100644 (file)
@@ -23,9 +23,11 @@ class UserController < ApplicationController
       @user.data_public = true
       @user.description = "" if @user.description.nil?
       @user.creation_ip = request.remote_ip
       @user.data_public = true
       @user.description = "" if @user.description.nil?
       @user.creation_ip = request.remote_ip
+      @user.locale = Language.find_by_code(I18n.locale.to_s)
+      @user.locale = Language.find_by_code("en") if @user.locale.nil?
 
       if @user.save
 
       if @user.save
-        flash[:notice] = "User was successfully created. Check your email for a confirmation note, and you\'ll be mapping in no time :-)<br /><br />Please note that you won't be able to login until you've received and confirmed your email address.<br /><br />If you use an antispam system which sends confirmation requests then please make sure you whitelist webmaster@openstreetmap.org as we are unable to reply to any confirmation requests."
+        flash[:notice] = I18n.t('user.new.create success message')
         Notifier.deliver_signup_confirm(@user, @user.tokens.create)
         redirect_to :action => 'login'
       else
         Notifier.deliver_signup_confirm(@user, @user.tokens.create)
         redirect_to :action => 'login'
       else
@@ -54,10 +56,10 @@ class UserController < ApplicationController
 
       if @user.save
         if params[:user][:email] == @user.new_email
 
       if @user.save
         if params[:user][:email] == @user.new_email
-          @notice = "User information updated successfully. Check your email for a note to confirm your new email address."
+          flash[:notice] = I18n.t('user.account.flash update success confirm needed')
           Notifier.deliver_email_confirm(@user, @user.tokens.create)
         else
           Notifier.deliver_email_confirm(@user, @user.tokens.create)
         else
-          @notice = "User information updated successfully."
+          flash[:notice] = I18n.t('user.account.flash update success')
         end
       end
     end
         end
       end
     end
@@ -68,7 +70,7 @@ class UserController < ApplicationController
       @user.home_lat = params[:user][:home_lat].to_f
       @user.home_lon = params[:user][:home_lon].to_f
       if @user.save
       @user.home_lat = params[:user][:home_lat].to_f
       @user.home_lon = params[:user][:home_lon].to_f
       if @user.save
-        flash[:notice] = "Home location saved successfully."
+        flash[:notice] = I18n.t('user.set_home.flash success')
         redirect_to :controller => 'user', :action => 'account'
       end
     end
         redirect_to :controller => 'user', :action => 'account'
       end
     end
@@ -77,27 +79,27 @@ class UserController < ApplicationController
   def go_public
     @user.data_public = true
     @user.save
   def go_public
     @user.data_public = true
     @user.save
-    flash[:notice] = 'All your edits are now public.'
+    flash[:notice] = I18n.t('user.go_public.flash success')
     redirect_to :controller => 'user', :action => 'account', :display_name => @user.display_name
   end
 
   def lost_password
     redirect_to :controller => 'user', :action => 'account', :display_name => @user.display_name
   end
 
   def lost_password
-    @title = 'lost password'
+    @title = I18n.t('user.lost_password.title')
     if params[:user] and params[:user][:email]
       user = User.find_by_email(params[:user][:email], :conditions => {:visible => true})
 
       if user
         token = user.tokens.create
         Notifier.deliver_lost_password(user, token)
     if params[:user] and params[:user][:email]
       user = User.find_by_email(params[:user][:email], :conditions => {:visible => true})
 
       if user
         token = user.tokens.create
         Notifier.deliver_lost_password(user, token)
-        @notice = "Sorry you lost it :-( but an email is on its way so you can reset it soon."
+        flash[:notice] = I18n.t('user.lost_password.notice.email on way')
       else
       else
-        @notice = "Couldn't find that email address, sorry."
+        flash[:notice] = I18n.t('user.lost_password.notice email cannot find')
       end
     end
   end
 
   def reset_password
       end
     end
   end
 
   def reset_password
-    @title = 'reset password'
+    @title = I18n.t('user.reset_password.title')
     if params['token']
       token = UserToken.find_by_token(params[:token])
       if token
     if params['token']
       token = UserToken.find_by_token(params[:token])
       if token
@@ -110,9 +112,9 @@ class UserController < ApplicationController
         user.save!
         token.destroy
         Notifier.deliver_reset_password(user, pass)
         user.save!
         token.destroy
         Notifier.deliver_reset_password(user, pass)
-        flash[:notice] = "Your password has been changed and is on its way to your mailbox :-)"
+        flash[:notice] = I18n.t('user.reset_password.flash changed check mail')
       else
       else
-        flash[:notice] = "Didn't find that token, check the URL maybe?"
+        flash[:notice] = I18n.t('user.reset_password.flash token bad')
       end
     end
 
       end
     end
 
index 8965cf4532a141b2a514f53a729df2f2d6ad8303..150341cc70f50fe2e5f8398bd25cb53ba6d5f64d 100644 (file)
@@ -3,4 +3,12 @@ class Language < ActiveRecord::Base
 
   has_many :users, :foreign_key => 'locale'
   has_many :diary_entries, :foreign_key => 'language'
 
   has_many :users, :foreign_key => 'locale'
   has_many :diary_entries, :foreign_key => 'language'
+  
+  def self.generate(code, name, translation_available)
+    Language.create do |l|
+      l.code = code
+      l.name = name
+      l.translation_available = translation_available
+    end
+  end
 end
 end
index 1dd4bdca0dea067f7a477ce54e4a3d4f8a9c3951..40e8fe01a913a4d929fb0f79129628113208f4ba 100644 (file)
@@ -1,33 +1,33 @@
-<h2>My settings</h2>
+<h2><%= t 'user.account.my settings' %></h2>
 <%= error_messages_for 'user' %>
 <% form_for :user, @user do |f| %>
 <table id="accountForm">
 <%= error_messages_for 'user' %>
 <% form_for :user, @user do |f| %>
 <table id="accountForm">
-  <tr><td class="fieldName">Display Name : </td><td><%= f.text_field :display_name %></td></tr>
-  <tr><td class="fieldName">Email : </td><td><%= f.text_field :email, {:size => 50, :maxlength => 255} %> <span class="minorNote">(never displayed publicly)</span></td></tr>
-  <tr><td class="fieldName" style="padding-bottom:0px;">Password : </td><td style="padding-bottom:0px;"><%= f.password_field :pass_crypt, {:value => '', :size => 30, :maxlength => 255} %></td></tr>
-  <tr><td class="fieldName">Confirm Password : </td><td><%= f.password_field :pass_crypt_confirmation, {:value => '', :size => 30, :maxlength => 255} %></td></tr>
+  <tr><td class="fieldName"><%= t 'user.new.display name' %></td><td><%= f.text_field :display_name %></td></tr>
+  <tr><td class="fieldName"><%= t 'user.new.email address' %></td><td><%= f.text_field :email, {:size => 50, :maxlength => 255} %> <span class="minorNote"><%= t 'user.account.email never displayed publicly' %></span></td></tr>
+  <tr><td class="fieldName" style="padding-bottom:0px;"><%= t 'user.new.password' %></td><td style="padding-bottom:0px;"><%= f.password_field :pass_crypt, {:value => '', :size => 30, :maxlength => 255} %></td></tr>
+  <tr><td class="fieldName"><%= t 'user.new.confirm password' %></td><td><%= f.password_field :pass_crypt_confirmation, {:value => '', :size => 30, :maxlength => 255} %></td></tr>
 
   <tr>
 
   <tr>
-  <td class="fieldName" valign="top">Public editing :</td>
+  <td class="fieldName" valign="top"><%= t 'user.account.public editing.heading' %></td>
   <td>
 <% if @user.data_public? %>
   <td>
 <% if @user.data_public? %>
-  Enabled. Not anonymous <span class="minorNote">(<a href="http://wiki.openstreetmap.org/index.php/Disabling_anonymous_edits" target="_new">what's this?</a>)</span>
+  <%= t 'user.account.public editing.enabled' %> <span class="minorNote">(<a href="<%= t 'user.account.public editing.enabled link' %>" target="_new"><%= t 'user.account.public editing.enabled link text' %></a>)</span>
 <% else %>
 <% else %>
-  Disabled and anonymous. <span class="minorNote">(<a href="#public">why's this bad?</a>)</span>
+  <%= t 'user.account.public editing.disabled' %><span class="minorNote">(<a href="#public"><%= t 'user.account.public editing.disabled link text' %></a>)</span>
 <% end %>
   </td>
   </tr>
 
 <% end %>
   </td>
   </tr>
 
-  <tr><td class="fieldName" valign="top">Profile Description : </td><td><%= f.text_area :description, :rows => '5', :cols => '60' %><br /><br /></td></tr>
+  <tr><td class="fieldName" valign="top"><%= t 'user.account.profile description' %></td><td><%= f.text_area :description, :rows => '5', :cols => '60' %><br /><br /></td></tr>
 
 
-  <tr id="homerow" <% unless @user.home_lat and @user.home_lon %> class="nohome" <%end%> ><td class="fieldName">Home Location : </td><td><em class="message">You have not entered your home location.</em><span class="location">Latitude: <%= f.text_field :home_lat, :size => 20, :id => "home_lat" %> Longitude <%= f.text_field :home_lon, :size => 20, :id => "home_lon" %></span></td></tr>
+  <tr id="homerow" <% unless @user.home_lat and @user.home_lon %> class="nohome" <%end%> ><td class="fieldName"><%= t 'user.account.home location' %></td><td><em class="message"><%= t 'user.account.no home location' %></em><span class="location"><%= t 'user.account.latitude' %> <%= f.text_field :home_lat, :size => 20, :id => "home_lat" %><%= t 'user.account.longitude' %><%= f.text_field :home_lon, :size => 20, :id => "home_lon" %></span></td></tr>
 
   <tr><td></td><td>
 
   <tr><td></td><td>
-  <p>Update home location when I click on the map? <input type="checkbox" value="1" <% unless @user.home_lat and @user.home_lon %> checked="checked" <% end %> id="updatehome" /> </p>
+  <p><%= t 'user.account.update home location on click' %> <input type="checkbox" value="1" <% unless @user.home_lat and @user.home_lon %> checked="checked" <% end %> id="updatehome" /> </p>
   <div id="map" style="border:1px solid black; position:relative; width:500px; height:400px;"></div>
   </td></tr>
   
   <div id="map" style="border:1px solid black; position:relative; width:500px; height:400px;"></div>
   </td></tr>
   
-  <tr><td></td><td align=right><br/></br><%= submit_tag 'Save Changes' %></td></tr>
+  <tr><td></td><td align=right><br/></br><%= submit_tag t('user.account.save changes button') %></td></tr>
 </table>
 <br/>
 
 </table>
 <br/>
 
   Your email address will not be revealed by becoming public.<br />
   This action cannot be reversed and all new users are now public by default.<br />
   <br /><br />
   Your email address will not be revealed by becoming public.<br />
   This action cannot be reversed and all new users are now public by default.<br />
   <br /><br />
-  <%= button_to "Make all my edits public", :action => :go_public %>
+  <%= button_to t('user.account.make all my edits public button', :action => :go_public %>
 <% end %>
 <br/>
 <br/>
 <% end %>
 <br/>
 <br/>
-<%= link_to 'return to profile', :controller => 'user', :action => @user.display_name %>
+<%= link_to t('user.account.return to profile'), :controller => 'user', :action => @user.display_name %>
 <br/>
 <br/>
 <br/>
 <br/>
index 7953ff8222eaf2837ee9b2cd646b1adf8c09a574..5a4106ee395d441efd59b6463f30d9e40a6e42ea 100644 (file)
@@ -1,10 +1,10 @@
-<h1>Confirm a user account</h1>
+<h1><%= t 'user.confirm.heading' %></h1>
 
 
-<p>Press the confirm button below to activate your account.</p>
+<p><%= t 'user.confirm.press confirm button' %></p>
 
 <form method="post">
 <input type="hidden" name="confirm_string" value="<%= params[:confirm_string] %>">
 
 <form method="post">
 <input type="hidden" name="confirm_string" value="<%= params[:confirm_string] %>">
-<input type="submit" name="confirm_action" value="Confirm">
+<input type="submit" name="confirm_action" value="<%= t 'user.confirm.button' %>">
 </form>
 
 
 </form>
 
 
index 4be2b19bab8c52209b002be7fd64a2128b2d8b75..154dbb7c278f225ce37b30218401461b725ed85e 100644 (file)
@@ -1,8 +1,8 @@
-<h1>Confirm a change of email address</h1>
+<h1><%= t 'user.confirm email.heading' %></h1>
 
 
-<p>Press the confirm button below to confirm your new email address.</p>
+<p><%= t 'user.confirm email. press confirm button' %></p>
 
 <form method="post">
 <input type="hidden" name="confirm_string" value="<%= params[:confirm_string] %>">
 
 <form method="post">
 <input type="hidden" name="confirm_string" value="<%= params[:confirm_string] %>">
-<input type="submit" name="confirm_action" value="Confirm">
+<input type="submit" name="confirm_action" value="<%= t 'user.confirm email.button' %>">
 </form>
 </form>
index 42dafa74445e7ed508acc299e44fc9f6ca42ef10..f0d91800be28931642ad0abf9ce5977ba92c250d 100644 (file)
@@ -12,12 +12,12 @@ en:
       older_entries: Older Entries
       newer_entries: Newer Entries
     edit:
       older_entries: Older Entries
       newer_entries: Newer Entries
     edit:
-      subject: "Subject:"
-      body: "Body:"
-      language: "Language:"
-      location: "Location:"
-      latitude: "Latitude:"
-      longitude: "Longitude:"
+      subject: "Subject: "
+      body: "Body: "
+      language: "Language: "
+      location: "Location: "
+      latitude: "Latitude: "
+      longitude: "Longitude: "
       use_map_link: "use map"
       save_button: "Save"
       marker_text: Diary entry location
       use_map_link: "use map"
       save_button: "Save"
       marker_text: Diary entry location
@@ -96,9 +96,16 @@ en:
       lost password link: "Lost your password?"
       login_button: Login
     lost_password:
       lost password link: "Lost your password?"
       login_button: Login
     lost_password:
+      title: lost password
       heading: "Forgotten Password?"
       email address: "Email Address:"
       new password button: "Send me a new password"
       heading: "Forgotten Password?"
       email address: "Email Address:"
       new password button: "Send me a new password"
+      notice email on way: "Sorry you lost it :-( but an email is on its way so you can reset it soon."
+      notice email cannot find: "Couldn't find that email address, sorry."
+    reset_password:
+      title: reset password
+      flash changed check mail: "Your password has been changed and is on its way to your mailbox :-)"
+      flash token bad: "Didn't find that token, check the URL maybe?"
     new:
       heading: Create a User Account
       no_auto_account_create: "Unfortunately we are not currently able to create an account for you automatically."
     new:
       heading: Create a User Account
       no_auto_account_create: "Unfortunately we are not currently able to create an account for you automatically."
@@ -109,9 +116,10 @@ en:
       confirm email address: "Confirm Email Address: "
       not displayed publicly: 'Not displayed publicly (see <a href="http://wiki.openstreetmap.org/wiki/Privacy_Policy" title="wiki privacy policy including section on email addresses">privacy policy</a>)'
       display name: "Display Name: "
       confirm email address: "Confirm Email Address: "
       not displayed publicly: 'Not displayed publicly (see <a href="http://wiki.openstreetmap.org/wiki/Privacy_Policy" title="wiki privacy policy including section on email addresses">privacy policy</a>)'
       display name: "Display Name: "
-      password: "Password: "
+      pasword: "Password: "
       confirm password: "Confirm Password: "
       signup: Signup
       confirm password: "Confirm Password: "
       signup: Signup
+      flash create success message: "User was successfully created. Check your email for a confirmation note, and you\'ll be mapping in no time :-)<br /><br />Please note that you won't be able to login until you've received and confirmed your email address.<br /><br />If you use an antispam system which sends confirmation requests then please make sure you whitelist webmaster@openstreetmap.org as we are unable to reply to any confirmation requests."
     no_such_user:
       body: "Sorry, there is no user with the name {{user}}. Please check your spelling, or maybe the link you clicked is wrong."
     view:
     no_such_user:
       body: "Sorry, there is no user with the name {{user}}. Please check your spelling, or maybe the link you clicked is wrong."
     view:
@@ -145,3 +153,36 @@ en:
     friend_map:
       your location: Your location
       nearby mapper: "Nearby mapper: "
     friend_map:
       your location: Your location
       nearby mapper: "Nearby mapper: "
+    account:
+      my settings: My settings
+      email never displayed publicly: "(never displayed publicly)"
+      public editing:
+        heading: "Public editing: "
+        enabled: "Enabled. Not anonymous and can edit data."
+        enabled link: "http://wiki.openstreetmap.org/wiki/Disabling_anonymous_edits"
+        enabled link text: "what's this?"
+        disabled: "Disabled and cannot edit data, all previous edits are anonymous."
+        disabled link text: "why can't I edit?"
+      profile description: "Profile Description: "
+      home location: "Home Location: "
+      no home location: "You have not entered your home location."
+      latitude: "Latitude: "
+      longitude: "Longitude: "
+      update home location on click: "Update home location when I click on the map?"
+      save changes button: Save Changes
+      make edits public button: Make all my edits public
+      return to profile: Return to profile
+      flash update success confirm needed: "User information updated successfully. Check your email for a note to confirm your new email address."
+      flash update success: "User information updated successfully."
+    confirm:
+      heading: Confirm a user account
+      press confirm button: "Press the confirm button below to activate your account."
+      button: Confirm
+    confirm email:
+      heading: Confirm a change of email address
+      press confirm button: "Press the confirm button below to confirm your new eail address."
+      button: Confirm
+    set_home:
+      flash success: "Home location saved successfully"
+    go_public:
+      flash success: "All your edits are now public, and you are now allowed to edit."