From 640e9799aaaf9ad957da836d49ee527b8cd554c4 Mon Sep 17 00:00:00 2001 From: Manuel Wiedenmann Date: Mon, 11 Feb 2013 09:57:33 +0700 Subject: [PATCH] i18n financial_transactions + controller --- .../financial_transactions_controller.rb | 6 ++-- .../financial_transactions/_ordergroup.haml | 2 +- .../_transactions.html.haml | 8 ++--- .../financial_transactions/index.html.haml | 10 +++--- .../financial_transactions/new.html.haml | 6 ++-- .../new_collection.html.haml | 18 +++++----- config/locales/de/de.finance.yml | 36 ++++++++++++++++++- 7 files changed, 59 insertions(+), 27 deletions(-) diff --git a/app/controllers/finance/financial_transactions_controller.rb b/app/controllers/finance/financial_transactions_controller.rb index cacf55eb..a129a49d 100644 --- a/app/controllers/finance/financial_transactions_controller.rb +++ b/app/controllers/finance/financial_transactions_controller.rb @@ -34,7 +34,7 @@ class Finance::FinancialTransactionsController < ApplicationController @financial_transaction = FinancialTransaction.new(params[:financial_transaction]) @financial_transaction.user = current_user @financial_transaction.add_transaction! - redirect_to finance_ordergroup_transactions_url(@ordergroup), :notice => "Die Transaktion wurde gespeichert." + redirect_to finance_ordergroup_transactions_url(@ordergroup), notice: t('finance.financial_transactions.create.notice') rescue ActiveRecord::RecordInvalid => error flash.now[:alert] = error.message render :action => :new @@ -51,9 +51,9 @@ class Finance::FinancialTransactionsController < ApplicationController Ordergroup.find(trans[:ordergroup_id]).add_financial_transaction!(trans[:amount], params[:note], @current_user) end end - redirect_to finance_ordergroups_url, notice: "Alle Transaktionen wurden gespeichert." + redirect_to finance_ordergroups_url, notice: t('finance.create_collection.create.notice') rescue => error - redirect_to finance_new_transaction_collection_url, alert: "Ein Fehler ist aufgetreten: " + error.to_s + redirect_to finance_new_transaction_collection_url, alert: t('finance.create_collection.create.alert', error: error.to_s) end protected diff --git a/app/views/finance/financial_transactions/_ordergroup.haml b/app/views/finance/financial_transactions/_ordergroup.haml index 50bdd9b1..c2595c61 100644 --- a/app/views/finance/financial_transactions/_ordergroup.haml +++ b/app/views/finance/financial_transactions/_ordergroup.haml @@ -3,5 +3,5 @@ = select_tag 'financial_transactions[][ordergroup_id]', options_for_select(Ordergroup.order(:name).all.map { |g| [ g.name, g.id ] }) %td= text_field_tag 'financial_transactions[][amount]', nil, class: 'input-small' - %td= link_to "Entfernen", "#", :title => "Gruppe enfernen", 'data-remove-transaction' => true, + %td= link_to t('.remove'), "#", :title => t('.remove_group'), 'data-remove-transaction' => true, class: 'btn btn-small' \ No newline at end of file diff --git a/app/views/finance/financial_transactions/_transactions.html.haml b/app/views/finance/financial_transactions/_transactions.html.haml index 2d6d03e7..35c4e07f 100644 --- a/app/views/finance/financial_transactions/_transactions.html.haml +++ b/app/views/finance/financial_transactions/_transactions.html.haml @@ -4,10 +4,10 @@ %table.table.table-striped %thead %tr - %td= sort_link_helper "Datum", "date" - %td Wer - %td= sort_link_helper "Notiz", "note" - %td= sort_link_helper "Betrag", "amount" + %td= sort_link_helper t('.date'), "date" + %td= t('.who') + %td= sort_link_helper t('.note'), "note" + %td= sort_link_helper t('amount'), "amount" %tbody - @financial_transactions.each do |t| %tr diff --git a/app/views/finance/financial_transactions/index.html.haml b/app/views/finance/financial_transactions/index.html.haml index 258e85d0..7de3526a 100644 --- a/app/views/finance/financial_transactions/index.html.haml +++ b/app/views/finance/financial_transactions/index.html.haml @@ -1,18 +1,18 @@ -- title "Kontoauszug für #{@ordergroup.name}" +- title t('.title', name: @ordergroup.name) - content_for :actionbar do - = link_to 'Neue Transaktion anlegen', new_finance_ordergroup_transaction_path(@ordergroup), class: 'btn btn-primary' + = link_to t('.new_transaction'), new_finance_ordergroup_transaction_path(@ordergroup), class: 'btn btn-primary' - content_for :sidebar do .well.well-small - %strong Kontostand: #{number_to_currency(@ordergroup.account_balance)} + %strong= t('.balance', balance: number_to_currency(@ordergroup.account_balance)) %br/ - %small (zuletzt aktualisiert vor #{distance_of_time_in_words(Time.now, @ordergroup.account_updated)}) + %small= t('.last_updated_at', when: distance_of_time_in_words(Time.now, @ordergroup.account_updated)) .well.well-small = form_tag finance_ordergroup_transactions_path(@ordergroup), :method => :get, :remote => true, 'data-submit-onchange' => true, class: 'form-search' do = text_field_tag :query, params[:query], class: 'input-medium search-query', - placeholder: 'Suchen ...' + placeholder: t('.search_placeholder') #transactions= render 'transactions' \ No newline at end of file diff --git a/app/views/finance/financial_transactions/new.html.haml b/app/views/finance/financial_transactions/new.html.haml index 459669d1..1fd96222 100644 --- a/app/views/finance/financial_transactions/new.html.haml +++ b/app/views/finance/financial_transactions/new.html.haml @@ -1,6 +1,6 @@ -- title "Neue Transaktion" +- title t('.title') -%p Hier kannst du der Bestellgruppe #{@ordergroup.name} Geld gutschreiben/abziehen. +%p!= t('.paragraph', name: @ordergroup.name) = simple_form_for @financial_transaction, :url => finance_ordergroup_transactions_path(@ordergroup), :validate => true do |f| @@ -9,4 +9,4 @@ = f.input :note, :as => :text .form-actions = f.submit class: 'btn btn-primary' - = link_to "oder abbrechen", finance_ordergroup_transactions_path(@ordergroup) \ No newline at end of file + = link_to t('.or_cancel'), finance_ordergroup_transactions_path(@ordergroup) \ No newline at end of file diff --git a/app/views/finance/financial_transactions/new_collection.html.haml b/app/views/finance/financial_transactions/new_collection.html.haml index 37d6dfeb..02814005 100644 --- a/app/views/finance/financial_transactions/new_collection.html.haml +++ b/app/views/finance/financial_transactions/new_collection.html.haml @@ -1,4 +1,4 @@ -- title "Mehrere Konten aktualisieren" +- title t('.title') - content_for :javascript do :javascript @@ -17,22 +17,20 @@ }); - content_for :sidebar do - .well.well-small - Hier kannst Du mehrere Konten gleichzeitig aktualsieren. - Z.B. alle Überweisungen der Bestellgruppen aus einem Kontoauszug. + .well.well-small= t('.sidebar') = form_tag finance_create_transaction_collection_path do %p - %b Notiz + %b= t('.note') = text_field_tag :note, params[:note], class: 'input-xlarge', required: 'required' %p %table#ordergroups{:style => "width:20em"} %tr - %th Bestellgruppe - %th Betrag + %th= t('.ordergroup') + %th= t('.amount') = render :partial => 'ordergroup', :collection => [1, 2, 3] %p - = link_to "Weitere Bestellgruppe hinzufügen", '#', 'data-add-transaction' => true, class: 'btn' + = link_to t('.new_ordergroup'), '#', 'data-add-transaction' => true, class: 'btn' .form-actions - = submit_tag "Transaktionen speichern", class: 'btn btn-primary' - = link_to "oder abbrechen", finance_ordergroups_path \ No newline at end of file + = submit_tag t('.save'), class: 'btn btn-primary' + = link_to t('.or_cancel'), finance_ordergroups_path \ No newline at end of file diff --git a/config/locales/de/de.finance.yml b/config/locales/de/de.finance.yml index 0b194059..08db7df2 100644 --- a/config/locales/de/de.finance.yml +++ b/config/locales/de/de.finance.yml @@ -95,4 +95,38 @@ de: gross: 'Brutto' tax: 'MwSt' refund: 'Pfand' - add_article: 'Artikel hinzufügen' \ No newline at end of file + add_article: 'Artikel hinzufügen' + financial_transactions: + create: + notice: "Die Transaktion wurde gespeichert." + create_collection: + notice: "Alle Transaktionen wurden gespeichert." + alert: "Ein Fehler ist aufgetreten: %{error}" + ordergroup: + remove: "Entfernen" + remove_group: "Gruppe enfernen" + transactions: + date: "Datum" + who: "Wer" + note: "Notiz" + amount: "Betrag" + index: + title: "Kontoauszug für %{name}" + new_transaction: 'Neue Transaktion anlegen' + balance: 'Kontostand: %{balance}' + last_updated_at: '(zuletzt aktualisiert vor %{when})' + search_placeholder: 'Suchen ...' + new_collection: + title: "Mehrere Konten aktualisieren" + sidebar: 'Hier kannst Du mehrere Konten gleichzeitig aktualsieren. Z.B. alle Überweisungen der Bestellgruppen aus einem Kontoauszug.' + new_ordergroup: 'Weitere Bestellgruppe hinzufügen' + ordergroup: 'Bestellgruppe' + note: 'Notiz' + amount: 'Betrag' + save: "Transaktionen speichern" + or_cancel: 'oder abbrechen' + new: + title: "Neue Transaktion" + paragraph: 'Hier kannst du der Bestellgruppe %{name} Geld gutschreiben/abziehen.' + or_cancel: "oder abbrechen" + \ No newline at end of file