Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

fix(i18n): localize import step labels (#3322)

Thomas Steibl83c5948823a0
diff --git a/app/views/import/confirms/show.html.erb b/app/views/import/confirms/show.html.erb
index 43afe9e70d..4e4f2ff071 100644
--- a/app/views/import/confirms/show.html.erb
+++ b/app/views/import/confirms/show.html.erb
@@ -57,7 +57,7 @@
<% is_active = step_idx == idx %>
<%= link_to url_for(step: idx + 1), class: "w-5 h-[3px] #{is_active ? 'bg-inverse hover:bg-inverse-hover' : 'bg-surface-inset hover:bg-surface-inset-hover'} rounded-xl transition-colors duration-200" do %>
- <span class="sr-only">Step <%= idx + 1 %></span>
+ <span class="sr-only"><%= t("imports.steps.label", step: idx + 1) %></span>
<% end %>
<% end %>
</div>
diff --git a/config/locales/views/imports/de.yml b/config/locales/views/imports/de.yml
index 63aa25aa15..640c824142 100644
--- a/config/locales/views/imports/de.yml
+++ b/config/locales/views/imports/de.yml
@@ -242,6 +242,7 @@ de:
map: Zuordnen
confirm: Bestätigen
select: Auswählen
+ label: Schritt %{step}
progress: Schritt %{step} von %{total}
index:
title: Importe
diff --git a/config/locales/views/imports/en.yml b/config/locales/views/imports/en.yml
index be16768551..697a2e6cf8 100644
--- a/config/locales/views/imports/en.yml
+++ b/config/locales/views/imports/en.yml
@@ -368,6 +368,7 @@ en:
map: Map
confirm: Confirm
select: Select
+ label: "Step %{step}"
progress: "Step %{step} of %{total}"
empty:
message: No imports found.
diff --git a/test/controllers/import/confirms_controller_test.rb b/test/controllers/import/confirms_controller_test.rb
index 360ea0c6d6..ac5b468cf7 100644
--- a/test/controllers/import/confirms_controller_test.rb
+++ b/test/controllers/import/confirms_controller_test.rb
@@ -3,6 +3,7 @@ require "test_helper"
class Import::ConfirmsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in @user = users(:family_admin)
+ ensure_tailwind_build
end
test "shows if cleaned" do
@@ -14,6 +15,32 @@ class Import::ConfirmsControllerTest < ActionDispatch::IntegrationTest
assert_response :success
end
+ test "localizes mapping step labels in German" do
+ import = imports(:transaction)
+ @user.update!(locale: "de")
+ TransactionImport.any_instance.stubs(:cleaned?).returns(true)
+
+ get import_confirm_path(import)
+
+ assert_response :success
+ assert_select "span.sr-only", text: "Schritt 1", count: 1
+ assert_select "span.sr-only", text: "Schritt 2", count: 1
+ assert_select "span.sr-only", text: "Schritt 3", count: 1
+ end
+
+ test "preserves mapping step labels in English" do
+ import = imports(:transaction)
+ @user.update!(locale: "en")
+ TransactionImport.any_instance.stubs(:cleaned?).returns(true)
+
+ get import_confirm_path(import)
+
+ assert_response :success
+ assert_select "span.sr-only", text: "Step 1", count: 1
+ assert_select "span.sr-only", text: "Step 2", count: 1
+ assert_select "span.sr-only", text: "Step 3", count: 1
+ end
+
test "redirects if not cleaned" do
import = imports(:transaction)