Skip to content

Commit

Permalink
[5.2] Mail Templates language file loading not using the MailsHelper:…
Browse files Browse the repository at this point in the history
…:loadTranslationFiles (#43475)

* load the language files via MailsHelper

* Update HtmlView.php

* Fix the language load for the templates

* Dont fix things outside of the scope of this PR
  • Loading branch information
zero-24 authored Jul 16, 2024
1 parent deea9d6 commit a682c8b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
11 changes: 6 additions & 5 deletions administrator/components/com_mails/src/Helper/MailsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ public static function mailtags($mail, $fieldname)
* Load the translation files for an extension
*
* @param string $extension Extension name
* @param string $language Language to load
*
* @return void
*
* @since 4.0.0
*/
public static function loadTranslationFiles($extension)
public static function loadTranslationFiles($extension, $language = 'en-GB')
{
static $cache = [];

Expand Down Expand Up @@ -96,12 +97,12 @@ public static function loadTranslationFiles($extension)
break;
}

$lang->load($extension, JPATH_ADMINISTRATOR)
|| $lang->load($extension, $source);
$lang->load($extension, JPATH_ADMINISTRATOR, $language, true)
|| $lang->load($extension, $source, $language, true);

if (!$lang->hasKey(strtoupper($extension))) {
$lang->load($extension . '.sys', JPATH_ADMINISTRATOR)
|| $lang->load($extension . '.sys', $source);
$lang->load($extension . '.sys', JPATH_ADMINISTRATOR, $language, true)
|| $lang->load($extension . '.sys', $source, $language, true);
}

$cache[$extension] = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\Component\Mails\Administrator\Helper\MailsHelper;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
Expand Down Expand Up @@ -85,14 +86,11 @@ public function display($tpl = null)
throw new GenericDataException(implode("\n", $errors), 500);
}

list($component, $template_id) = explode('.', $this->item->template_id, 2);
list($extension, $template_id) = explode('.', $this->item->template_id, 2);
$fields = ['subject', 'body', 'htmlbody'];
$this->templateData = [];
$language = $this->getLanguage();
$language->load($component, JPATH_SITE, $this->item->language, true);
$language->load($component, JPATH_SITE . '/components/' . $component, $this->item->language, true);
$language->load($component, JPATH_ADMINISTRATOR, $this->item->language, true);
$language->load($component, JPATH_ADMINISTRATOR . '/components/' . $component, $this->item->language, true);

MailsHelper::loadTranslationFiles($extension, $this->item->language);

$this->master->subject = Text::_($this->master->subject);
$this->master->body = Text::_($this->master->body);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function display($tpl = null)
}

foreach ($extensions as $extension) {
MailsHelper::loadTranslationFiles($extension);
MailsHelper::loadTranslationFiles($extension, $defaultLanguageTag);
}

$this->addToolbar();
Expand Down

0 comments on commit a682c8b

Please sign in to comment.