No Code Attached Yet
avatar garkell
garkell
4 Jan 2023

What needs to be fixed

Language file needs to be loaded to cater for 3rd party components using the MailTemplate

Why this should be fixed

Without the language files being loaded the 3rd party components can't adequately utilise this whole component.

How would you fix it

In the tmpl file for the list view (administrator/components/com_mails/tmpl/templates/default.php) add the following:
Insert line 13
use \Joomla\CMS\Factory;
Insert line 74

// load components language file
Factory::getLanguage()->load($component, JPATH_ADMINISTRATOR);

Replace line 79 with
<?php echo Text::_(STRTOUPPER($component) . '_MAIL_' . STRTOUPPER($sub_id) . '_TITLE'); ?>
And 103 with
<?php echo Text::_(STRTOUPPER($component) . '_MAIL_' . STRTOUPPER($sub_id) . '_DESC'); ?>

Side Effects expected

Possibly reduced speed to load.

avatar garkell garkell - open - 4 Jan 2023
avatar joomla-cms-bot joomla-cms-bot - change - 4 Jan 2023
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 4 Jan 2023
avatar garkell garkell - change - 4 Jan 2023
The description was changed
avatar garkell garkell - edited - 4 Jan 2023
avatar garkell garkell - change - 4 Jan 2023
The description was changed
avatar garkell garkell - edited - 4 Jan 2023
avatar garkell garkell - change - 4 Jan 2023
Title
Display List Tmpl of MailTemplates
[4.2.6] Display List Tmpl of MailTemplates
avatar garkell garkell - edited - 4 Jan 2023
avatar joomdonation joomdonation - change - 8 Jan 2023
Status New Closed
Closed_Date 0000-00-00 00:00:00 2023-01-08 14:49:30
Closed_By joomdonation
avatar joomdonation joomdonation - close - 8 Jan 2023
avatar joomdonation
joomdonation - comment - 8 Jan 2023

We load language files for third party extensions already. It is called here https://github.com/joomla/joomla-cms/blob/4.2-dev/administrator/components/com_mails/src/View/Templates/HtmlView.php#L120 and the actual code which loads language file can be found here https://github.com/joomla/joomla-cms/blob/4.2-dev/administrator/components/com_mails/src/Helper/MailsHelper.php#L67 . If you read the code, it loads language files for not only component but also module and plugin. So your suggested code is not valid

As for your suggested code change on line 79 and 103 (the lines number is not right to me), it is not needed, too. Adding strotoupper is not required because it is handled automatically by our language API, see https://github.com/joomla/joomla-cms/blob/4.2-dev/libraries/src/Language/Language.php#L317

Base on the above information, this issue is invalid, so I'm closing it. Feel free to re-open if there are something more to discuss. Thanks !

avatar garkell
garkell - comment - 9 Jan 2023

Thank you for highlighting all this for me and I apologise for wasting time. I will read through this code to see why my components language text didn't work as I expected it. Cheers.

avatar joomdonation
joomdonation - comment - 9 Jan 2023

Your welcome @garkell . As mentioned, If you found something which need to be addressed in the core code, feel free to add a comment here or re-open the issue so that we can discuss about it further.

avatar garkell
garkell - comment - 9 Jan 2023

Ahhh so the admin list view of the template records is using the site language file rather than the admin one, this is why my language didn't get picked up. No problems I will change my component accordingly. (I keep learning every time I delve into the code and I must do more delving.) Thanks again for your guidance. Cheers.

avatar joomdonation
joomdonation - comment - 9 Jan 2023

Ahhh so the admin list view of the template records is using the site language file rather than the admin one, this is why my language didn't get picked up

It is not right. It looks for admin language file, not site language file. Not sure how you insert the mail templates for your extension into #__mail_templates table? I would suggest you to look at that table, find the records related to your extension and check data of extension column. It should be set to the name of the extension (like com_contact, com_banner..). I guess right now, it is empty and that's why the language file of your component is not loaded. There is a PR for fixing that behavior #39540 (I know you commented on that PR, just want to make sure it is set to right value)

For example, here are the language items used for com_contact component and it's from admin language file https://github.com/joomla/joomla-cms/blob/4.2-dev/administrator/language/en-GB/com_contact.ini#L151-L154

avatar brianteeman
brianteeman - comment - 9 Jan 2023

To see exactly which language files are loaded you should enable the language debug in global configuration

avatar garkell
garkell - comment - 11 Jan 2023

Apologies, I don't know what I was looking at, but yes all is good now. Cheers.

Add a Comment

Login with GitHub to post a comment