fix articles controller i18n

Conflicts:

	app/controllers/articles_controller.rb
This commit is contained in:
wvengen 2013-04-12 16:14:54 +02:00
parent f6ba21832d
commit 5e2a3fb3f0
2 changed files with 33 additions and 32 deletions

View file

@ -95,31 +95,31 @@ class ArticlesController < ApplicationController
if invalid_articles if invalid_articles
# An error has occurred, transaction has been rolled back. # An error has occurred, transaction has been rolled back.
flash.now.alert = I18n.t('articles.update_all.error_invalid') flash.now.alert = I18n.t('articles.controller.error_invalid')
render :edit_all render :edit_all
else else
# Successfully done. # Successfully done.
redirect_to supplier_articles_path(@supplier), notice: I18n.t('articles.update_all.notice') redirect_to supplier_articles_path(@supplier), notice: I18n.t('articles.controller.update_all.notice')
end end
end end
# makes different actions on selected articles # makes different actions on selected articles
def update_selected def update_selected
raise I18n.t('articles.update_selected.error_nosel') if params[:selected_articles].nil? raise I18n.t('articles.controller.error_nosel') if params[:selected_articles].nil?
articles = Article.find(params[:selected_articles]) articles = Article.find(params[:selected_articles])
Article.transaction do Article.transaction do
case params[:selected_action] case params[:selected_action]
when 'destroy' when 'destroy'
articles.each(&:mark_as_deleted) articles.each(&:mark_as_deleted)
flash[:notice] = I18n.t('articles.update_selected.notice_destroy') flash[:notice] = I18n.t('articles.controller.update_sel.notice_destroy')
when 'setNotAvailable' when 'setNotAvailable'
articles.each {|a| a.update_attribute(:availability, false) } articles.each {|a| a.update_attribute(:availability, false) }
flash[:notice] = I18n.t('articles.update_selected.notice_unavail') flash[:notice] = I18n.t('articles.controller.update_sel.notice_unavail')
when 'setAvailable' when 'setAvailable'
articles.each {|a| a.update_attribute(:availability, true) } articles.each {|a| a.update_attribute(:availability, true) }
flash[:notice] = I18n.t('articles.update_selected.notice_avail') flash[:notice] = I18n.t('articles.controller.update_sel.notice_avail')
else else
flash[:alert] = I18n.t('articles.update_selected.notice_noaction') flash[:alert] = I18n.t('articles.controller.update_sel.notice_noaction')
end end
end end
# action succeded # action succeded
@ -160,11 +160,11 @@ class ArticlesController < ApplicationController
:tax => row[:tax]) :tax => row[:tax])
# stop parsing, when an article isn't valid # stop parsing, when an article isn't valid
unless article.valid? unless article.valid?
raise I18n.t('articles.parse_upload.error_parse', :msg => article.errors.full_messages.join(", "), :line => (articles.index(row) + 2).to_s) raise I18n.t('articles.controller.error_parse', :msg => article.errors.full_messages.join(", "), :line => (articles.index(row) + 2).to_s)
end end
@articles << article @articles << article
end end
flash.now[:notice] = I18n.t('articles.parse_upload.notice', :count => @articles.size) flash.now[:notice] = I18n.t('articles.controller.parse_upload.notice', :count => @articles.size)
rescue => error rescue => error
redirect_to upload_supplier_articles_path(@supplier), :alert => I18n.t('errors.general_msg', :msg => error.message) redirect_to upload_supplier_articles_path(@supplier), :alert => I18n.t('errors.general_msg', :msg => error.message)
end end
@ -181,10 +181,10 @@ class ArticlesController < ApplicationController
invalid_articles = true unless article.save invalid_articles = true unless article.save
end end
raise I18n.t('articles.create_from_upload.error_invalid') if invalid_articles raise I18n.t('articles.controller.error_invalid') if invalid_articles
end end
# Successfully done. # Successfully done.
redirect_to supplier_articles_path(@supplier), notice: I18n.t('articles.create_from_upload.notice', :count => @articles.size) redirect_to supplier_articles_path(@supplier), notice: I18n.t('articles.controller.create_from_upload.notice', :count => @articles.size)
rescue => error rescue => error
# An error has occurred, transaction has been rolled back. # An error has occurred, transaction has been rolled back.
@ -215,14 +215,14 @@ class ArticlesController < ApplicationController
def sync def sync
# check if there is an shared_supplier # check if there is an shared_supplier
unless @supplier.shared_supplier unless @supplier.shared_supplier
redirect_to supplier_articles_url(@supplier), :alert => I18n.t('articles.sync.shared_alert', :supplier => @supplier.name) redirect_to supplier_articles_url(@supplier), :alert => I18n.t('articles.controller.sync.shared_alert', :supplier => @supplier.name)
end end
# sync articles against external database # sync articles against external database
@updated_articles, @outlisted_articles = @supplier.sync_all @updated_articles, @outlisted_articles = @supplier.sync_all
# convert to db-compatible-string # convert to db-compatible-string
@updated_articles.each {|a, b| a.shared_updated_on = a.shared_updated_on.to_formatted_s(:db)} @updated_articles.each {|a, b| a.shared_updated_on = a.shared_updated_on.to_formatted_s(:db)}
if @updated_articles.empty? && @outlisted_articles.empty? if @updated_articles.empty? && @outlisted_articles.empty?
redirect_to supplier_articles_path(@supplier), :notice => I18n.t('articles.sync.notice') redirect_to supplier_articles_path(@supplier), :notice => I18n.t('articles.controller.sync.notice')
end end
end end
@ -242,12 +242,12 @@ class ArticlesController < ApplicationController
end end
# Successfully done. # Successfully done.
redirect_to supplier_articles_path(@supplier), notice: I18n.t('articles.update_synchronized.notice') redirect_to supplier_articles_path(@supplier), notice: I18n.t('articles.controller.update_sync.notice')
rescue ActiveRecord::RecordInvalid => invalid rescue ActiveRecord::RecordInvalid => invalid
# An error has occurred, transaction has been rolled back. # An error has occurred, transaction has been rolled back.
redirect_to supplier_articles_path(@supplier), redirect_to supplier_articles_path(@supplier),
alert: I18n.t('articles.update_synchronized.error_update', :article => invalid.record.name, :msg => invalid.record.errors.full_messages) alert: I18n.t('articles.controller.error_update', :article => invalid.record.name, :msg => invalid.record.errors.full_messages)
rescue => error rescue => error
redirect_to supplier_articles_path(@supplier), redirect_to supplier_articles_path(@supplier),

View file

@ -91,26 +91,27 @@ de:
submit: 'Speichere neue Artikel für %{supplier}' submit: 'Speichere neue Artikel für %{supplier}'
# used by controller # used by controller
controller:
update_all: update_all:
notice: 'Alle Artikel und Preise wurden aktualisiert' notice: 'Alle Artikel und Preise wurden aktualisiert'
error_invalid: 'Artikel sind fehlerhaft. Bitte überprüfe Deine Eingaben.' update_sel:
update_selected:
notice_destroy: 'Alle gewählten Artikel wurden gelöscht' notice_destroy: 'Alle gewählten Artikel wurden gelöscht'
notice_unavail: 'Alle gewählten Artikel wurden auf "nicht verfügbar" gesetzt' notice_unavail: 'Alle gewählten Artikel wurden auf "nicht verfügbar" gesetzt'
notice_avail: 'Alle gewählten Artikel wurden auf "verfügbar" gesetzt' notice_avail: 'Alle gewählten Artikel wurden auf "verfügbar" gesetzt'
notice_noaction: 'Keine Aktion ausgewählt!' notice_noaction: 'Keine Aktion ausgewählt!'
error_nosel: 'Du hast keine Artikel ausgewählt'
parse_upload: parse_upload:
notice: '%{count} Artikel sind erfolgreich analysiert.' notice: '%{count} Artikel sind erfolgreich analysiert.'
error_parse: '%{msg} ... in Zeile %{line}'
create_from_upload: create_from_upload:
notice: 'Es wurden %{count} neue Artikel gespeichert.' notice: 'Es wurden %{count} neue Artikel gespeichert.'
error_invalid: 'Artikel sind fehlerhaft'
sync: sync:
shared_alert: '%{supplier} ist nicht mit einer externen Datenbank verknüpft.' shared_alert: '%{supplier} ist nicht mit einer externen Datenbank verknüpft.'
notice: 'Der Katalog ist aktuell' notice: 'Der Katalog ist aktuell'
update_synchronized: update_sync:
notice: 'Alle Artikel und Preise wurden aktualisiert' notice: 'Alle Artikel und Preise wurden aktualisiert'
error_invalid: 'Artikel sind fehlerhaft. Bitte überprüfe Deine Eingaben.'
error_nosel: 'Du hast keine Artikel ausgewählt'
error_invalid: 'Artikel sind fehlerhaft'
error_parse: '%{msg} ... in Zeile %{line}'
error_update: "Es trat ein Fehler beim Aktualisieren des Artikels '%{article}' auf: %{msg}" error_update: "Es trat ein Fehler beim Aktualisieren des Artikels '%{article}' auf: %{msg}"
# used by model # used by model