1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-19 05:09:38 +02:00

Start I18n Internationalization setup (#276)

* start internationalization_setup

* add passwords views translations

* add account views translations

* fix translations

* temporary disable i18n used key
This commit is contained in:
Ricardo Siqueira de Oliveira Leite 2024-02-06 14:58:17 -03:00 committed by GitHub
parent 64c8774867
commit c8a659694d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 177 additions and 102 deletions

View file

@ -6,7 +6,7 @@ class AccountsController < ApplicationController
@account = if params[:type].blank?
Account.new
else
Account.new(accountable_type: "Account::#{params[:type]}")
Account.new(accountable_type: "Account::#{params[:type]}", balance: nil)
end
else
head :not_found
@ -21,7 +21,7 @@ class AccountsController < ApplicationController
@account.accountable = account_params[:accountable_type].constantize.new
if @account.save
redirect_to accounts_path, notice: "New account created successfully"
redirect_to accounts_path, notice: t(".success")
else
render "new", status: :unprocessable_entity
end

View file

@ -1,7 +1,3 @@
class Account::Credit < ApplicationRecord
include Accountable
def type_name
"Credit Card"
end
end

View file

@ -1,7 +1,3 @@
class Account::Depository < ApplicationRecord
include Accountable
def type_name
"Bank Accounts"
end
end

View file

@ -1,7 +1,3 @@
class Account::Investment < ApplicationRecord
include Accountable
def type_name
"Investments"
end
end

View file

@ -1,7 +1,3 @@
class Account::Loan < ApplicationRecord
include Accountable
def type_name
"Loan"
end
end

View file

@ -1,7 +1,3 @@
class Account::OtherAsset < ApplicationRecord
include Accountable
def type_name
"Other Asset"
end
end

View file

@ -1,7 +1,3 @@
class Account::OtherLiability < ApplicationRecord
include Accountable
def type_name
"Other Liability"
end
end

View file

@ -1,7 +1,3 @@
class Account::Property < ApplicationRecord
include Accountable
def type_name
"Real Estate"
end
end

View file

@ -1,7 +1,3 @@
class Account::Vehicle < ApplicationRecord
include Accountable
def type_name
"Vehicle"
end
end

View file

@ -4,6 +4,6 @@
<span class="flex w-10 h-10 shrink-0 grow-0 items-center justify-center rounded-xl <%= bg_color %> mb-2">
<%= inline_svg_tag(icon, class: "#{text_color} stroke-current") %>
</span>
<%= type.type_name %>
<%= type.model_name.human %>
<% end %>
</div>

View file

@ -1,5 +1,5 @@
<h2 class="text-2xl font-semibold font-display">Cash</h2>
<h2 class="text-2xl font-semibold font-display"><%= t('.title')%></h2>
<h3 class="mt-1 mb-4 text-sm text-gray-500"><%#= number_to_currency Current.family.cash_balance %></h3>
<% Current.family.accounts.each do |account| %>
@ -8,7 +8,7 @@
<%= account.name %>
</div>
<div class="flex items-center text-sm">
<%= account.accountable %>
<%= account.accountable.model_name.human %>
</div>
<p class="text-sm text-right">
<span class="block mb-1"><%= humanized_money_with_symbol account.balance %></span>

View file

@ -1,4 +1,4 @@
<h1 class="text-3xl font-semibold font-display">Add an account</h1>
<h1 class="text-3xl font-semibold font-display"><%= t('.title')%></h1>
<% if params[:type].blank? || Account.accountable_types.include?("Account::#{params[:type]}") == false %>
<div class="grid grid-cols-2 gap-4 mt-8 text-sm sm:grid-cols-3 md:grid-cols-4">
@ -16,7 +16,7 @@
<%= link_to new_account_path, class: "" do %>
<%= inline_svg_tag('icon-arrow-left.svg', class: 'text-gray-500 fill-current') %>
<% end %>
<h2 class="text-2xl font-semibold font-display">Enter <%= params[:type] %> account</h2>
<h2 class="text-2xl font-semibold font-display"><%= t('.enter_type_account', type: @account.accountable_class.model_name.human.downcase ) %></h2>
</div>
<%= form_with model: @account, url: accounts_path, scope: :account, html: { class: "space-y-4" } do |f| %>
@ -24,16 +24,17 @@
<div class="relative p-4 border border-gray-100 bg-offwhite rounded-xl focus-within:bg-white focus-within:shadow focus-within:opacity-100">
<%# <span class="absolute px-2 py-1 text-xs font-medium text-gray-400 uppercase bg-gray-200 rounded-full opacity-50 right-3">Optional</span> %>
<label for="account_name" class="block text-sm font-medium opacity-50 focus-within:opacity-100">Name</label>
<%= f.text_field :name, placeholder: "Account name", required: 'required', class: "p-0 mt-1 bg-transparent border-none opacity-50 focus:outline-none focus:ring-0 focus-within:opacity-100" %>
<%= f.label :name, class: 'block text-sm font-medium opacity-50 focus-within:opacity-100' %>
<%= f.text_field :name, placeholder: t('.account_name_placeholder'), required: 'required', class: "p-0 mt-1 bg-transparent border-none opacity-50 focus:outline-none focus:ring-0 focus-within:opacity-100" %>
</div>
<%= render "accounts/#{permitted_accountable_partial(@account.accountable_type)}", f: f %>
<div class="relative p-4 border border-gray-100 bg-offwhite rounded-xl focus-within:bg-white focus-within:shadow focus-within:opacity-100">
<label for="account_balance" class="block text-sm font-medium opacity-50 focus-within:opacity-100">Balance</label>
<%= f.label :balance, class: 'block text-sm font-medium opacity-50 focus-within:opacity-100' %>
<div class="flex">
<%= f.number_field :balance, placeholder: "$0.00", in: 0.00..100000000.00, step: :any, required: 'required', class: "p-0 mt-1 bg-transparent border-none opacity-50 focus:outline-none focus:ring-0 focus-within:opacity-100" %>
<%= f.number_field :balance, placeholder: number_to_currency(0), in: 0.00..100000000.00, required: 'required', class: "p-0 mt-1 bg-transparent border-none opacity-50 focus:outline-none focus:ring-0 focus-within:opacity-100" %>
</div>
</div>

View file

@ -49,20 +49,20 @@
<li>
<%= link_to root_path, class: 'block hover:bg-gray-100 -ml-2 p-2 text-sm font-semibold text-gray-900 flex items-center rounded' do %>
<%= inline_svg_tag('icon-dashboard.svg', class: 'text-black stroke-current mr-2') %>
Dashboard
<%= t('.dashboard') %>
<% end %>
</li>
</ul>
</nav>
<div class="flex flex-col mt-6">
<div class="flex items-center justify-between">
<span class="text-xs">Accounts</span>
<%= link_to new_account_path, class: 'block hover:bg-gray-100 p-2 text-sm font-semibold text-gray-900 flex items-center rounded', title: "New account" do %>
<span class="text-xs"><%= t('.accounts') %></span>
<%= link_to new_account_path, class: 'block hover:bg-gray-100 p-2 text-sm font-semibold text-gray-900 flex items-center rounded', title: t('.new_accoount') do %>
<%= inline_svg_tag('icon-add.svg', class: 'text-gray-500 fill-current') %>
<% end %>
</div>
<div>
<h2 class="text-sm font-semibold font-display">Cash</h2>
<h2 class="text-sm font-semibold font-display"><%= t('.cache') %></h2>
<% Current.family.accounts.each do |account| %>
<div class="flex items-center justify-between py-2">

View file

@ -24,17 +24,17 @@
<%= render "shared/logo" %>
<h2 class="mt-6 text-3xl font-semibold tracking-tight text-center font-display">
<%= content_for?(:header_title) ? yield(:header_title).html_safe : "Your account" %>
<%= content_for?(:header_title) ? yield(:header_title).html_safe : t('.your_account') %>
</h2>
<% if controller_name == "sessions" %>
<p class="mt-2 text-sm text-center text-gray-600">
or <%= link_to "create an account", new_registration_path, class: 'font-medium text-gray-600 hover:text-gray-400 transition' %>
</p>
<p class="mt-2 text-sm text-center text-gray-600">
<%= t('.or') %> <%= link_to t('.sign_up'), new_registration_path, class: 'font-medium text-gray-600 hover:text-gray-400 transition' %>
</p>
<% elsif controller_name == "registrations" %>
<p class="mt-2 text-sm text-center text-gray-600">
or <%= link_to "sign in to your account", new_session_path, class: 'font-medium text-gray-600 hover:text-gray-400 transition' %>
</p>
<p class="mt-2 text-sm text-center text-gray-600">
<%= t('.or') %> <%= link_to t('.sign_in'), new_session_path, class: 'font-medium text-gray-600 hover:text-gray-400 transition' %>
</p>
<% end %>
</div>
@ -44,7 +44,7 @@
</div>
<div class="p-8 mt-2 text-center">
<p class="mt-6 text-sm text-black"><a href="/privacy" class="font-medium text-gray-600 hover:text-gray-400 transition">Privacy Policy</a> &bull; <a href="/terms" class="font-medium text-gray-600 hover:text-gray-400 transition">Terms of Service</a></p>
<p class="mt-6 text-sm text-black"><%= link_to t('.privacy_policy'), "/privacy", class: "font-medium text-gray-600 hover:text-gray-400 transition" %> &bull; <%= link_to t('.terms_of_service'), "/terms", class: "font-medium text-gray-600 hover:text-gray-400 transition" %></p>
</div>
</div>

View file

@ -1 +1 @@
<h1 class="text-3xl font-semibold font-display">Dashboard</h1>
<h1 class="text-3xl font-semibold font-display"><%= t('.title')%></h1>

View file

@ -1 +1 @@
<%= link_to "Reset your password", edit_password_reset_url(token: params[:token]) %>
<%= link_to t('.cta'), edit_password_reset_url(token: params[:token]) %>

View file

@ -1,5 +1,5 @@
<%
header_title "Reset password"
header_title t('.title')
%>
<%= form_with url: password_reset_path(token: params[:token]), html: {class: 'space-y-6'} do |form| %>
@ -16,6 +16,6 @@
</div>
<div>
<%= form.submit "Reset Password", class: 'flex justify-center w-full px-4 py-3 text-sm font-medium text-white bg-black rounded-xl hover:bg-black focus:outline-none focus:ring-2 focus:ring-gray-200 shadow' %>
<%= form.submit t('.submit'), class: 'flex justify-center w-full px-4 py-3 text-sm font-medium text-white bg-black rounded-xl hover:bg-black focus:outline-none focus:ring-2 focus:ring-gray-200 shadow' %>
</div>
<% end %>

View file

@ -1,5 +1,5 @@
<%
header_title "Reset password"
header_title t('.title')
%>
<%= form_with url: password_reset_path, html: {class: 'space-y-6'} do |form| %>
@ -11,6 +11,6 @@
</div>
<div>
<%= form.submit "Reset password", class: 'flex justify-center w-full px-4 py-3 text-sm font-medium text-white bg-black rounded-xl hover:bg-black focus:outline-none focus:ring-2 focus:ring-gray-200 shadow' %>
<%= form.submit t('.submit'), class: 'flex justify-center w-full px-4 py-3 text-sm font-medium text-white bg-black rounded-xl hover:bg-black focus:outline-none focus:ring-2 focus:ring-gray-200 shadow' %>
</div>
<% end %>

View file

@ -1,15 +1,15 @@
<h1>Update Password</h1>
<h1><% t('.title')%></h1>
<%= form_with model: Current.user, url: password_path do |form| %>
<%= auth_messages form %>
<div>
<%= form.label :password_challenge, "Current Password" %>
<%= form.label :password_challenge, t('.password_challenge') %>
<%= form.password_field :password_challenge %>
</div>
<div>
<%= form.label :password, "New Password" %>
<%= form.label :password, t('.password') %>
<%= form.password_field :password %>
</div>
@ -19,7 +19,6 @@
</div>
<div>
<%= form.submit 'Update Password' %>
<%= form.submit t('.submit') %>
</div>
<% end %>

View file

@ -1,5 +1,5 @@
<%
header_title "Create an account"
header_title t('.title')
%>
<%= form_with model: @user, url: registration_path, html: {class: 'space-y-6'} do |form| %>
@ -11,23 +11,23 @@
</div>
<div class="relative border border-gray-100 bg-offwhite rounded-xl focus-within:bg-white focus-within:shadow focus-within:opacity-100">
<%= form.label :password, "Password", class: 'p-4 pb-0 block text-sm font-medium text-gray-700' %>
<%= form.label :password, class: 'p-4 pb-0 block text-sm font-medium text-gray-700' %>
<%= form.password_field :password, autocomplete: "new-password", required: 'required', class: 'p-4 pt-1 bg-transparent border-none opacity-50 focus:outline-none focus:ring-0 focus-within:opacity-100 w-full' %>
</div>
<div class="relative border border-gray-100 bg-offwhite rounded-xl focus-within:bg-white focus-within:shadow focus-within:opacity-100">
<%= form.label :password_confirmation, "Password confirmation", class: 'p-4 pb-0 block text-sm font-medium text-gray-700' %>
<%= form.label :password_confirmation, class: 'p-4 pb-0 block text-sm font-medium text-gray-700' %>
<%= form.password_field :password_confirmation, autocomplete: "new-password", required: 'required', class: 'p-4 pt-1 bg-transparent border-none opacity-50 focus:outline-none focus:ring-0 focus-within:opacity-100 w-full' %>
</div>
<% if hosted_app? %>
<div class="bg-offwhite rounded-xl focus-within:bg-white focus-within:shadow focus-within:opacity-100 relative border border-gray-100">
<%= form.label :invite_code, "Invite code", class: 'p-4 pb-0 block text-sm font-medium text-gray-700' %>
<%= form.label :invite_code, class: 'p-4 pb-0 block text-sm font-medium text-gray-700' %>
<%= form.password_field :invite_code, required: 'required', class: 'p-4 pt-1 bg-transparent border-none opacity-50 focus:outline-none focus:ring-0 focus-within:opacity-100 w-full' %>
</div>
<% end %>
<div>
<%= form.submit "Continue", class: 'cursor-pointer flex justify-center w-full px-4 py-3 text-sm font-medium text-white bg-black rounded-xl hover:bg-black focus:outline-none focus:ring-2 focus:ring-gray-200 shadow' %>
<%= form.submit class: 'cursor-pointer flex justify-center w-full px-4 py-3 text-sm font-medium text-white bg-black rounded-xl hover:bg-black focus:outline-none focus:ring-2 focus:ring-gray-200 shadow' %>
</div>
<% end %>

View file

@ -1,25 +1,25 @@
<%
header_title "Sign in to your account"
header_title t('.title')
%>
<%= form_with url: session_path, html: {class: 'space-y-6'} do |form| %>
<%= auth_messages form %>
<div class="relative border border-gray-100 bg-offwhite rounded-xl focus-within:bg-white focus-within:shadow focus-within:opacity-100">
<%= form.label :email, "Email address", class: 'p-4 pb-0 block text-sm font-medium text-gray-700' %>
<%= form.email_field :email, autofocus: false, autocomplete: "email", required: 'required', placeholder: 'you@example.com', class: 'p-4 pt-1 bg-transparent border-none opacity-50 focus:outline-none focus:ring-0 focus-within:opacity-100 w-full' %>
<%= form.label :email, t('.email'), class: 'p-4 pb-0 block text-sm font-medium text-gray-700' %>
<%= form.email_field :email, autofocus: false, autocomplete: "email", required: 'required', placeholder: t('.email_placeholder'), class: 'p-4 pt-1 bg-transparent border-none opacity-50 focus:outline-none focus:ring-0 focus-within:opacity-100 w-full' %>
</div>
<div class="relative border border-gray-100 bg-offwhite rounded-xl focus-within:bg-white focus-within:shadow focus-within:opacity-100">
<%= form.label :password, "Password", class: 'p-4 pb-0 block text-sm font-medium text-gray-700' %>
<%= form.label :password, class: 'p-4 pb-0 block text-sm font-medium text-gray-700' %>
<%= form.password_field :password, required: 'required', class: 'p-4 pt-1 bg-transparent border-none opacity-50 focus:outline-none focus:ring-0 focus-within:opacity-100 w-full' %>
</div>
<div>
<%= form.submit "Log in", class: 'cursor-pointer flex justify-center w-full px-4 py-3 text-sm font-medium text-white bg-black rounded-xl hover:bg-black focus:outline-none focus:ring-2 focus:ring-gray-200 shadow' %>
<%= form.submit t('.submit'), class: 'cursor-pointer flex justify-center w-full px-4 py-3 text-sm font-medium text-white bg-black rounded-xl hover:bg-black focus:outline-none focus:ring-2 focus:ring-gray-200 shadow' %>
</div>
<% end %>
<div class="mt-6 text-center">
<p class="text-sm text-gray-600">Forgot your password? <%= link_to "Reset it", new_password_reset_path, class: 'font-medium text-gray-600 hover:text-gray-400 transition' %></p>
<p class="text-sm text-gray-600"><%= t('.forgot_password') %> <%= link_to t('.reset_password'), new_password_reset_path, class: 'font-medium text-gray-600 hover:text-gray-400 transition' %></p>
</div>

View file

@ -1,9 +1,9 @@
base_locale: en
data:
read:
- config/locales/%{locale}.yml
- config/locales/**/*%{locale}.yml
write:
- config/locales/%{locale}.yml
- config/locales/**/*%{locale}.yml
router: conservative_router
search:
paths:
@ -14,7 +14,7 @@ search:
- app/mailers
- app/presenters
- app/views
strict: true
strict: false
## Files or `File.fnmatch` patterns to exclude from search. Some files are always excluded regardless of this setting:
## *.jpg *.jpeg *.png *.gif *.svg *.ico *.eot *.otf *.ttf *.woff *.woff2 *.pdf *.css *.sass *.scss *.less
## *.yml *.json *.zip *.tar.gz *.swf *.flv *.mp3 *.wav *.flac *.webm *.mp4 *.ogg *.opus *.webp *.map *.xlsx
@ -23,3 +23,8 @@ search:
- app/assets/fonts
- app/assets/videos
- app/assets/builds
ignore_unused:
- 'activerecord.attributes.*' # i18n-tasks does not detect these on forms, forms validations (https://github.com/glebm/i18n-tasks/blob/0b4b483c82664f26c5696fb0f6aa1297356e4683/templates/config/i18n-tasks.yml#L146)
- 'activerecord.models.account*' # i18n-tasks does not detect use in dynamic model names (e.g. object.model_name.human)
- 'helpers.submit.*' # i18n-tasks does not detect used at forms
- 'helpers.label.*' # i18n-tasks does not detect used at forms

View file

@ -1,22 +0,0 @@
---
en:
password_resets:
create:
requested: If an account with that email exists, we have sent a link to reset
your password.
update:
invalid_token: Invalid token.
success: Your password has been reset.
passwords:
update:
success: Your password has been updated successfully.
registrations:
create:
failure: Invalid input, please try again.
invalid_invite_code: Invalid invite code, please try again.
success: You have signed up successfully.
sessions:
create:
invalid_credentials: Invalid email or password.
destroy:
logout_successful: You have signed out successfully.

View file

@ -0,0 +1,21 @@
---
en:
activerecord:
attributes:
account:
balance: Balance
currency: Currency
family: Family
family_id: Family
name: Name
subtype: Subtype
models:
account: Account
account/credit: Credit Card
account/depository: Bank Accounts
account/investiment: Investments
account/loan: Loan
account/other_asset: Other Asset
account/other_liability: Other Liability
account/property: Real Estate
account/vehicle: Vehicle

View file

@ -0,0 +1,12 @@
---
en:
activerecord:
attributes:
user:
email: Email
family: Family
family_id: Family
first_name: First Name
last_name: Last Name
password: Password
password_confirmation: Password Confirmation

View file

@ -0,0 +1,11 @@
---
en:
accounts:
create:
success: New account created successfully
index:
title: Cash
new:
account_name_placeholder: Account name
enter_type_account: Enter %{type} account
title: Add an account

View file

@ -0,0 +1,15 @@
---
en:
layouts:
application:
accounts: Accounts
cache: Cache
dashboard: Dashboard
new_accoount: New Account
auth:
or: or
privacy_policy: Privacy Policy
sign_in: sign in to your account
sign_up: create an account
terms_of_service: Terms of Service
your_account: Your account

View file

@ -0,0 +1,5 @@
---
en:
pages:
dashboard:
title: Dashboard

View file

@ -0,0 +1,5 @@
---
en:
password_mailer:
password_reset:
cta: Reset your password

View file

@ -0,0 +1,15 @@
---
en:
password_resets:
create:
requested: If an account with that email exists, we have sent a link to reset
your password.
edit:
submit: Update Password
title: Reset password
new:
submit: Reset password
title: Reset password
update:
invalid_token: Invalid token.
success: Your password has been reset.

View file

@ -0,0 +1,10 @@
---
en:
passwords:
edit:
password: New Password
password_challenge: Current Password
submit: Reset Password
title: Update Password
update:
success: Your password has been reset.

View file

@ -0,0 +1,16 @@
---
en:
helpers:
label:
user:
invite_code: Invite Code
submit:
user:
create: Continue
registrations:
create:
failure: Invalid input, please try again.
invalid_invite_code: Invalid invite code, please try again.
success: You have signed up successfully.
new:
title: Create an account

View file

@ -0,0 +1,14 @@
---
en:
sessions:
create:
invalid_credentials: Invalid email or password.
destroy:
logout_successful: You have signed out successfully.
new:
email: Email address
email_placeholder: you@example.com
forgot_password: Forgot your password?
reset_password: Reset it
submit: Log in
title: Sign in to your account