Skip to content

Commit

Permalink
Internal: In legacy get_lang and templates isn't necessary to force t…
Browse files Browse the repository at this point in the history
…he locale - refs BT#21304

The locale is set in request
  • Loading branch information
AngelFQC committed Dec 23, 2023
1 parent 58399c0 commit da03c3e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
4 changes: 1 addition & 3 deletions public/main/inc/lib/internationalization.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,11 @@ function get_lang(string $variable): string

// Using symfony
$defaultDomain = 'messages';
$locale = api_get_language_isocode();

return $translator->trans(
$variable,
[],
$defaultDomain,
$locale
$defaultDomain
);
}

Expand Down
4 changes: 1 addition & 3 deletions public/main/inc/lib/usermanager.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ public static function create_user(
$language = 'en_US';
}

$locale = substr($language, 0, 2);
$now = new DateTime();
if (empty($expirationDate) || '0000-00-00 00:00:00' === $expirationDate) {
$expirationDate = null;
Expand Down Expand Up @@ -378,7 +377,7 @@ public static function create_user(
PERSON_NAME_EMAIL_ADDRESS
);
$tpl = Container::getTwig();
$emailSubject = $tpl->render('@ChamiloCore/Mailer/Legacy/subject_registration_platform.html.twig', ['locale' => $locale]);
$emailSubject = $tpl->render('@ChamiloCore/Mailer/Legacy/subject_registration_platform.html.twig');
$sender_name = api_get_person_name(
api_get_setting('administratorName'),
api_get_setting('administratorSurname'),
Expand Down Expand Up @@ -406,7 +405,6 @@ public static function create_user(
'mailWebPath' => $url,
'new_user' => $user,
'search_link' => $url,
'locale' => $locale,
];

// ofaj
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
{% autoescape false %}
{% set locale = locale|default('en') %}
<p>{{ 'Dear'|trans({}, null, locale) }} {{ complete_name }},</p>
<p>{{ 'Welcome to this platform'|trans({}, null, locale) }}</p>
<p>{{ 'You are registered to'|trans({}, null, locale) }} {{ 'platform.site_name' | api_get_setting }} {{ 'with the following settings:'|trans({}, null, locale) }}</p>
<p>{{ 'Username'|trans({}, null, locale) }} : {{ login_name }}<br>
{{ 'Pass'|trans({}, null, locale) }} : {{ original_password }}</p>
<p>{{ 'For more details visit %s'|trans({}, null, locale)|format(search_link) }}</p>
<p>{{ 'In case of trouble, contact us.'|trans({}, null, locale) }}</p>
<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>{{ 'Sincerely'|trans({}, null, locale) }}</p>
<p>{{ 'Sincerely'|trans }}</p>
<p>{{ 'admin.administrator_name' | api_get_setting }} {{ 'admin.administrator_surname' | api_get_setting }}<br />
{{ 'Manager'|trans({}, null, locale) }} {{ 'platform.site_name' | api_get_setting }}<br />
{{ 'Manager'|trans }} {{ '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({}, null, locale) ~ ': ' ~ 'admin.administrator_email' | api_get_setting }}
{{ 'Email'|trans ~ ': ' ~ 'admin.administrator_email' | api_get_setting }}
{% endif %}
</p>
{% endautoescape %}
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
{% set locale = locale|default('en') %}
{{ '['~ 'platform.site_name' | api_get_setting ~ '] ' ~ 'Your Reg'|trans({}, null, locale) ~ ' ' ~ 'platform.site_name' | api_get_setting }}
{{ '['~ 'platform.site_name' | api_get_setting ~ '] ' ~ 'Your Reg'|trans ~ ' ' ~ 'platform.site_name' | api_get_setting }}

0 comments on commit da03c3e

Please # to comment.