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']); $recipient_name = api_get_person_name($values['firstname'], $values['lastname']);
$textAfterRegistration = $textAfterRegistration =
'<p>'. '<p>'.
get_lang('Dear').' '. get_lang('Dear', $userEntity->getLocale()).' '.
stripslashes(Security::remove_XSS($recipient_name)).',<br /><br />'. 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 = [ $formData = [
'button' => Display::button( 'button' => Display::button(
@ -1205,11 +1205,11 @@ if ($form->validate()) {
} else { } else {
if (!empty($values['email'])) { if (!empty($values['email'])) {
$linkDiagnostic = api_get_path(WEB_PATH).'main/search/search.php'; $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>'; $diagnosticPath = '<a href="'.$linkDiagnostic.'" class="custom-link">'.$linkDiagnostic.'</a>';
$textAfterRegistration .= '<p>'; $textAfterRegistration .= '<p>';
$textAfterRegistration .= sprintf( $textAfterRegistration .= sprintf(
get_lang('Welcome, please go to diagnostic at %s.'), get_lang('Welcome, please go to diagnostic at %s.', $userEntity->getLocale()),
$diagnosticPath $diagnosticPath
); );
$textAfterRegistration .= '</p>'; $textAfterRegistration .= '</p>';

@ -315,6 +315,7 @@ class UserManager
$userId = $user->getId(); $userId = $user->getId();
if (!empty($userId)) { if (!empty($userId)) {
$userLocale = $user->getLocale();
if ($isAdmin) { if ($isAdmin) {
self::addUserAsAdmin($user); self::addUserAsAdmin($user);
} }
@ -377,7 +378,7 @@ class UserManager
PERSON_NAME_EMAIL_ADDRESS PERSON_NAME_EMAIL_ADDRESS
); );
$tpl = Container::getTwig(); $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( $sender_name = api_get_person_name(
api_get_setting('administratorName'), api_get_setting('administratorName'),
api_get_setting('administratorSurname'), api_get_setting('administratorSurname'),
@ -405,6 +406,7 @@ class UserManager
'mailWebPath' => $url, 'mailWebPath' => $url,
'new_user' => $user, 'new_user' => $user,
'search_link' => $url, 'search_link' => $url,
'locale' => $userLocale,
]; ];
// ofaj // ofaj

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