Internal: Fix user-selected locale in registration email and confirmation message - refs BT#21596

pull/5688/head
christianbeeznst 4 months ago
parent f83c8a0b13
commit 790f7eb87e
  1. 8
      public/main/auth/inscription.php
  2. 4
      public/main/inc/lib/usermanager.lib.php
  3. 23
      src/CoreBundle/Resources/views/Mailer/Legacy/content_registration_platform.html.twig
  4. 5
      src/CoreBundle/Resources/views/Mailer/Legacy/subject_registration_platform.html.twig

@ -1171,9 +1171,9 @@ if ($form->validate()) {
$recipient_name = api_get_person_name($values['firstname'], $values['lastname']);
$textAfterRegistration =
'<p>'.
get_lang('Dear').' '.
get_lang('Dear', $userEntity->getLocale()).' '.
stripslashes(Security::remove_XSS($recipient_name)).',<br /><br />'.
get_lang('Your personal settings have been registered')."</p>";
get_lang('Your personal settings have been registered', $userEntity->getLocale())."</p>";
$formData = [
'button' => Display::button(
@ -1205,11 +1205,11 @@ if ($form->validate()) {
} else {
if (!empty($values['email'])) {
$linkDiagnostic = api_get_path(WEB_PATH).'main/search/search.php';
$textAfterRegistration .= '<p>'.get_lang('An e-mail has been sent to remind you of your login and password').'</p>';
$textAfterRegistration .= '<p>'.get_lang('An e-mail has been sent to remind you of your login and password', $userEntity->getLocale()).'</p>';
$diagnosticPath = '<a href="'.$linkDiagnostic.'" class="custom-link">'.$linkDiagnostic.'</a>';
$textAfterRegistration .= '<p>';
$textAfterRegistration .= sprintf(
get_lang('Welcome, please go to diagnostic at %s.'),
get_lang('Welcome, please go to diagnostic at %s.', $userEntity->getLocale()),
$diagnosticPath
);
$textAfterRegistration .= '</p>';

@ -315,6 +315,7 @@ class UserManager
$userId = $user->getId();
if (!empty($userId)) {
$userLocale = $user->getLocale();
if ($isAdmin) {
self::addUserAsAdmin($user);
}
@ -377,7 +378,7 @@ class UserManager
PERSON_NAME_EMAIL_ADDRESS
);
$tpl = Container::getTwig();
$emailSubject = $tpl->render('@ChamiloCore/Mailer/Legacy/subject_registration_platform.html.twig');
$emailSubject = $tpl->render('@ChamiloCore/Mailer/Legacy/subject_registration_platform.html.twig', ['locale' => $userLocale]);
$sender_name = api_get_person_name(
api_get_setting('administratorName'),
api_get_setting('administratorSurname'),
@ -405,6 +406,7 @@ class UserManager
'mailWebPath' => $url,
'new_user' => $user,
'search_link' => $url,
'locale' => $userLocale,
];
// ofaj

@ -1,21 +1,24 @@
{% set user_locale = locale is defined ? locale : 'en' %}
{% trans_default_domain 'messages' %}
{% autoescape false %}
<p>{{ 'Dear'|trans }} {{ complete_name }},</p>
<p>{{ 'Welcome to this platform'|trans }}</p>
<p>{{ 'You are registered to'|trans }} {{ 'platform.site_name' | api_get_setting }} {{ 'with the following settings:'|trans }}</p>
<p>{{ 'Username'|trans }} : {{ login_name }}<br>
{{ 'Pass'|trans }} : {{ original_password }}</p>
<p>{{ 'For more details visit %s'|trans|format(search_link) }}</p>
<p>{{ 'In case of trouble, contact us.'|trans }}</p>
<p>{{ 'Dear'|trans({}, 'messages', user_locale) }} {{ complete_name }},</p>
<p>{{ 'Welcome to this platform'|trans({}, 'messages', user_locale) }}</p>
<p>{{ 'You are registered to'|trans({}, 'messages', user_locale) }} {{ 'platform.site_name' | api_get_setting }} {{ 'with the following settings:'|trans({}, 'messages', user_locale) }}</p>
<p>{{ 'Username'|trans({}, 'messages', user_locale) }} : {{ login_name }}<br>
{{ 'Pass'|trans({}, 'messages', user_locale) }} : {{ original_password }}</p>
<p>{{ 'For more details visit %s'|trans({'%s': search_link}, 'messages', user_locale) }}</p>
<p>{{ 'In case of trouble, contact us.'|trans({}, 'messages', user_locale) }}</p>
<p>{{ 'Sincerely'|trans }}</p>
<p>{{ 'Sincerely'|trans({}, 'messages', user_locale) }}</p>
<p>{{ 'admin.administrator_name' | api_get_setting }} {{ 'admin.administrator_surname' | api_get_setting }}<br />
{{ 'Manager'|trans }} {{ 'platform.site_name' | api_get_setting }}<br />
{{ 'Manager'|trans({}, 'messages', user_locale) }} {{ 'platform.site_name' | api_get_setting }}<br />
{% if 'admin.administrator_phone' | api_get_setting %}
{{ 'T. ' ~ 'admin.administrator_phone' | api_get_setting }}<br />
{% endif %}
{% if 'admin.administrator_email' | api_get_setting %}
{{ 'Email'|trans ~ ': ' ~ 'admin.administrator_email' | api_get_setting }}
{{ 'Email'|trans({}, 'messages', user_locale) ~ ': ' ~ 'admin.administrator_email' | api_get_setting }}
{% endif %}
</p>
{% endautoescape %}

@ -1 +1,4 @@
{{ '['~ 'platform.site_name' | api_get_setting ~ '] ' ~ 'Your Reg'|trans ~ ' ' ~ 'platform.site_name' | api_get_setting }}
{% set user_locale = locale is defined ? locale : 'en' %}
{% trans_default_domain 'messages' %}
{{ '['~ 'platform.site_name' | api_get_setting ~ '] ' ~ 'Your Reg'|trans({}, 'messages', user_locale) ~ ' ' ~ 'platform.site_name' | api_get_setting }}

Loading…
Cancel
Save