The personal finance app for everyone (by everyone)
Ruby
fix(i18n): localize trade activity labels (U4) (#3282)
Thomas Steiblf66053f83c77
diff --git a/config/locales/views/trades/de.yml b/config/locales/views/trades/de.ymlindex bbb996b305..17b616d6cd 100644--- a/config/locales/views/trades/de.yml+++ b/config/locales/views/trades/de.yml@@ -26,6 +26,15 @@ de:sell: Verkaufendividend: Dividendeinterest: Zinsen+ contribution: Einlage+ exchange: Umtausch+ fee: Gebühr+ other: Sonstige+ reinvestment: Reinvestition+ sweep_in: Sweep In+ sweep_out: Sweep Out+ transfer: Überweisung+ withdrawal: Entnahmecurrent_market_price_label: Aktueller Marktpreisoverview: Übersichtpurchase_price_label: Kaufpreisdiff --git a/test/controllers/trades_controller_test.rb b/test/controllers/trades_controller_test.rbindex 775cb305b8..e2f5e2c86b 100644--- a/test/controllers/trades_controller_test.rb+++ b/test/controllers/trades_controller_test.rb@@ -23,6 +23,42 @@ class TradesControllerTest < ActionDispatch::IntegrationTestassert_select "span.text-secondary.text-sm", text: I18n.t("trades.header.buy"), count: 0end+ test "the German header localizes supported provider activity labels" do+ @user.update!(locale: "de")++ translations = {+ "Buy" => "Kaufen",+ "Contribution" => "Einlage",+ "Dividend" => "Dividende",+ "Exchange" => "Umtausch",+ "Fee" => "Gebühr",+ "Interest" => "Zinsen",+ "Other" => "Sonstige",+ "Reinvestment" => "Reinvestition",+ "Sell" => "Verkaufen",+ "Sweep In" => "Sweep In",+ "Sweep Out" => "Sweep Out",+ "Transfer" => "Überweisung",+ "Withdrawal" => "Entnahme"+ }++ assert_equal Trade::ACTIVITY_LABELS.sort, translations.keys.sort++ translations.each do |activity_label, translation|+ key = activity_label.parameterize(separator: "_")++ assert_equal translation,+ I18n.t("trades.header.#{key}", locale: :de, fallback: false, default: nil)++ @entry.trade.update!(investment_activity_label: activity_label)++ get trade_url(@entry)++ assert_response :success+ assert_select "span.text-secondary.text-sm", text: translation+ end+ end+test "an unlabelled trade still reads from the amount" do@entry.trade.update!(investment_activity_label: nil)