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
# 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
else
# 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
# makes different actions on selected articles
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])
Article.transaction do
case params[:selected_action]
when 'destroy'
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'
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'
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
flash[:alert] = I18n.t('articles.update_selected.notice_noaction')
flash[:alert] = I18n.t('articles.controller.update_sel.notice_noaction')
end
end
# action succeded
@ -160,11 +160,11 @@ class ArticlesController < ApplicationController
:tax => row[:tax])
# stop parsing, when an article isn't 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
@articles << article
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
redirect_to upload_supplier_articles_path(@supplier), :alert => I18n.t('errors.general_msg', :msg => error.message)
end
@ -181,10 +181,10 @@ class ArticlesController < ApplicationController
invalid_articles = true unless article.save
end
raise I18n.t('articles.create_from_upload.error_invalid') if invalid_articles
raise I18n.t('articles.controller.error_invalid') if invalid_articles
end
# 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
# An error has occurred, transaction has been rolled back.
@ -215,14 +215,14 @@ class ArticlesController < ApplicationController
def sync
# check if there is an 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
# sync articles against external database
@updated_articles, @outlisted_articles = @supplier.sync_all
# convert to db-compatible-string
@updated_articles.each {|a, b| a.shared_updated_on = a.shared_updated_on.to_formatted_s(:db)}
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
@ -242,12 +242,12 @@ class ArticlesController < ApplicationController
end
# 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
# An error has occurred, transaction has been rolled back.
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
redirect_to supplier_articles_path(@supplier),

View file

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