From 5197c1b3ec8ea0b9a96d4530a3a551174d158227 Mon Sep 17 00:00:00 2001 From: Claudius Coenen Date: Fri, 17 Sep 2010 00:23:35 +0200 Subject: [PATCH] adding localisation for controller's flash messages' --- app/controllers/albums_controller.rb | 8 ++++---- config/locales/de.yml | 7 +++++++ config/locales/en.yml | 9 ++++++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb index 5a75616d1..1a577f645 100644 --- a/app/controllers/albums_controller.rb +++ b/app/controllers/albums_controller.rb @@ -17,7 +17,7 @@ class AlbumsController < ApplicationController def create aspect = params[:album][:to] @album = current_user.post(:album, params[:album]) - flash[:notice] = "You've created an album called #{@album.name}." + flash[:notice] = I18n.t('albums.create.success', :name => @album.name) redirect_to :action => :show, :id => @album.id, :aspect => aspect end @@ -28,7 +28,7 @@ class AlbumsController < ApplicationController def destroy @album = Album.find_by_id params[:id] @album.destroy - flash[:notice] = "Album #{@album.name} deleted." + flash[:notice] = I18n.t('albums.destroy.success', :name => @album.name) respond_with :location => albums_url end @@ -48,10 +48,10 @@ class AlbumsController < ApplicationController def update @album = Album.find_params_by_id params[:id] if @album.update_attributes params[:album] - flash[:notice] = "Album #{@album.name} successfully edited." + flash[:notice] = I18n.t('albums.update.success', :name => @album.name) respond_with @album else - flash[:error] = "Failed to edit album #{@album.name}." + flash[:error] = I18n.t('albums.update.failure', :name => @album.name) render :action => :edit end end diff --git a/config/locales/de.yml b/config/locales/de.yml index 23617a3f3..c67d87550 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -30,6 +30,8 @@ de: new_album: create: "erstellen" add_a_new_album: "Album hinzufügen" + create: + success: Du hast das Album %{name} erstellt. show: edit_album: "Album bearbeiten" albums: "Alben" @@ -41,9 +43,14 @@ de: are_you_sure: "Bist du sicher?" delete_album: "Album löschen" cancel: "Abbrechen" + update: + success: Album %{name} erfolgreich geändert. + failure: %{name} wurde nicht geändert. index: home: "Startseite" new_album: "Neues Album" + destroy: + success: Album %{name} gelöscht. aspects: index: photos: "Fotos" diff --git a/config/locales/en.yml b/config/locales/en.yml index d9046c00b..87a96b009 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -30,6 +30,8 @@ en: new_album: create: "create" add_a_new_album: "Add a new album" + create: + success: You've created an album called %{name}. show: edit_album: "Edit Album" albums: "albums" @@ -41,10 +43,15 @@ en: are_you_sure: "Are you sure?" delete_album: "Delete Album" cancel: "Cancel" + update: + success: Album %{name} successfully edited. + failure: Failed to edit album %{name}. index: home: "home" new_album: "New Album" - aspects: + destroy: + success: Album %{name} deleted. + aspects: index: photos: "photos" show: