diff --git a/app/controllers/group_orders_controller.rb b/app/controllers/group_orders_controller.rb index 76c23372..f93e98ec 100644 --- a/app/controllers/group_orders_controller.rb +++ b/app/controllers/group_orders_controller.rb @@ -20,12 +20,12 @@ class GroupOrdersController < ApplicationController @group_order = GroupOrder.new(params[:group_order]) begin @group_order.save_ordering! - redirect_to group_order_url(@group_order), :notice => 'Die Bestellung wurde gespeichert.' + redirect_to group_order_url(@group_order), :notice => I18n.t('group_orders.create.notice') rescue ActiveRecord::StaleObjectError - redirect_to group_orders_url, :alert => 'In der Zwischenzeit hat jemand anderes auch bestellt, daher konnte die Bestellung nicht aktualisiert werden.' + redirect_to group_orders_url, :alert => I18n.t('group_orders.create.error_stale') rescue => exception logger.error('Failed to update order: ' + exception.message) - redirect_to group_orders_url, :alert => 'Die Bestellung konnte nicht aktualisiert werden, da ein Fehler auftrat.' + redirect_to group_orders_url, :alert => I18n.t('group_orders.create.error_general') end end @@ -41,12 +41,12 @@ class GroupOrdersController < ApplicationController @group_order.attributes = params[:group_order] begin @group_order.save_ordering! - redirect_to group_order_url(@group_order), :notice => 'Die Bestellung wurde gespeichert.' + redirect_to group_order_url(@group_order), :notice => I18n.t('group_orders.update.notice') rescue ActiveRecord::StaleObjectError - redirect_to group_orders_url, :alert => 'In der Zwischenzeit hat jemand anderes auch bestellt, daher konnte die Bestellung nicht aktualisiert werden.' + redirect_to group_orders_url, :alert => I18n.t('group_orders.update.error_stale') rescue => exception logger.error('Failed to update order: ' + exception.message) - redirect_to group_orders_url, :alert => 'Die Bestellung konnte nicht aktualisiert werden, da ein Fehler auftrat.' + redirect_to group_orders_url, :alert => I18n.t('group_orders.update.error_general') end end @@ -69,7 +69,7 @@ class GroupOrdersController < ApplicationController def ensure_ordergroup_member @ordergroup = @current_user.ordergroup if @ordergroup.nil? - redirect_to root_url, :alert => "Du bist kein Mitglieder einer Bestellgruppe." + redirect_to root_url, :alert => I18n.t('group_orders.errors.no_member') end end @@ -77,7 +77,7 @@ class GroupOrdersController < ApplicationController @order = Order.find((params[:order_id] || params[:group_order][:order_id]), :include => [:supplier, :order_articles]) unless @order.open? - flash[:notice] = 'Diese Bestellung ist bereits abgeschlossen.' + flash[:notice] = I18n.t('group_orders.error_closed') redirect_to :action => 'index' end end @@ -85,7 +85,7 @@ class GroupOrdersController < ApplicationController def ensure_my_group_order @group_order = @ordergroup.group_orders.find(params[:id]) rescue ActiveRecord::RecordNotFound - redirect_to group_orders_url, alert: 'Fehlerhafte URL, das ist nicht Deine Bestellung.' + redirect_to group_orders_url, alert: I18n.t('group_orders.errors.notfound') end def enough_apples? diff --git a/app/views/group_orders/_form.html.haml b/app/views/group_orders/_form.html.haml index b1103462..50ec8312 100644 --- a/app/views/group_orders/_form.html.haml +++ b/app/views/group_orders/_form.html.haml @@ -8,29 +8,29 @@ setStockit(#{@order.stockit?}); }); -- title "Bestellen", false +- title t('.title'), false .row-fluid .well.pull-left %h2= @order.name %dl.dl-horizontal - unless @order.note.blank? - %dt Notiz + %dt= t '.note' %dd= @order.note - %dt Erstellt von + %dt= t '.created_by' %dd= link_to_user_message_if_valid(@order.created_by) - %dt Ende + %dt= t '.ending' %dd= format_time(@order.ends) - unless @order.stockit? or @order.supplier.min_order_quantity.blank? - %dt Mindestbestellmenge + %dt= t '.min_quantity' %dd= @order.supplier.min_order_quantity - %dt Gesamtbestellmenge bisher: + %dt= t '.sum_amount' %dd= number_to_currency @order.sum - %dt Zuletzt bestellt + %dt= t '.last_update' %dd = @group_order.updated_by.nick if @group_order.updated_by (#{format_time(@group_order.updated_on)}) - %dt Guthaben + %dt= t '.funds' %dd= number_to_currency(@ordering_data[:available_funds]) .well.pull-right @@ -44,18 +44,18 @@ %table.table.table-hover %thead %tr - %th Name + %th= t '.name' %th{style: "width:13px;"} - %th{style: "width:4.5em;"} Preis - %th{style: "width:4.5em;"} Einheit + %th{style: "width:4.5em;"}= t '.price' + %th{style: "width:4.5em;"}= t '.unit' - unless @order.stockit? - %th{style: "width:70px;"} Fehlende Einheiten - %th#col_required Menge - %th#col_tolerance Toleranz + %th{style: "width:70px;"}= t '.unit_missing' + %th#col_required= t '.amount' + %th#col_tolerance= t '.tolerance' - else - %th(style="width:20px") Verfügbar - %th#col_required Menge - %th{style: "width:15px;"} Summe + %th(style="width:20px")= t '.available' + %th#col_required= t '.amount' + %th{style: "width:15px;"}= t '.sum' %tbody - @order.articles_grouped_by_category.each do |category, order_articles| %tr.article-category @@ -98,42 +98,42 @@ .article-info .article-name= order_article.article.name .pull-right - Volle Gebinde: + = t('.units_full') + ':' %span{id: "units_#{order_article.id}"}= order_article.units_to_order %br/ - Gesamt-Einheiten: + = t('.units_total') + ':' %span{id: "q_total_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:quantity] + @ordering_data[:order_articles][order_article.id][:others_quantity] %br/ - Gesamt-Toleranz: + = t('.total_tolerance') + ':' %span{id: "t_total_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:tolerance] + @ordering_data[:order_articles][order_article.id][:others_tolerance] %br/ .pull-left - Hersteller: #{order_article.article.manufacturer} + #{t '.manufacturer'}: #{order_article.article.manufacturer} %br/ - Gebinde: #{@order.stockit? ? order_article.article.quantity_available : @ordering_data[:order_articles][order_article.id][:unit]} * #{h order_article.article.unit} + #{t '.units'}: #{@order.stockit? ? order_article.article.quantity_available : @ordering_data[:order_articles][order_article.id][:unit]} * #{h order_article.article.unit} %br/ - Notiz: #{order_article.article.note} + #{t '.note'}: #{order_article.article.note} %br/ #order-footer #info-box #total-sum %table %tr - %td Gesamtbetrag: + %td= t('.total_sum_amount') + ':' %td.currency %span#total_price= @group_order.price € %tr - %td Verfügbares Guthaben: + %td= t('.available_funds') + ':' %td.currency= number_to_currency(@ordering_data[:available_funds]) %tr - %td Neuer Kontostand: + %td= t('.new_funds') + ':' %td.currency %strong %span#new_balance= @ordering_data[:available_funds] - @group_order.price € #order-button - = submit_tag( "Bestellung speichern", id: 'submit_button', class: 'btn btn-primary' ) - oder #{link_to "abbrechen", group_orders_path} + = submit_tag( t('.action_save'), id: 'submit_button', class: 'btn btn-primary' ) + oder #{link_to t('.cancel'), group_orders_path} %input#total_balance{name: "total_balance", type: "hidden", value: @ordergroup.account_balance - @group_order.price}/ - %input{name: "version", type: "hidden", value: @version}/ \ No newline at end of file + %input{name: "version", type: "hidden", value: @version}/ diff --git a/app/views/group_orders/_orders.html.haml b/app/views/group_orders/_orders.html.haml index 435841de..f3137588 100644 --- a/app/views/group_orders/_orders.html.haml +++ b/app/views/group_orders/_orders.html.haml @@ -1,9 +1,9 @@ %table.table.table-striped %thead %tr - %th Lieferantin - %th Ende - %th Summe + %th= t '.supplier' + %th= t '.ending' + %th= t '.sum' %tbody - for order in orders - group_order = order.group_order(@ordergroup) # Get GroupOrder if possible @@ -13,4 +13,4 @@ %td= format_time(order.ends) %td.numeric= group_order ? number_to_currency(group_order.price) : "--" - if pagination - = pagination_links_remote @closed_orders \ No newline at end of file + = pagination_links_remote @closed_orders diff --git a/app/views/group_orders/_switch_order.html.haml b/app/views/group_orders/_switch_order.html.haml index e63b4aea..efa6e2b3 100644 --- a/app/views/group_orders/_switch_order.html.haml +++ b/app/views/group_orders/_switch_order.html.haml @@ -1,9 +1,9 @@ - orders = Order.open.reject{ |order| order == current_order } - unless orders.empty? - %h2 Laufende Bestellungen + %h2= t '.title' %ul.unstyled - orders.each do |order| %li = link_to_ordering(order, 'data-confirm_switch_order' => true) - if order.ends - noch #{time_ago_in_words(order.ends)} \ No newline at end of file + = t '.remaining', remaining: time_ago_in_words(order.ends) diff --git a/app/views/group_orders/archive.html.haml b/app/views/group_orders/archive.html.haml index 42b10f3a..6dc020f0 100644 --- a/app/views/group_orders/archive.html.haml +++ b/app/views/group_orders/archive.html.haml @@ -1,14 +1,13 @@ -- title "Bestellungen der #{@ordergroup.name}" +- title t('.title', group: @ordergroup.name) %p - Siehe hier alle - = link_to "laufenden Bestellungen.", group_orders_path += t('.desc', link: link_to(t('.open_orders'), group_orders_path)).html_safe .row-fluid .span6 - %h2 beendet/nicht abgerechnet + %h2= t '.title_open' = render :partial => "orders", :locals => {:orders => Order.finished_not_closed, :pagination => false} .span6 - %h2 abgerechnet + %h2= t '.title_closed' #closed_orders = render :partial => "orders", :locals => {:orders => @closed_orders, :pagination => true} diff --git a/app/views/group_orders/index.html.haml b/app/views/group_orders/index.html.haml index 49e3dd79..20f31b2f 100644 --- a/app/views/group_orders/index.html.haml +++ b/app/views/group_orders/index.html.haml @@ -1,21 +1,21 @@ -- title "Bestellüberblick", false +- title t('.title'), false - content_for :sidebar do .well.well-small // Ordergroups Account Balance - %h2 Guthaben + %h2= t '.funds.title' %table.table.table-striped %tr - %td Kontostand: + %td= t('.funds.account_balance') + ':' %td.numeric{:style => "width:5em"}= number_to_currency(@ordergroup.account_balance) %tr - %td - laufende Bestellungen: + %td= '- ' + t('.funds.open_orders') + ':' %td.numeric= number_to_currency(@ordergroup.value_of_open_orders) %tr - %td= "- nicht abgerechnete Bestellungen:" + %td= '- ' + t('.funds.finished_orders') + ':' %td.numeric= number_to_currency(@ordergroup.value_of_finished_orders) %tr - %th verfügbares Guthaben: + %th= t('.funds.available_funds') + ':' %th.numeric= number_to_currency(@ordergroup.get_available_funds) = render :partial => "shared/open_orders", :locals => {:ordergroup => @ordergroup} @@ -23,17 +23,17 @@ // finished orders - unless Order.finished.empty? %section - %h2 Nicht abgerechnete Bestellungen + %h2= t '.finished_orders.title' = render :partial => "orders", :locals => {:orders => Order.finished_not_closed, :pagination => false} - if @ordergroup.value_of_finished_orders > 0 %p - Gesamtsumme: + = t('.finished_orders.total_sum') + ':' %b= number_to_currency(@ordergroup.value_of_finished_orders) // closed orders - unless Order.closed.empty? %section - %h2 Abgerechnete Bestellungen + %h2= t '.closed_orders.title' = render :partial => "orders", :locals => {:orders => Order.closed.all(:limit => 5), :pagination => false} %br/ - = link_to "mehr...", archive_group_orders_path \ No newline at end of file + = link_to t('.closed_orders.more'), archive_group_orders_path diff --git a/app/views/group_orders/order.html.haml b/app/views/group_orders/order.html.haml index cc0b89b6..0d2f8c5a 100644 --- a/app/views/group_orders/order.html.haml +++ b/app/views/group_orders/order.html.haml @@ -6,20 +6,20 @@ - form_tag(:action => 'saveOrder', :id => @order) do .single_column{:style => "clear:both;margin-bottom:7em;"} .box_title - %h2 Artikel + %h2= t '.title' .column_content %table#order.list %thead %tr - %th Name + %th= t 'group_orders.form.name' %th{:style => "width:13px;"} - %th{:style => "width:4.5em;"} Preis - %th{:style => "width:4.5em;"} Einheit - %th{:style => "width:70px;"} Fehlende Einheiten - %th#col_required Menge + %th{:style => "width:4.5em;"}= t 'group_orders.form.price' + %th{:style => "width:4.5em;"}= t 'group_orders.form.unit' + %th{:style => "width:70px;"}= t 'group_orders.form.unit_missing' + %th#col_required= t 'group_orders.form.amount' - if not @order.stockit? - %th#col_tolerance Toleranz - %th{:style => "width:15px;"} Summe + %th#col_tolerance= t 'group_orders.form.tolerance' + %th{:style => "width:15px;"}= t 'group_orders.form.sum' %tbody - total = 0 - i = 0 @@ -68,21 +68,21 @@ .article-info %h3= order_article.article.name .right - Volle Gebinde: + = t('group_orders.form.units_full') + ':' %span{:id => "units_#{i}"}= order_article.units_to_order %br/ - Gesamt-Einheiten: + = t('group_orders.form.total_units') + ':' %span{:id => "q_total_#{i}"}= @quantity[i] + @others_quantity[i] %br/ - Gesamt-Toleranz: + = t('group_orders.form.total_tolerance') + ':' %span{:id => "t_total_#{i}"}= @tolerance[i] + @others_tolerance[i] %br/ .left - Hersteller: #{order_article.article.manufacturer} + #{t 'group_orders.form.manufacturer'}: #{order_article.article.manufacturer} %br/ - Gebinde: #{@order.stockit? ? order_article.article.quantity_available : @unit[i]} * #{h order_article.article.unit} + #{t 'group_orders.form.units'}: #{@order.stockit? ? order_article.article.quantity_available : @unit[i]} * #{h order_article.article.unit} %br/ - Notiz: #{order_article.article.note} + #{t 'group_orders.form.note'}: #{order_article.article.note} %br/ - i = i + 1 - = render "order_footer", :total => total \ No newline at end of file + = render "order_footer", :total => total diff --git a/app/views/group_orders/show.html.haml b/app/views/group_orders/show.html.haml index 10b93c7c..32147654 100644 --- a/app/views/group_orders/show.html.haml +++ b/app/views/group_orders/show.html.haml @@ -4,48 +4,49 @@ $('tr.ignored').hide(); }); -- title "Dein Bestellergebnis für #{@order.name}" +- title t('.title', order: @order.name) .well // Order summary %dl.dl-horizontal - %dt Lieferantin + %dt= t '.supplier' %dd= @order.name - %dt Notiz + %dt= t '.note' %dd= @order.note - %dt Ende + %dt= t '.ending' %dd= format_time(@order.ends) - %dt Bestellsumme + %dt= t '.order_sum' %dd - if @group_order = number_to_currency(@group_order.price) - else - Du hast nicht bestellt. + = t '.not_ordered' - if @order.closed? - %p Abgerechnet von #{@order.updated_by.nick} - = link_to "Kommentare lesen/schreiben", "#comments" + %p= t '.closed_by', user: @order.updated_by.nick + = link_to t('.comment'), "#comments" // Article box %section - %h2 Artikelübersicht + %h2= t '.articles.title' .column_content#result - if @group_order - %p.pull-right= link_to "Zeige/Verstecke nicht bestellte Artikel", '#', 'data-toggle-this' => 'tr.ignored' - %p= link_to("Bestellung anpassen", edit_group_order_path(@group_order, order_id: @order.id), class: 'btn btn-primary') if @order.open? + %p.pull-right= link_to t('.articles.show_hide'), '#', 'data-toggle-this' => 'tr.ignored' + %p= link_to(t('.articles.edit_order'), edit_group_order_path(@group_order, order_id: @order.id), class: 'btn btn-primary') if @order.open? %table.table.table-hover %thead %tr - %th{style: "width:40%"} Name - %th Gebinde - %th Einzelpreis + %th{style: "width:40%"}= t '.articles.name' + %th= t '.articles.units' + %th= t '.articles.unit_price' %th - %abbr{title: "Menge + Toleranz"} Bestellt + %abbr{title: t('.articles.ordered_title')}= t '.articles.ordered' %th - %abbr{title: "Unter Berücksichtigung der derzeitigen Bestellungen aller Gruppen"} + %abbr{title: t('.articles.order_nopen_title')} - if @order.open? - Zu - Erhalten - %th Gesamtpreis + = t '.articles.order_open' + - else + = t '.articles.order_not_open' + %th= t '.articles.total_price' %tbody - total = 0 #set counter for order-sum - for category_name, order_articles in @order.articles_grouped_by_category @@ -73,20 +74,20 @@ %tr{id: "note_#{oa.id}", class: "note even", style: "display:none"} %td{colspan: "6"}=h oa.article.note %tr{class: cycle('even', 'odd', name: 'articles')} - %th{colspan: "5"} Summe + %th{colspan: "5"}= t '.articles.sum' %th= number_to_currency(total) %br/ = link_to_top - else - if @order.open? - Du hast noch nicht bestellt. - = link_to "Das ist Deine Chance!", action: "order", id: @order + = t '.articles.not_ordered_msg' + = link_to t('.articles.order_now'), action: "order", id: @order - else - Die Bestellung is leider schon zu Ende. Beim nächsten mal früher aufstehen... + = t '.articles.order_closed_msg' // Comments box %section - %h2 Kommentare + %h2= t '.comments.title' #comments = render 'shared/comments', comments: @order.comments #new_comment= render 'order_comments/form', order_comment: @order.comments.build(user: current_user) diff --git a/config/locales/de/de.group_orders.yml b/config/locales/de/de.group_orders.yml new file mode 100644 index 00000000..2e63edab --- /dev/null +++ b/config/locales/de/de.group_orders.yml @@ -0,0 +1,98 @@ +de: + group_orders: + archive: + title: 'Bestellungen der %{group}' + desc: 'Siehe hier alle %{link}.' + open_orders: 'laufenden Bestellungen' + title_open: 'beendet/nicht abgerechnet' + title_closed: 'abgerechnet' + form: + title: 'Bestellen' + note: 'Notiz' + created_by: 'Erstellt von' + ending: 'Ende' + min_quantity: 'Mindestbestellmenge' + sum_amount: 'Gesamtbestellmenge bisher:' + last_update: 'Zuletzt bestellt' + funds: 'Guthaben' + name: 'Name' + price: 'Preis' + unit: 'Einheit' + unit_missing: 'Fehlende Einheiten' + amount: 'Menge' + tolerance: 'Toleranz' + available: 'Verfügbar' + sum: 'Summe' + units: 'Gebinde' + units_full: 'Volle Gebinde' + total_units: 'Gesamt-Einheiten' + total_tolerance: 'Gesamt-Toleranz' + manufacturer: 'Hersteller' + total_sum_amount: 'Gesamtbetrag' + available_funds: 'Verfügbares Guthaben' + new_funds: 'Neuer Kontostand' + action_save: 'Bestellung speichern' + cancel: 'abbrechen' + index: + title: 'Bestellüberblick' + funds: + title: 'Guthaben' + account_balance: 'Kontostand' + open_orders: 'laufende Bestellungen' + finished_orders: 'nicht abgerechnete Bestellungen' + available_funds: 'verfügbares Guthaben' + finished_orders: + title: 'Nicht abgerechnete Bestellungen' + total_sum: 'Gesamtsumme' + closed_orders: + title: 'Abgerechnete Bestellungen' + more: 'mehr...' + order: + title: 'Artikel' + # other fields reference group_orders.form + orders: &orders + supplier: 'Lieferantin' + ending: 'Ende' + sum: 'Summe' + show: + <<: *orders + title: 'Dein Bestellergebnis für %{order}' + note: 'Notiz' + order_sum: 'Bestellsumme' + not_ordered: 'Du hast nicht bestellt.' + closed_by: 'Abgerechnet von %{user}' + comment: 'Kommentare lesen/schreiben' + articles: + title: 'Artikelübersicht' + show_hide: 'Zeige/Verstecke nicht bestellte Artikel' + edit_order: 'Bestellung anpassen' + name: 'Name' + units: 'Gebinde' + unit_price: 'Einzelpreis' + ordered: 'Bestellt' + ordered_title: 'Menge + Toleranz' + order_open: 'Zu Erhalten' + order_not_open: 'Erhalten' + order_nopen_title: 'Unter Berücksichtigung der derzeitigen Bestellungen aller Gruppen' + total_price: 'Gesamtpreis' + sum: 'Summe' + not_ordered_msg: 'Du hast noch nicht bestellt' + order_now: 'Das ist Deine Chance!' + order_closed_msg: 'Die Bestellung is leider schon zu Ende. Beim nächsten mal früher aufstehen...' + comments: + title: 'Kommentare' + switch_order: + title: 'Laufende Bestellungen' + remaining: 'noch %{remaining}' + + # used by controller + create: &create + notice: 'Die Bestellung wurde gespeichert.' + error_stale: 'In der Zwischenzeit hat jemand anderes auch bestellt, daher konnte die Bestellung nicht aktualisiert werden.' + error_general: 'Die Bestellung konnte nicht aktualisiert werden, da ein Fehler auftrat.' + update: + <<: *create + errors: + no_member: 'Du bist kein Mitglieder einer Bestellgruppe.' + closed: 'Diese Bestellung ist bereits abgeschlossen.' + notfound: 'Fehlerhafte URL, das ist nicht Deine Bestellung.'