Skip to content

armgit / maybe

Public Imported from GitHub
0

The personal finance app for everyone

Fix translation scope within modals (#404)

Josh Brown80f68b657c93
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 1904451f..e2fe2b8a 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -14,6 +14,7 @@ module ApplicationHelper
# Wrap view with <%= modal do %> ... <% end %> to have it open in a modal
# Make sure to add data-turbo-frame="modal" to the link/button that opens the modal
def modal(&block)
- render "shared/modal", &block
+ content = capture &block
+ render partial: "shared/modal", locals: { content: content }
end
end
diff --git a/app/views/accounts/new.html.erb b/app/views/accounts/new.html.erb
index 23d8e8b7..ea60252f 100644
--- a/app/views/accounts/new.html.erb
+++ b/app/views/accounts/new.html.erb
@@ -3,7 +3,7 @@
<%= modal do %>
<% if params[:type].blank? || Account.accountable_types.include?("Account::#{params[:type]}") == false %>
<div class="border-b border-[#141414]/2 p-4 text-gray-400">
- What would you like to add?
+ <%= t '.select_accountable_type' %>
</div>
<div class="flex flex-col p-2 text-sm" data-controller="list-keyboard-navigation">
<button hidden data-controller="hotkey" data-hotkey="k,K,ArrowUp,ArrowLeft" data-action="list-keyboard-navigation#focusPrevious">Previous</button>
diff --git a/app/views/shared/_modal.html.erb b/app/views/shared/_modal.html.erb
index c274b671..773af70a 100644
--- a/app/views/shared/_modal.html.erb
+++ b/app/views/shared/_modal.html.erb
@@ -1,7 +1,8 @@
+<%# locals: (content:) -%>
<%= turbo_frame_tag "modal" do %>
<dialog class="bg-white border border-[#141414]/25 rounded-2xl max-h-[556px] max-w-[580px] w-full shadow-xs" data-controller="modal" data-action="click->modal#click_outside">
<div class="flex flex-col h-full">
- <%= yield %>
+ <%= content %>
</div>
</dialog>
<% end %>
diff --git a/config/locales/views/account/en.yml b/config/locales/views/account/en.yml
index c97bda51..72c9164c 100644
--- a/config/locales/views/account/en.yml
+++ b/config/locales/views/account/en.yml
@@ -6,4 +6,5 @@ en:
index:
title: Cash
new:
+ select_accountable_type: What would you like to add?
title: Add an account