Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

Localization for an accountable group and sidebar (#257)

Albert Solàdfe60fa07d31
diff --git a/app/models/balance_sheet/classification_group.rb b/app/models/balance_sheet/classification_group.rb
index a6d82bb3c7..32e64214cc 100644
--- a/app/models/balance_sheet/classification_group.rb
+++ b/app/models/balance_sheet/classification_group.rb
@@ -34,7 +34,7 @@ class BalanceSheet::ClassificationGroup
.transform_keys { |at| Accountable.from_type(at) }
.map do |accountable, account_rows|
BalanceSheet::AccountGroup.new(
- name: accountable.display_name,
+ name: I18n.t("accounts.types.#{accountable.name.underscore}", default: accountable.display_name),
color: accountable.color,
accountable_type: accountable,
accounts: account_rows,
diff --git a/app/views/accounts/_account_sidebar_tabs.html.erb b/app/views/accounts/_account_sidebar_tabs.html.erb
index 8aba2d7c9c..ae6f793d8d 100644
--- a/app/views/accounts/_account_sidebar_tabs.html.erb
+++ b/app/views/accounts/_account_sidebar_tabs.html.erb
@@ -6,16 +6,15 @@
<summary class="flex items-center justify-between gap-2">
<div class="flex items-center gap-2">
<%= icon "triangle-alert", size: "sm", color: "warning" %>
- <p class="font-medium">Missing historical data</p>
+ <p class="font-medium"><%= t("accounts.sidebar.missing_data") %></p>
</div>
<%= icon("chevron-down", color: "warning", class: "group-open:transform group-open:rotate-180") %>
</summary>
<div class="text-xs py-2 space-y-2">
- <p><%= product_name %> uses third party providers to fetch historical exchange rates, security prices, and more. This data is required to calculate accurate historical account balances.</p>
-
+ <p><%= t("accounts.sidebar.missing_data_description", product: product_name) %></p>
<p>
- <%= link_to "Configure your providers here.", settings_hosting_path, class: "text-yellow-600 underline" %>
+ <%= link_to t("accounts.sidebar.configure_providers"), settings_hosting_path, class: "text-yellow-600 underline" %>
</p>
</div>
</details>
@@ -23,15 +22,15 @@
<%= render DS::Tabs.new(active_tab: active_tab, session_key: "account_sidebar_tab", testid: "account-sidebar-tabs") do |tabs| %>
<% tabs.with_nav do |nav| %>
- <% nav.with_btn(id: "all", label: "All") %>
- <% nav.with_btn(id: "asset", label: "Assets") %>
- <% nav.with_btn(id: "liability", label: "Debts") %>
+ <% nav.with_btn(id: "all", label: t("accounts.sidebar.tabs.all")) %>
+ <% nav.with_btn(id: "asset", label: t("accounts.sidebar.tabs.assets")) %>
+ <% nav.with_btn(id: "liability", label: t("accounts.sidebar.tabs.debts")) %>
<% end %>
<% tabs.with_panel(tab_id: "asset") do %>
<div class="space-y-2">
<%= render DS::Link.new(
- text: "New asset",
+ text: t("accounts.sidebar.new_asset"),
variant: "ghost",
href: new_account_path(step: "method_select", classification: "asset"),
icon: "plus",
@@ -51,7 +50,7 @@
<% tabs.with_panel(tab_id: "liability") do %>
<div class="space-y-2">
<%= render DS::Link.new(
- text: "New debt",
+ text: t("accounts.sidebar.new_debt"),
variant: "ghost",
href: new_account_path(step: "method_select", classification: "liability"),
icon: "plus",
@@ -71,7 +70,7 @@
<% tabs.with_panel(tab_id: "all") do %>
<div class="space-y-2">
<%= render DS::Link.new(
- text: "New account",
+ text: t("accounts.sidebar.new_account"),
variant: "ghost",
full_width: true,
href: new_account_path(step: "method_select"),
diff --git a/app/views/accounts/_accountable_group.html.erb b/app/views/accounts/_accountable_group.html.erb
index e3ae8d5a0b..934f2bb3e2 100644
--- a/app/views/accounts/_accountable_group.html.erb
+++ b/app/views/accounts/_accountable_group.html.erb
@@ -53,7 +53,7 @@
<div class="my-2">
<%= render DS::Link.new(
href: new_polymorphic_path(account_group.key, step: "method_select"),
- text: "New #{account_group.name.downcase.singularize}",
+ text: t("accounts.sidebar.new_account_group", account_group: account_group.name.downcase.singularize),
icon: "plus",
full_width: true,
variant: "ghost",
diff --git a/config/locales/views/accounts/ca.yml b/config/locales/views/accounts/ca.yml
index cf1afef7bf..b3e7c204e5 100644
--- a/config/locales/views/accounts/ca.yml
+++ b/config/locales/views/accounts/ca.yml
@@ -60,6 +60,28 @@ ca:
manage: Gestiona els comptes
update:
success: "Compte %{type} actualitzat"
+ sidebar:
+ missing_data: Falten dades històriques
+ missing_data_description: "%{product} utilitza proveïdors externs per obtenir tipus de canvi històrics, preus de valors i més. Aquestes dades són necessàries per calcular saldos històrics precisos dels comptes."
+ configure_providers: Configura els teus proveïdors aquí.
+ tabs:
+ all: Tots
+ assets: Actius
+ debts: Deutes
+ new_asset: Nou actiu
+ new_debt: Nou deute
+ new_account: Nou compte
+ new_account_group: "Nou %{account_group}"
+ types:
+ depository: Efectiu
+ investment: Inversió
+ crypto: Cripto
+ property: Propietat
+ vehicle: Vehicle
+ other_asset: Altre actiu
+ credit_card: Targeta de crèdit
+ loan: Préstec
+ other_liability: Altra passiu
email_confirmations:
new:
invalid_token: L'enllaç de confirmació no és vàlid o ha caducat.
diff --git a/config/locales/views/accounts/en.yml b/config/locales/views/accounts/en.yml
index 63b0de4a53..6ee145114e 100644
--- a/config/locales/views/accounts/en.yml
+++ b/config/locales/views/accounts/en.yml
@@ -63,6 +63,29 @@ en:
manage: Manage accounts
update:
success: "%{type} account updated"
+ sidebar:
+ missing_data: Missing historical data
+ missing_data_description: "%{product} uses third party providers to fetch historical exchange rates, security prices, and more. This data is required to calculate accurate historical account balances."
+ configure_providers: Configure your providers here.
+ tabs:
+ all: All
+ assets: Assets
+ debts: Debts
+ new_asset: New asset
+ new_debt: New debt
+ new_account: New account
+ new_account_group: "New %{account_group}"
+ types:
+ depository: Cash
+ investment: Investment
+ crypto: Crypto
+ property: Property
+ vehicle: Vehicle
+ other_asset: Other Asset
+ credit_card: Credit Card
+ loan: Loan
+ other_liability: Other Liability
+
email_confirmations:
new:
invalid_token: Invalid or expired confirmation link.
diff --git a/test/models/balance_sheet_test.rb b/test/models/balance_sheet_test.rb
index 04906afa56..9021baf27d 100644
--- a/test/models/balance_sheet_test.rb
+++ b/test/models/balance_sheet_test.rb
@@ -56,9 +56,9 @@ class BalanceSheetTest < ActiveSupport::TestCase
asset_groups = BalanceSheet.new(@family).assets.account_groups
assert_equal 3, asset_groups.size
- assert_equal 1000 + 2000, asset_groups.find { |ag| ag.name == "Cash" }.total
- assert_equal 3000, asset_groups.find { |ag| ag.name == "Investments" }.total
- assert_equal 5000, asset_groups.find { |ag| ag.name == "Other Assets" }.total
+ assert_equal 1000 + 2000, asset_groups.find { |ag| ag.name == I18n.t("accounts.types.depository") }.total
+ assert_equal 3000, asset_groups.find { |ag| ag.name == I18n.t("accounts.types.investment") }.total
+ assert_equal 5000, asset_groups.find { |ag| ag.name == I18n.t("accounts.types.other_asset") }.total
end
test "calculates liability group totals" do
@@ -71,8 +71,8 @@ class BalanceSheetTest < ActiveSupport::TestCase
liability_groups = BalanceSheet.new(@family).liabilities.account_groups
assert_equal 2, liability_groups.size
- assert_equal 1000 + 2000, liability_groups.find { |ag| ag.name == "Credit Cards" }.total
- assert_equal 3000 + 5000, liability_groups.find { |ag| ag.name == "Other Liabilities" }.total
+ assert_equal 1000 + 2000, liability_groups.find { |ag| ag.name == I18n.t("accounts.types.credit_card") }.total
+ assert_equal 3000 + 5000, liability_groups.find { |ag| ag.name == I18n.t("accounts.types.other_liability") }.total
end
private