The personal finance app for everyone (by everyone)
Ruby
fix(i18n): localize onchain wallet movement names (#3388)
Thomas Steiblbca1239848f4
diff --git a/app/models/onchain_wallet_account/processor.rb b/app/models/onchain_wallet_account/processor.rbindex 5358411daa..1fcf6c0907 100644--- a/app/models/onchain_wallet_account/processor.rb+++ b/app/models/onchain_wallet_account/processor.rb@@ -357,8 +357,11 @@ class OnchainWalletAccount::Processorenddef translated_name(key, quantity)+ # Entry names persist across request- and scheduler-triggered syncs, so+ # they must not depend on whichever locale happened to enqueue the job.I18n.t(key,+ locale: onchain_wallet_account.onchain_wallet_item.family.locale,quantity: quantity.abs.round(8).to_s("F"),symbol: onchain_wallet_account.symbol)diff --git a/config/locales/models/onchain_wallet_item/de.yml b/config/locales/models/onchain_wallet_item/de.ymlnew file mode 100644index 0000000000..2b6319224e--- /dev/null+++ b/config/locales/models/onchain_wallet_item/de.yml@@ -0,0 +1,6 @@+---+de:+ onchain_wallet_item:+ movement:+ received: "Eingang: %{quantity} %{symbol}"+ sent: "Ausgang: %{quantity} %{symbol}"diff --git a/test/models/onchain_wallet_account/processor_test.rb b/test/models/onchain_wallet_account/processor_test.rbindex 9bbfd12746..4bab6fc231 100644--- a/test/models/onchain_wallet_account/processor_test.rb+++ b/test/models/onchain_wallet_account/processor_test.rb@@ -122,6 +122,38 @@ class OnchainWalletAccount::ProcessorTest < ActiveSupport::TestCaseassert_equal "Sent 1.0 FAKE", entry.nameend+ test "localizes wallet movement names in German" do+ date = 3.days.ago.to_date+ @family.update!(locale: "de")+ price_asset_at(date, 50)+ store_movements(+ fake_movement(external_id: "received", amount: "1.5", timestamp: date),+ fake_movement(external_id: "sent", amount: "-1", timestamp: date)+ )++ I18n.with_locale(:en) do+ OnchainWalletAccount::Processor.new(@onchain_account).process+ end++ received = @account.entries.find_by!(external_id: "onchain_#{@onchain_account.id}_received")+ sent = @account.entries.find_by!(external_id: "onchain_#{@onchain_account.id}_sent")++ assert_equal "Eingang: 1.5 FAKE", received.name+ assert_equal "Ausgang: 1.0 FAKE", sent.name++ received.update!(name: "Received 1.5 FAKE")+ received.entryable.update!(investment_activity_label: "Buy")++ I18n.with_locale(:en) do+ assert_equal 1, OnchainWalletAccount::Processor.new(@onchain_account).repair_display_only_movements+ end++ assert_equal "Eingang: 1.5 FAKE", received.reload.name+ assert_equal "Ausgang: 1.0 FAKE", sent.reload.name+ assert I18n.exists?("onchain_wallet_item.movement.received", :de, fallback: false)+ assert I18n.exists?("onchain_wallet_item.movement.sent", :de, fallback: false)+ end+test "materializes a display-only excluded entry when that day's price is unknown" dodate = 3.days.ago.to_datestore_movements(fake_movement(external_id: "tx3", amount: "1.5", timestamp: date))