Fix email language when recipient has no selected locale (#31747)
This commit is contained in:
		
							parent
							
								
									e1b5f3fc6f
								
							
						
					
					
						commit
						559958f8c5
					
				| @ -12,7 +12,7 @@ class ApplicationMailer < ActionMailer::Base | ||||
|   protected | ||||
| 
 | ||||
|   def locale_for_account(account, &block) | ||||
|     I18n.with_locale(account.user_locale || I18n.locale || I18n.default_locale, &block) | ||||
|     I18n.with_locale(account.user_locale || I18n.default_locale, &block) | ||||
|   end | ||||
| 
 | ||||
|   def set_autoreply_headers! | ||||
|  | ||||
| @ -33,7 +33,7 @@ class UserMailer < Devise::Mailer | ||||
| 
 | ||||
|     return unless @resource.active_for_authentication? | ||||
| 
 | ||||
|     I18n.with_locale(locale) do | ||||
|     I18n.with_locale(locale(use_current_locale: true)) do | ||||
|       mail subject: default_devise_subject | ||||
|     end | ||||
|   end | ||||
| @ -43,7 +43,7 @@ class UserMailer < Devise::Mailer | ||||
| 
 | ||||
|     return unless @resource.active_for_authentication? | ||||
| 
 | ||||
|     I18n.with_locale(locale) do | ||||
|     I18n.with_locale(locale(use_current_locale: true)) do | ||||
|       mail subject: default_devise_subject | ||||
|     end | ||||
|   end | ||||
| @ -53,7 +53,7 @@ class UserMailer < Devise::Mailer | ||||
| 
 | ||||
|     return unless @resource.active_for_authentication? | ||||
| 
 | ||||
|     I18n.with_locale(locale) do | ||||
|     I18n.with_locale(locale(use_current_locale: true)) do | ||||
|       mail subject: default_devise_subject | ||||
|     end | ||||
|   end | ||||
| @ -63,7 +63,7 @@ class UserMailer < Devise::Mailer | ||||
| 
 | ||||
|     return unless @resource.active_for_authentication? | ||||
| 
 | ||||
|     I18n.with_locale(locale) do | ||||
|     I18n.with_locale(locale(use_current_locale: true)) do | ||||
|       mail subject: default_devise_subject | ||||
|     end | ||||
|   end | ||||
| @ -73,7 +73,7 @@ class UserMailer < Devise::Mailer | ||||
| 
 | ||||
|     return unless @resource.active_for_authentication? | ||||
| 
 | ||||
|     I18n.with_locale(locale) do | ||||
|     I18n.with_locale(locale(use_current_locale: true)) do | ||||
|       mail subject: default_devise_subject | ||||
|     end | ||||
|   end | ||||
| @ -83,7 +83,7 @@ class UserMailer < Devise::Mailer | ||||
| 
 | ||||
|     return unless @resource.active_for_authentication? | ||||
| 
 | ||||
|     I18n.with_locale(locale) do | ||||
|     I18n.with_locale(locale(use_current_locale: true)) do | ||||
|       mail subject: default_devise_subject | ||||
|     end | ||||
|   end | ||||
| @ -93,7 +93,7 @@ class UserMailer < Devise::Mailer | ||||
| 
 | ||||
|     return unless @resource.active_for_authentication? | ||||
| 
 | ||||
|     I18n.with_locale(locale) do | ||||
|     I18n.with_locale(locale(use_current_locale: true)) do | ||||
|       mail subject: default_devise_subject | ||||
|     end | ||||
|   end | ||||
| @ -103,7 +103,7 @@ class UserMailer < Devise::Mailer | ||||
| 
 | ||||
|     return unless @resource.active_for_authentication? | ||||
| 
 | ||||
|     I18n.with_locale(locale) do | ||||
|     I18n.with_locale(locale(use_current_locale: true)) do | ||||
|       mail subject: default_devise_subject | ||||
|     end | ||||
|   end | ||||
| @ -114,7 +114,7 @@ class UserMailer < Devise::Mailer | ||||
| 
 | ||||
|     return unless @resource.active_for_authentication? | ||||
| 
 | ||||
|     I18n.with_locale(locale) do | ||||
|     I18n.with_locale(locale(use_current_locale: true)) do | ||||
|       mail subject: I18n.t('devise.mailer.webauthn_credential.added.subject') | ||||
|     end | ||||
|   end | ||||
| @ -125,7 +125,7 @@ class UserMailer < Devise::Mailer | ||||
| 
 | ||||
|     return unless @resource.active_for_authentication? | ||||
| 
 | ||||
|     I18n.with_locale(locale) do | ||||
|     I18n.with_locale(locale(use_current_locale: true)) do | ||||
|       mail subject: I18n.t('devise.mailer.webauthn_credential.deleted.subject') | ||||
|     end | ||||
|   end | ||||
| @ -219,7 +219,7 @@ class UserMailer < Devise::Mailer | ||||
|     @instance = Rails.configuration.x.local_domain | ||||
|   end | ||||
| 
 | ||||
|   def locale | ||||
|     @resource.locale.presence || I18n.locale || I18n.default_locale | ||||
|   def locale(use_current_locale: false) | ||||
|     @resource.locale.presence || (use_current_locale && I18n.locale) || I18n.default_locale | ||||
|   end | ||||
| end | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user