From: Shaun McDonald Date: Sat, 30 May 2009 14:04:42 +0000 (+0000) Subject: Some more of the user account translations. Custom generate method for languages... X-Git-Tag: live~7358^2~52 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/3a599519eb49c2211bbb513fbbda65a05068b9e5?ds=sidebyside Some more of the user account translations. Custom generate method for languages, that doesn't appear to work. Setting user language on create. Start translations in controllers. Diary entries can now be saved. --- diff --git a/app/controllers/diary_entry_controller.rb b/app/controllers/diary_entry_controller.rb index 9bbadb29d..9ce5409d6 100644 --- a/app/controllers/diary_entry_controller.rb +++ b/app/controllers/diary_entry_controller.rb @@ -13,6 +13,8 @@ class DiaryEntryController < ApplicationController 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 @@ -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] + 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 diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 36516f60f..0b2ec168a 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -23,9 +23,11 @@ class UserController < ApplicationController @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 - flash[:notice] = "User was successfully created. Check your email for a confirmation note, and you\'ll be mapping in no time :-)

Please note that you won't be able to login until you've received and confirmed your email address.

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 @@ -54,10 +56,10 @@ class UserController < ApplicationController 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 - @notice = "User information updated successfully." + flash[:notice] = I18n.t('user.account.flash update success') 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 - flash[:notice] = "Home location saved successfully." + flash[:notice] = I18n.t('user.set_home.flash success') redirect_to :controller => 'user', :action => 'account' end end @@ -77,27 +79,27 @@ class UserController < ApplicationController 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 - @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) - @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 - @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 - @title = 'reset password' + @title = I18n.t('user.reset_password.title') 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) - 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 - flash[:notice] = "Didn't find that token, check the URL maybe?" + flash[:notice] = I18n.t('user.reset_password.flash token bad') end end diff --git a/app/models/language.rb b/app/models/language.rb index 8965cf453..150341cc7 100644 --- a/app/models/language.rb +++ b/app/models/language.rb @@ -3,4 +3,12 @@ class Language < ActiveRecord::Base 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 diff --git a/app/views/user/account.rhtml b/app/views/user/account.rhtml index 1dd4bdca0..40e8fe01a 100644 --- a/app/views/user/account.rhtml +++ b/app/views/user/account.rhtml @@ -1,33 +1,33 @@ -

My settings

+

<%= t 'user.account.my settings' %>

<%= error_messages_for 'user' %> <% form_for :user, @user do |f| %> - - - - + + + + - + - + - class="nohome" <%end%> > + class="nohome" <%end%> > - +
Display Name : <%= f.text_field :display_name %>
Email : <%= f.text_field :email, {:size => 50, :maxlength => 255} %> (never displayed publicly)
Password : <%= f.password_field :pass_crypt, {:value => '', :size => 30, :maxlength => 255} %>
Confirm Password : <%= f.password_field :pass_crypt_confirmation, {:value => '', :size => 30, :maxlength => 255} %>
<%= t 'user.new.display name' %><%= f.text_field :display_name %>
<%= t 'user.new.email address' %><%= f.text_field :email, {:size => 50, :maxlength => 255} %> <%= t 'user.account.email never displayed publicly' %>
<%= t 'user.new.password' %><%= f.password_field :pass_crypt, {:value => '', :size => 30, :maxlength => 255} %>
<%= t 'user.new.confirm password' %><%= f.password_field :pass_crypt_confirmation, {:value => '', :size => 30, :maxlength => 255} %>
Public editing :<%= t 'user.account.public editing.heading' %> <% if @user.data_public? %> - Enabled. Not anonymous (what's this?) + <%= t 'user.account.public editing.enabled' %> (<%= t 'user.account.public editing.enabled link text' %>) <% else %> - Disabled and anonymous. (why's this bad?) + <%= t 'user.account.public editing.disabled' %>(<%= t 'user.account.public editing.disabled link text' %>) <% end %>
Profile Description : <%= f.text_area :description, :rows => '5', :cols => '60' %>

<%= t 'user.account.profile description' %><%= f.text_area :description, :rows => '5', :cols => '60' %>

Home Location : You have not entered your home location.Latitude: <%= f.text_field :home_lat, :size => 20, :id => "home_lat" %> Longitude <%= f.text_field :home_lon, :size => 20, :id => "home_lon" %>
<%= t 'user.account.home location' %><%= t 'user.account.no home 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" %>
-

Update home location when I click on the map? checked="checked" <% end %> id="updatehome" />

+

<%= t 'user.account.update home location on click' %> checked="checked" <% end %> id="updatehome" />



<%= submit_tag 'Save Changes' %>


<%= submit_tag t('user.account.save changes button') %>

@@ -42,10 +42,10 @@ Your email address will not be revealed by becoming public.
This action cannot be reversed and all new users are now public by default.


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

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

diff --git a/app/views/user/confirm.rhtml b/app/views/user/confirm.rhtml index 7953ff822..5a4106ee3 100644 --- a/app/views/user/confirm.rhtml +++ b/app/views/user/confirm.rhtml @@ -1,10 +1,10 @@ -

Confirm a user account

+

<%= t 'user.confirm.heading' %>

-

Press the confirm button below to activate your account.

+

<%= t 'user.confirm.press confirm button' %>

- +
diff --git a/app/views/user/confirm_email.rhtml b/app/views/user/confirm_email.rhtml index 4be2b19ba..154dbb7c2 100644 --- a/app/views/user/confirm_email.rhtml +++ b/app/views/user/confirm_email.rhtml @@ -1,8 +1,8 @@ -

Confirm a change of email address

+

<%= t 'user.confirm email.heading' %>

-

Press the confirm button below to confirm your new email address.

+

<%= t 'user.confirm email. press confirm button' %>

- +
diff --git a/config/locales/en.yml b/config/locales/en.yml index 42dafa744..f0d91800b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -12,12 +12,12 @@ en: 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 @@ -96,9 +96,16 @@ en: 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" + 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." @@ -109,9 +116,10 @@ en: confirm email address: "Confirm Email Address: " not displayed publicly: 'Not displayed publicly (see privacy policy)' display name: "Display Name: " - password: "Password: " + pasword: "Password: " 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 :-)

Please note that you won't be able to login until you've received and confirmed your email address.

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: @@ -145,3 +153,36 @@ en: 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."