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 |   protected | ||||||
| 
 | 
 | ||||||
|   def locale_for_account(account, &block) |   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 |   end | ||||||
| 
 | 
 | ||||||
|   def set_autoreply_headers! |   def set_autoreply_headers! | ||||||
|  | |||||||
| @ -33,7 +33,7 @@ class UserMailer < Devise::Mailer | |||||||
| 
 | 
 | ||||||
|     return unless @resource.active_for_authentication? |     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 |       mail subject: default_devise_subject | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| @ -43,7 +43,7 @@ class UserMailer < Devise::Mailer | |||||||
| 
 | 
 | ||||||
|     return unless @resource.active_for_authentication? |     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 |       mail subject: default_devise_subject | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| @ -53,7 +53,7 @@ class UserMailer < Devise::Mailer | |||||||
| 
 | 
 | ||||||
|     return unless @resource.active_for_authentication? |     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 |       mail subject: default_devise_subject | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| @ -63,7 +63,7 @@ class UserMailer < Devise::Mailer | |||||||
| 
 | 
 | ||||||
|     return unless @resource.active_for_authentication? |     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 |       mail subject: default_devise_subject | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| @ -73,7 +73,7 @@ class UserMailer < Devise::Mailer | |||||||
| 
 | 
 | ||||||
|     return unless @resource.active_for_authentication? |     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 |       mail subject: default_devise_subject | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| @ -83,7 +83,7 @@ class UserMailer < Devise::Mailer | |||||||
| 
 | 
 | ||||||
|     return unless @resource.active_for_authentication? |     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 |       mail subject: default_devise_subject | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| @ -93,7 +93,7 @@ class UserMailer < Devise::Mailer | |||||||
| 
 | 
 | ||||||
|     return unless @resource.active_for_authentication? |     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 |       mail subject: default_devise_subject | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| @ -103,7 +103,7 @@ class UserMailer < Devise::Mailer | |||||||
| 
 | 
 | ||||||
|     return unless @resource.active_for_authentication? |     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 |       mail subject: default_devise_subject | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| @ -114,7 +114,7 @@ class UserMailer < Devise::Mailer | |||||||
| 
 | 
 | ||||||
|     return unless @resource.active_for_authentication? |     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') |       mail subject: I18n.t('devise.mailer.webauthn_credential.added.subject') | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| @ -125,7 +125,7 @@ class UserMailer < Devise::Mailer | |||||||
| 
 | 
 | ||||||
|     return unless @resource.active_for_authentication? |     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') |       mail subject: I18n.t('devise.mailer.webauthn_credential.deleted.subject') | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| @ -219,7 +219,7 @@ class UserMailer < Devise::Mailer | |||||||
|     @instance = Rails.configuration.x.local_domain |     @instance = Rails.configuration.x.local_domain | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   def locale |   def locale(use_current_locale: false) | ||||||
|     @resource.locale.presence || I18n.locale || I18n.default_locale |     @resource.locale.presence || (use_current_locale && I18n.locale) || I18n.default_locale | ||||||
|   end |   end | ||||||
| end | end | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user