diff --git a/CHANGELOG.md b/CHANGELOG.md index 38b434e1..e4e2fade 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +### Unreleased + +* bug fixes + * Fix translation issue with German `E-Mail` on invalid authentication messages caused by previous fix for incorrect grammar [#5822](https://github.com/heartcombo/devise/pull/5822) + ### 5.0.0 - 2026-01-23 no changes diff --git a/lib/devise/failure_app.rb b/lib/devise/failure_app.rb index 8222780f..1c9b5865 100644 --- a/lib/devise/failure_app.rb +++ b/lib/devise/failure_app.rb @@ -112,7 +112,9 @@ module Devise options[:default] = [message] auth_keys = scope_class.authentication_keys human_keys = (auth_keys.respond_to?(:keys) ? auth_keys.keys : auth_keys).map { |key| - scope_class.human_attribute_name(key).downcase + # TODO: Remove the fallback and just use `downcase_first` once we drop support for Rails 7.0. + human_key = scope_class.human_attribute_name(key) + human_key.respond_to?(:downcase_first) ? human_key.downcase_first : human_key[0].downcase + human_key[1..] } options[:authentication_keys] = human_keys.join(I18n.t(:"support.array.words_connector")) options = i18n_options(options) diff --git a/test/failure_app_test.rb b/test/failure_app_test.rb index b57f4e42..c9e4a56c 100644 --- a/test/failure_app_test.rb +++ b/test/failure_app_test.rb @@ -215,6 +215,11 @@ class FailureTest < ActiveSupport::TestCase assert_equal 'Email ou senha inválidos.', @request.flash[:alert] assert_equal 'http://test.host/users/sign_in', @response.second["Location"] + + call_failure('warden' => OpenStruct.new(message: :invalid), 'warden.options' => { locale: :de }) + + assert_equal 'E-Mail oder Passwort ist ungültig.', @request.flash[:alert] + assert_equal 'http://test.host/users/sign_in', @response.second["Location"] end test 'uses the proxy failure message as string' do diff --git a/test/support/locale/de.yml b/test/support/locale/de.yml new file mode 100644 index 00000000..b6045716 --- /dev/null +++ b/test/support/locale/de.yml @@ -0,0 +1,12 @@ +de: + activerecord: + attributes: + user: + email: E-Mail + mongoid: + attributes: + user: + email: E-Mail + devise: + failure: + invalid: "%{authentication_keys} oder Passwort ist ungültig."