Skip to content

Commit 790f7eb

Browse files
Internal: Fix user-selected locale in registration email and confirmation message - refs BT#21596
1 parent f83c8a0 commit 790f7eb

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

public/main/auth/inscription.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,9 +1171,9 @@
11711171
$recipient_name = api_get_person_name($values['firstname'], $values['lastname']);
11721172
$textAfterRegistration =
11731173
'<p>'.
1174-
get_lang('Dear').' '.
1174+
get_lang('Dear', $userEntity->getLocale()).' '.
11751175
stripslashes(Security::remove_XSS($recipient_name)).',<br /><br />'.
1176-
get_lang('Your personal settings have been registered')."</p>";
1176+
get_lang('Your personal settings have been registered', $userEntity->getLocale())."</p>";
11771177

11781178
$formData = [
11791179
'button' => Display::button(
@@ -1205,11 +1205,11 @@
12051205
} else {
12061206
if (!empty($values['email'])) {
12071207
$linkDiagnostic = api_get_path(WEB_PATH).'main/search/search.php';
1208-
$textAfterRegistration .= '<p>'.get_lang('An e-mail has been sent to remind you of your login and password').'</p>';
1208+
$textAfterRegistration .= '<p>'.get_lang('An e-mail has been sent to remind you of your login and password', $userEntity->getLocale()).'</p>';
12091209
$diagnosticPath = '<a href="'.$linkDiagnostic.'" class="custom-link">'.$linkDiagnostic.'</a>';
12101210
$textAfterRegistration .= '<p>';
12111211
$textAfterRegistration .= sprintf(
1212-
get_lang('Welcome, please go to diagnostic at %s.'),
1212+
get_lang('Welcome, please go to diagnostic at %s.', $userEntity->getLocale()),
12131213
$diagnosticPath
12141214
);
12151215
$textAfterRegistration .= '</p>';

public/main/inc/lib/usermanager.lib.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ public static function create_user(
315315
$userId = $user->getId();
316316

317317
if (!empty($userId)) {
318+
$userLocale = $user->getLocale();
318319
if ($isAdmin) {
319320
self::addUserAsAdmin($user);
320321
}
@@ -377,7 +378,7 @@ public static function create_user(
377378
PERSON_NAME_EMAIL_ADDRESS
378379
);
379380
$tpl = Container::getTwig();
380-
$emailSubject = $tpl->render('@ChamiloCore/Mailer/Legacy/subject_registration_platform.html.twig');
381+
$emailSubject = $tpl->render('@ChamiloCore/Mailer/Legacy/subject_registration_platform.html.twig', ['locale' => $userLocale]);
381382
$sender_name = api_get_person_name(
382383
api_get_setting('administratorName'),
383384
api_get_setting('administratorSurname'),
@@ -405,6 +406,7 @@ public static function create_user(
405406
'mailWebPath' => $url,
406407
'new_user' => $user,
407408
'search_link' => $url,
409+
'locale' => $userLocale,
408410
];
409411

410412
// ofaj
Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1+
{% set user_locale = locale is defined ? locale : 'en' %}
2+
{% trans_default_domain 'messages' %}
3+
14
{% autoescape false %}
2-
<p>{{ 'Dear'|trans }} {{ complete_name }},</p>
3-
<p>{{ 'Welcome to this platform'|trans }}</p>
4-
<p>{{ 'You are registered to'|trans }} {{ 'platform.site_name' | api_get_setting }} {{ 'with the following settings:'|trans }}</p>
5-
<p>{{ 'Username'|trans }} : {{ login_name }}<br>
6-
{{ 'Pass'|trans }} : {{ original_password }}</p>
7-
<p>{{ 'For more details visit %s'|trans|format(search_link) }}</p>
8-
<p>{{ 'In case of trouble, contact us.'|trans }}</p>
5+
<p>{{ 'Dear'|trans({}, 'messages', user_locale) }} {{ complete_name }},</p>
6+
<p>{{ 'Welcome to this platform'|trans({}, 'messages', user_locale) }}</p>
7+
<p>{{ 'You are registered to'|trans({}, 'messages', user_locale) }} {{ 'platform.site_name' | api_get_setting }} {{ 'with the following settings:'|trans({}, 'messages', user_locale) }}</p>
8+
<p>{{ 'Username'|trans({}, 'messages', user_locale) }} : {{ login_name }}<br>
9+
{{ 'Pass'|trans({}, 'messages', user_locale) }} : {{ original_password }}</p>
10+
<p>{{ 'For more details visit %s'|trans({'%s': search_link}, 'messages', user_locale) }}</p>
11+
<p>{{ 'In case of trouble, contact us.'|trans({}, 'messages', user_locale) }}</p>
912

10-
<p>{{ 'Sincerely'|trans }}</p>
13+
<p>{{ 'Sincerely'|trans({}, 'messages', user_locale) }}</p>
1114
<p>{{ 'admin.administrator_name' | api_get_setting }} {{ 'admin.administrator_surname' | api_get_setting }}<br />
12-
{{ 'Manager'|trans }} {{ 'platform.site_name' | api_get_setting }}<br />
15+
{{ 'Manager'|trans({}, 'messages', user_locale) }} {{ 'platform.site_name' | api_get_setting }}<br />
1316

1417
{% if 'admin.administrator_phone' | api_get_setting %}
1518
{{ 'T. ' ~ 'admin.administrator_phone' | api_get_setting }}<br />
1619
{% endif %}
1720
{% if 'admin.administrator_email' | api_get_setting %}
18-
{{ 'Email'|trans ~ ': ' ~ 'admin.administrator_email' | api_get_setting }}
21+
{{ 'Email'|trans({}, 'messages', user_locale) ~ ': ' ~ 'admin.administrator_email' | api_get_setting }}
1922
{% endif %}
2023
</p>
2124
{% endautoescape %}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
{{ '['~ 'platform.site_name' | api_get_setting ~ '] ' ~ 'Your Reg'|trans ~ ' ' ~ 'platform.site_name' | api_get_setting }}
1+
{% set user_locale = locale is defined ? locale : 'en' %}
2+
{% trans_default_domain 'messages' %}
3+
4+
{{ '['~ 'platform.site_name' | api_get_setting ~ '] ' ~ 'Your Reg'|trans({}, 'messages', user_locale) ~ ' ' ~ 'platform.site_name' | api_get_setting }}

0 commit comments

Comments
 (0)