complete and improve receive i18n

This commit is contained in:
wvengen 2014-01-08 13:39:49 +01:00
parent 8f14ab31f3
commit ce17bf33e0
3 changed files with 28 additions and 11 deletions

View file

@ -111,7 +111,8 @@ class OrdersController < ApplicationController
unless request.post? unless request.post?
@order_articles = @order.order_articles.ordered.includes(:article) @order_articles = @order.order_articles.ordered.includes(:article)
else else
flash[:notice] = "Order received: " + update_order_amounts s = update_order_amounts
flash[:notice] = (s ? I18n.t('orders.receive.notice', :msg => s) : I18n.t('orders.receive.notice_none'))
redirect_to @order redirect_to @order
end end
end end
@ -156,6 +157,7 @@ class OrdersController < ApplicationController
end end
def update_order_amounts def update_order_amounts
return if not params[:order_articles]
# where to leave remainder during redistribution # where to leave remainder during redistribution
rest_to = [] rest_to = []
rest_to << :tolerance if params[:rest_to_tolerance] rest_to << :tolerance if params[:rest_to_tolerance]
@ -183,10 +185,12 @@ class OrdersController < ApplicationController
end end
end end
end end
notice = " #{counts.shift} articles (#{cunits.shift} units) updated" notice = I18n.t('orders.update_order_amounts.msg1', count: counts.shift, units: cunits.shift)
notice += ", #{counts.shift} (#{cunits.shift}) using tolerance" if params[:rest_to_tolerance] notice += ", " + I18n.t('orders.update_order_amounts.msg2', count: counts.shift, units: cunits.shift) if params[:rest_to_tolerance]
notice += ", #{counts.shift} (#{cunits.shift}) go to stock if foodsoft would support that" if params[:rest_to_stock] notice += ", " + I18n.t('orders.update_order_amounts.msg3', count: counts.shift, units: cunits.shift) if params[:rest_to_stock]
notice += ", #{counts.shift} (#{cunits.shift}) left over" if counts[0]>0 or cunits[0]>0
notice += ", " + I18n.t('orders.update_order_amounts.msg4', count: counts.shift, units: cunits.shift)
end
end end
end end

View file

@ -20,9 +20,9 @@ module OrdersHelper
if order_article.order.open? if order_article.order.open?
nil nil
else else
units_info = "#{order_article.units_to_order} #{heading_helper OrderArticle, :units_to_order}" units_info = "#{order_article.units_to_order} #{OrderArticle.human_attribute_name :units_to_order, count: order_article.units_to_order}"
units_info += ", #{order_article.units_billed} #{heading_helper OrderArticle, :units_billed}" unless order_article.units_billed.nil? units_info += ", #{order_article.units_billed} #{OrderArticle.human_attribute_name :units_billed_short, count: order_article.units_billed}" unless order_article.units_billed.nil?
units_info += ", #{order_article.units_received} #{heading_helper OrderArticle, :units_received}" unless order_article.units_received.nil? units_info += ", #{order_article.units_received} #{OrderArticle.human_attribute_name :units_received_short, count: order_article.units_received}" unless order_article.units_received.nil?
end end
end end

View file

@ -80,13 +80,19 @@ en:
supplier: Supplier supplier: Supplier
order_article: order_article:
article: Article article: Article
missing_units: Missing units missing_units:
one: Missing unit
other: Missing units
missing_units_short: Missing missing_units_short: Missing
quantity: Desired amount quantity: Desired amount
quantity_short: Desired quantity_short: Desired
units_received: Received units units_received:
one: Received unit
other: Received units
units_received_short: Received units_received_short: Received
units_to_order: Ordered units units_to_order:
one: Ordered unit
other: Ordered units
units_to_order_short: Ordered units_to_order_short: Ordered
update_current_price: Globally update current price update_current_price: Globally update current price
order_comment: order_comment:
@ -1149,6 +1155,8 @@ en:
receive: receive:
add_article: Add article add_article: Add article
consider_member_tolerance: consider tolerance consider_member_tolerance: consider tolerance
notice: ! 'Order received: %{msg}'
notice_none: No new articles to receive
rest_to_stock: rest to stock rest_to_stock: rest to stock
submit: Receive order submit: Receive order
surplus_options: 'Distribution options:' surplus_options: 'Distribution options:'
@ -1184,6 +1192,11 @@ en:
open: open open: open
update: update:
notice: The order was updated. notice: The order was updated.
update_order_amounts:
msg1: "%{count} articles (%{units} units) updated"
msg2: "%{count} (%{units}) using tolerance"
msg3: "%{count} (%{units}) go to stock if foodsoft would support that [don't translate]"
msg4: "%{count} (%{units}) left over"
pages: pages:
all: all:
new_page: Create new page new_page: Create new page