From 43aaa92db06ce3bd0b0b8c03f82ba19ef984b72e Mon Sep 17 00:00:00 2001 From: Rasmus Kjellberg <2277443+kjellberg@users.noreply.github.com> Date: Fri, 29 Mar 2024 16:18:53 +0100 Subject: [PATCH] feat: translation strings for all text --- .../fullscreen/form/component.html.erb | 2 +- app/views/accounts/_form.html.erb | 4 +- app/views/accounts/edit.html.erb | 2 +- app/views/devise/registrations/new.html.erb | 14 +++---- app/views/devise/sessions/new.html.erb | 16 ++++---- .../partials/navigations/_protected.html.erb | 9 ++-- config/locales/kiqr.en.yml | 41 +++++++++++++++++++ 7 files changed, 64 insertions(+), 24 deletions(-) diff --git a/app/components/fullscreen/form/component.html.erb b/app/components/fullscreen/form/component.html.erb index 9be4b8b..611038a 100644 --- a/app/components/fullscreen/form/component.html.erb +++ b/app/components/fullscreen/form/component.html.erb @@ -1,5 +1,5 @@
-
+

<%= title %>

<%= description %>

diff --git a/app/views/accounts/_form.html.erb b/app/views/accounts/_form.html.erb index cea2b04..4834866 100644 --- a/app/views/accounts/_form.html.erb +++ b/app/views/accounts/_form.html.erb @@ -1,6 +1,6 @@ <%= simple_form_for(account, url: account_path, method: :patch) do |f| %> - <%= f.input :name, placeholder: account.personal? ? "Your full name" : "Team / organization name", required: true, autofocus: true %> + <%= f.input :name, placeholder: (account.personal? ? t(".name.personal") : t(".name.team")), required: true, autofocus: true %>
- <%= f.button :submit, "Save changes" %> + <%= f.button :submit, t(".submit_button") %>
<% end %> diff --git a/app/views/accounts/edit.html.erb b/app/views/accounts/edit.html.erb index f63092b..3439350 100644 --- a/app/views/accounts/edit.html.erb +++ b/app/views/accounts/edit.html.erb @@ -1,4 +1,4 @@ -<% title "Edit your account profile" %> +<% title t(".title") %> <%= render(PageLayouts::Settings::Component.new) do %> <%= render "form", account: @account %> <% end %> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 3260496..7804a90 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -2,21 +2,21 @@ <%= fullscreen do |screen| %> <%= screen.with_form( - title: "Create your #{Kiqr::Config.app_name} account", - description: "Enter your email address and a secure password." + title: t(".heading.title", app_name: Kiqr::Config.app_name), + description: t(".heading.description") ) do %>
<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> - <%= f.input :email, placeholder: "Enter a valid email address", required: true, autofocus: true, input_html: { autocomplete: "email" } %> + <%= f.input :email, placeholder: t(".form.email.placeholder"), required: true, autofocus: true, input_html: { autocomplete: "email" } %>
- <%= f.input :password, placeholder: "Create a secure password", required: true, hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length), input_html: { autocomplete: "new-password" } %> - <%= f.input :password_confirmation, placeholder: "Confirm your password", required: true, input_html: { autocomplete: "new-password" } %> + <%= f.input :password, placeholder: t(".form.password.placeholder"), required: true, hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length), input_html: { autocomplete: "new-password" } %> + <%= f.input :password_confirmation, placeholder: t(".form.password_confirmation.placeholder"), required: true, input_html: { autocomplete: "new-password" } %>
- <%= f.button :submit, "Create your account" %> -

Already have an account? <%= link_to "Sign in!", new_user_session_path, class: "font-bold transition text-primary" %> + <%= f.button :submit, t(".form.submit_button") %> +

<%= t(".already_have_account") %> <%= link_to t(".sign_in"), new_user_session_path, class: "font-bold transition text-primary" %>

<% end %>
diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 62d7f2d..dcda14e 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -2,18 +2,20 @@ <%= fullscreen do |screen| %> <%= screen.with_form( - title: "Sign in to your #{Kiqr::Config.app_name} account", - description: "Enter with your email address and password or select any of the other available options below." + title: t(".heading.title", app_name: Kiqr::Config.app_name), + description: t(".heading.description") ) do %>
<%= simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> - <%= f.input :email, placeholder: "Enter your email", required: true, autofocus: true, input_html: { autocomplete: "email" } %> - <%= f.input :password, placeholder: "Enter your password", required: true, input_html: { autocomplete: "current-password" } %> - <%= f.input :remember_me, as: :boolean, wrapper: :inline_checkbox if devise_mapping.rememberable? %> + <%= f.input :email, placeholder: t(".form.email.placeholder"), required: true, autofocus: true, input_html: { autocomplete: "email" } %> + <%= f.input :password, placeholder: t(".form.password.placeholder"), required: true, input_html: { autocomplete: "current-password" } %> + <%= f.input :remember_me, label: t(".form.remember_me.label"), as: :boolean, wrapper: :inline_checkbox if devise_mapping.rememberable? %>
- <%= f.button :submit, "Sign in" %> -

Don't have an account? <%= link_to "Sign up!", new_user_registration_path, class: "font-bold text-primary transition" %>

+ <%= f.button :submit, t(".form.submit_button") %> +

+ <%= t(".no_account") %> + <%= link_to t(".sign_up"), new_user_registration_path, class: "font-bold text-primary transition" %>

<% end %>
diff --git a/app/views/partials/navigations/_protected.html.erb b/app/views/partials/navigations/_protected.html.erb index 2b8c476..f903e86 100644 --- a/app/views/partials/navigations/_protected.html.erb +++ b/app/views/partials/navigations/_protected.html.erb @@ -1,13 +1,10 @@ -<%= link_to "Dashboard", dashboard_path, class: "font-bold text-primary" %> -<%= link_to "Domains", dashboard_path %> -<%= link_to "Reports", dashboard_path %> +<%= link_to t(".dashboard"), dashboard_path, class: "font-bold text-primary" %> <% navbar.with_right_section do %> <%= navbar.account_selector if onboarded? %> - <%= render(Navbar::Dropdown::Component.new(icon: "fa fa-gear", chevron: false)) do |dropdown| %> - <%= dropdown.item(label: "Edit profile", icon: "fa fa-user", path: edit_account_path) %> - <%= dropdown.item(label: "Change password", icon: "fa fa-key", path: edit_user_registration_path) %> + <%= link_to edit_account_path do %> + <% end %> <%= navbar.dark_mode_switch %> diff --git a/config/locales/kiqr.en.yml b/config/locales/kiqr.en.yml index caaa0f0..fdeeb29 100644 --- a/config/locales/kiqr.en.yml +++ b/config/locales/kiqr.en.yml @@ -1,6 +1,47 @@ en: + devise: + sessions: + new: + heading: + title: "Sign in to your %{app_name} account" + description: "Enter with your email address and password or select any of the other available options below." + form: + email: + placeholder: "Enter your email" + password: + placeholder: "Enter your password" + remember_me: + label: "Remember me" + submit_button: "Sign in" + no_account: "Don't have an account?" + sign_up: "Sign up!" + registrations: + new: + heading: + title: "Create a new %{app_name} account" + description: "Enter your email address and password to create a new account." + form: + email: + placeholder: "Enter a valid email address" + password: + placeholder: "Create a secure password" + password_confirmation: + placeholder: "Confirm your password" + submit_button: "Create your account" + already_have_account: Already have an account? + sign_in: Sign in! + accounts: + edit: + title: "Edit your account profile" + form: + name: + personal: "Your full name" + team: "Team / organization name" + submit_button: "Save changes" partials: navigations: + protected: + dashboard: "Dashboard" settings: account_settings: "Account settings" user_settings: "Login & security"