From d47c70f576cf33dd7917edac91c98279c5228258 Mon Sep 17 00:00:00 2001
From: Riccardo Graziosi <31478034+riggraz@users.noreply.github.com>
Date: Sat, 16 Mar 2024 16:24:00 +0100
Subject: [PATCH] Add some missing translations and limit locale selection only
to available locales (#313)
---
app/models/tenant.rb | 1 +
app/views/devise/registrations/edit.html.erb | 15 +++++++++------
config/locales/en.yml | 3 +++
3 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/app/models/tenant.rb b/app/models/tenant.rb
index 3a8d661e..41eeecd3 100644
--- a/app/models/tenant.rb
+++ b/app/models/tenant.rb
@@ -18,6 +18,7 @@ class Tenant < ApplicationRecord
validates :site_name, presence: true
validates :subdomain, presence: true, uniqueness: true
+ validates :locale, inclusion: { in: I18n.available_locales.map(&:to_s) }
accepts_nested_attributes_for :tenant_setting, update_only: true
diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb
index 4a79500e..14f6ac35 100644
--- a/app/views/devise/registrations/edit.html.erb
+++ b/app/views/devise/registrations/edit.html.erb
@@ -13,6 +13,13 @@
<%= f.email_field :email, autocomplete: "email", class: "form-control" %>
+ <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
+
+ <%= t('common.forms.auth.waiting_confirmation', email: resource.unconfirmed_email) %>
+
+
+ <% end %>
+
<%= f.label :notifications_enabled, t('common.forms.auth.notifications_enabled') %>
@@ -22,15 +29,11 @@
- <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
- Currently waiting confirmation for: <%= resource.unconfirmed_email %>
- <% end %>
-
<%= f.label :password, t('common.forms.auth.password') %>
<%= f.password_field :password, autocomplete: "new-password", class: "form-control" %>
- leave blank if you don't want to change your password
+ <%= t('common.forms.auth.password_leave_blank_help') %>
@@ -43,7 +46,7 @@
<%= f.label :current_password, t('common.forms.auth.current_password') %>
<%= f.password_field :current_password, autocomplete: "current-password", class: "form-control" %>
- we need your current password to confirm your changes
+ <%= t('common.forms.auth.current_password_required_help') %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index b9e4c110..c492f477 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -17,6 +17,9 @@ en:
current_password: 'Current password'
notifications_enabled: 'Notifications enabled'
notifications_enabled_help: "if disabled, you won't receive any notification"
+ waiting_confirmation: 'Currently waiting confirmation for %{email}'
+ password_leave_blank_help: "leave blank if you don't want to change your password"
+ current_password_required_help: 'we need your current password to confirm your changes'
remember_me: 'Remember me'
log_in: 'Log in'
sign_up: 'Sign up'