Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

fix(i18n): localize account creation keyboard controls (#3433)

Thomas Steibl852515833f35
diff --git a/app/views/accounts/new/_container.html.erb b/app/views/accounts/new/_container.html.erb
index 594eee67ef..db637cea14 100644
--- a/app/views/accounts/new/_container.html.erb
+++ b/app/views/accounts/new/_container.html.erb
@@ -20,8 +20,8 @@
</div>
<div class="p-2 text-subdued">
- <button hidden data-controller="hotkey" data-hotkey="k,K,ArrowUp,ArrowLeft" data-action="list-keyboard-navigation#focusPrevious">Previous</button>
- <button hidden data-controller="hotkey" data-hotkey="j,J,ArrowDown,ArrowRight" data-action="list-keyboard-navigation#focusNext">Next</button>
+ <button hidden data-controller="hotkey" data-hotkey="k,K,ArrowUp,ArrowLeft" data-action="list-keyboard-navigation#focusPrevious"><%= t(".previous") %></button>
+ <button hidden data-controller="hotkey" data-hotkey="j,J,ArrowDown,ArrowRight" data-action="list-keyboard-navigation#focusNext"><%= t(".next") %></button>
<%= yield %>
</div>
diff --git a/config/locales/views/accounts/de.yml b/config/locales/views/accounts/de.yml
index 08d40d09b7..db85eb6bce 100644
--- a/config/locales/views/accounts/de.yml
+++ b/config/locales/views/accounts/de.yml
@@ -70,6 +70,8 @@ de:
container:
close: Schließen
navigate: Navigieren
+ next: Weiter
+ previous: Zurück
select: Auswählen
show:
activity:
diff --git a/config/locales/views/accounts/en.yml b/config/locales/views/accounts/en.yml
index c5433efe76..51d289c992 100644
--- a/config/locales/views/accounts/en.yml
+++ b/config/locales/views/accounts/en.yml
@@ -68,6 +68,8 @@ en:
select: Select
navigate: Navigate
close: Close
+ next: Next
+ previous: Previous
method_selector:
connected_entry: Link account
connected_entry_eu: Link EU account
diff --git a/test/controllers/accounts_new_localization_test.rb b/test/controllers/accounts_new_localization_test.rb
new file mode 100644
index 0000000000..89d5e4c005
--- /dev/null
+++ b/test/controllers/accounts_new_localization_test.rb
@@ -0,0 +1,46 @@
+require "test_helper"
+
+class AccountsNewLocalizationTest < ActiveSupport::TestCase
+ TRANSLATIONS = {
+ "previous" => "Zurück",
+ "next" => "Weiter"
+ }.freeze
+
+ test "German account container keyboard labels resolve without fallback" do
+ TRANSLATIONS.each do |key, expected|
+ full_key = "accounts.new.container.#{key}"
+
+ assert I18n.exists?(full_key, :de, fallback: false), "de is missing #{full_key}"
+ assert_equal expected, I18n.t(full_key, locale: :de, fallback: false)
+ end
+ end
+end
+
+class AccountsNewLocalizationRenderTest < ActionDispatch::IntegrationTest
+ setup do
+ ensure_tailwind_build
+ sign_in @user = users(:family_admin)
+ end
+
+ test "German account creation renders localized keyboard controls" do
+ @user.update!(locale: "de")
+
+ get new_account_url
+
+ assert_response :success
+ assert_select "button[data-action='list-keyboard-navigation#focusPrevious']", text: "Zurück", count: 1
+ assert_select "button[data-action='list-keyboard-navigation#focusNext']", text: "Weiter", count: 1
+ assert_no_match(/>Previous</, response.body)
+ assert_no_match(/>Next</, response.body)
+ end
+
+ test "English account creation preserves the keyboard controls" do
+ @user.update!(locale: "en")
+
+ get new_account_url
+
+ assert_response :success
+ assert_select "button[data-action='list-keyboard-navigation#focusPrevious']", text: "Previous", count: 1
+ assert_select "button[data-action='list-keyboard-navigation#focusNext']", text: "Next", count: 1
+ end
+end
diff --git a/test/controllers/wise_sca_localization_test.rb b/test/controllers/wise_sca_localization_test.rb
index 8c30a9ed23..482f889ed2 100644
--- a/test/controllers/wise_sca_localization_test.rb
+++ b/test/controllers/wise_sca_localization_test.rb
@@ -72,6 +72,7 @@ class WiseScaPanelLocalizationTest < ActionDispatch::IntegrationTest
# no encryption keys, so the flow has to be exercised as an install that does.
test "German Wise SCA keypair generation returns the localized success message" do
WiseItem.stubs(:encryption_ready?).returns(true)
+ WiseItem.any_instance.expects(:generate_sca_keypair!).once.returns("SYNTHETIC PUBLIC KEY")
post generate_sca_keypair_wise_item_url(wise_items(:one))