// Update zh-hant password_reset config with custom translation.
$configLanguageOverride =
$this->container->
get('language_manager'
)->
getLanguageConfigOverride('zh-hant', 'user.mail'
);
$configLanguageOverride->
set('password_reset.subject', 'hant subject [user:display-name]'
)->
save();
$configLanguageOverride->
set('password_reset.body', 'hant body [user:display-name] and token link [user:one-time-login-url]'
)->
save();
// Update fr password_reset config with custom translation.
$configLanguageOverride =
$this->container->
get('language_manager'
)->
getLanguageConfigOverride('fr', 'user.mail'
);
$configLanguageOverride->
set('password_reset.subject', 'fr subject [user:display-name]'
)->
save();
$configLanguageOverride->
set('password_reset.body', 'fr body [user:display-name] and token link [user:one-time-login-url]'
)->
save();
// Current language is 'en'.
$currentLanguage =
$this->container->
get('language_manager'
)->
getCurrentLanguage()->
getId();
$this->
assertSame('en',
$currentLanguage);
// Set preferred_langcode to 'zh-hant'.
$user =
$this->
createUser();
$user->
set('preferred_langcode', 'zh-hant'
)->
save();
$preferredLangcode =
$user->
getPreferredLangcode();
$this->
assertSame('zh-hant',
$preferredLangcode);
// Recovery email should respect user preferred langcode by default if
// langcode not set.
$this->
config('system.site'
)->
set('mail', 'test@example.com'
)->
save();