From 1102fcd56590f17bc269b7ece67334b527fd901d Mon Sep 17 00:00:00 2001 From: MrZYX Date: Thu, 4 Nov 2010 18:10:10 +0100 Subject: [PATCH] made flash messages translatable --- app/controllers/invitations_controller.rb | 2 +- app/controllers/people_controller.rb | 6 +++--- app/controllers/requests_controller.rb | 2 +- app/controllers/services_controller.rb | 4 ++-- app/controllers/users_controller.rb | 12 ++++++------ app/views/people/edit.html.haml | 2 +- app/views/services/index.html.haml | 2 +- app/views/users/edit.html.haml | 2 +- config/locales/diaspora/en.yml | 21 ++++++++++++++++++++- 9 files changed, 36 insertions(+), 17 deletions(-) diff --git a/app/controllers/invitations_controller.rb b/app/controllers/invitations_controller.rb index 8f71250a1..8c20ac2ba 100644 --- a/app/controllers/invitations_controller.rb +++ b/app/controllers/invitations_controller.rb @@ -48,7 +48,7 @@ class InvitationsController < Devise::InvitationsController def check_token if User.find_by_invitation_token(params['invitation_token']).nil? - flash[:error] = "Invitation token not found" + flash[:error] = I18n.t 'invitations.check_token.not_found' redirect_to root_url end end diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 9280e2d3e..62b59f3ad 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -32,7 +32,7 @@ class PeopleController < ApplicationController @posts = current_user.visible_posts(:person_id => @person.id).paginate :page => params[:page], :order => 'created_at DESC' respond_with @person else - flash[:error] = "Person does not exist!" + flash[:error] = I18n.t 'people.show.does_not_exist' redirect_to people_path end end @@ -68,9 +68,9 @@ class PeopleController < ApplicationController prep_image_url(params[:person]) if current_user.update_profile params[:person][:profile] - flash[:notice] = "Profile updated" + flash[:notice] = I18n.t 'people.update.updated' else - flash[:error] = "Failed to update profile" + flash[:error] = I18n.t 'people.update.failed' end if params[:getting_started] diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index e324357e0..3a16791f2 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -62,7 +62,7 @@ class RequestsController < ApplicationController if params[:getting_started] redirect_to getting_started_path(:step=>params[:getting_started]) else - flash[:notice] = "we tried our best to send a message to #{account}" unless flash[:error] + flash[:notice] = I18n.t('requests.create.tried', :account => account) unless flash[:error] respond_with :location => aspects_manage_path return end diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index d5fd50c83..4335efede 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -31,14 +31,14 @@ class ServicesController < ApplicationController :uid => auth['uid']) end - flash[:notice] = "Authentication successful." + flash[:notice] = I18n.t 'services.create.success' redirect_to services_url end def destroy @service = current_user.services.find(params[:id]) @service.destroy - flash[:notice] = "Successfully destroyed authentication." + flash[:notice] = I18n.t 'services.destroy.success' redirect_to services_url end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a96438dc2..76f192ffd 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -31,15 +31,15 @@ class UsersController < ApplicationController if params[:user][:password] && params[:user][:password_confirmation] if @user.update_attributes(:password => params[:user][:password], :password_confirmation => params[:user][:password_confirmation]) - flash[:notice] = "Password Changed" + flash[:notice] = I18n.t 'users.update.password_changed' else - flash[:error] = "Password Change Failed" + flash[:error] = I18n.t 'users.update.password_not_changed' end elsif params[:user][:language] if @user.update_attributes(:language => params[:user][:language]) - flash[:notice] = "Language Changed" + flash[:notice] = I18n.t 'users.update.language_changed' else - flash[:error] = "Language Change Failed" + flash[:error] = I18n.t 'users.update.language_not_changed' end end @@ -50,7 +50,7 @@ class UsersController < ApplicationController def destroy current_user.destroy sign_out current_user - flash[:notice] = t('user.destroy') + flash[:notice] = I18n.t 'users.destroy' redirect_to root_path end @@ -63,7 +63,7 @@ class UsersController < ApplicationController render :xml => director.build(ostatus_builder), :content_type => 'application/atom+xml' else - flash[:error] = "User #{params[:username]} does not exist!" + flash[:error] = I18n.t 'users.public.does_not_exists', :username => params[:username] redirect_to root_url end end diff --git a/app/views/people/edit.html.haml b/app/views/people/edit.html.haml index 089f2d760..6a7fd562e 100644 --- a/app/views/people/edit.html.haml +++ b/app/views/people/edit.html.haml @@ -9,7 +9,7 @@ %ul#settings_nav %li=link_to t('profile'), edit_person_path(current_user.person) %li=link_to t('account'), edit_user_path(current_user) - %li=link_to t('services'), services_path + %li=link_to t('_services'), services_path .span-19.prepend-5.last = form_for @person, :html => { :multipart => true } do |person| diff --git a/app/views/services/index.html.haml b/app/views/services/index.html.haml index 5d5a3b772..526175cc9 100644 --- a/app/views/services/index.html.haml +++ b/app/views/services/index.html.haml @@ -8,7 +8,7 @@ %ul#settings_nav %li=link_to t('profile'), edit_person_path(current_user.person) %li=link_to t('account'), edit_user_path(current_user) - %li=link_to t('services'), services_path + %li=link_to t('_services'), services_path .span-19.prepend-5.last %h2 diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index cea119d59..887e51edc 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -18,7 +18,7 @@ %ul#settings_nav %li=link_to t('profile'), edit_person_path(current_user.person) %li=link_to t('account'), edit_user_path(current_user) - %li=link_to t('services'), services_path + %li=link_to t('_services'), services_path .span-19.prepend-5.last %h2 diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 5a62a36ee..1baed842f 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -10,7 +10,7 @@ en: settings: "Settings" profile: "Profile" account: "Account" - services: "Services" + _services: "Services" _photos: "photos" stream: "stream" ok: "OK" @@ -156,6 +156,13 @@ en: 'step_1': you_dont_have_any_photos: "You don't have any photos! Go to the" page_to_upload_some: "page to upload some." + update: + password_changed: "Password Changed" + password_not_changed: "Password Change Failed" + language_changed: "Language Changed" + language_not_changed: "Language Change Failed" + public: + does_not_exist: "User %{username} does not exist!" comments: new_comment: comment: "Comment" @@ -215,6 +222,8 @@ en: message: 'Message:' send_an_invitation: 'Send an invitation' send_invitation: 'Send invitation' + check_token: + not_found: "Invitation token not found" status_messages: new_status_message: tell_me_something_good: "tell me something good" @@ -258,6 +267,7 @@ en: not_friends: "You're currently not friends with %{name}" request_people: "If you'd like, you can request to place him/her in one of your aspects." already_requested: "You have already sent a request to %{name}." + does_not_exist: "Person does not exist!" edit: info_available_to: "This info will be available to whomever you connect with on Diaspora." your_profile: "Your profile" @@ -280,6 +290,9 @@ en: allow_search: "Allow for people to search for you" profile_photo_upload: or_select_one: "or select one from your already existing" + update: + updated: "Profile updated" + failed: "Failed to update profile" requests: new_request: add_a_new_friend_to: "Add a new friend to" @@ -299,3 +312,9 @@ en: already_friends: "You are already friends with %{destination_url}!" success: "A friend request was sent to %{destination_url}." horribly_wrong: "Something went horribly wrong." + tried: "we tried our best to send a message to %{account}" + services: + create: + success: "Authentication successful." + destroy: + success: "Successfully destroyed authentication."