Trouble with JText to toggle between languages

General questions regarding the use of languages in Joomla! 3.x.

Moderators: infograf768, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Post Reply
sokrates_mx5
Joomla! Explorer
Joomla! Explorer
Posts: 260
Joined: Tue Mar 24, 2009 12:30 pm

Trouble with JText to toggle between languages

Post by sokrates_mx5 » Mon Apr 19, 2021 10:15 pm

I'm improving the functions of the JMailAlerts extension and its plugins to better fulfill my needs and to function better on multi-lingual websites. By default the language of the JMailAlerts only change when one change the back-end language of admin, which works for all language the variables.

The original code do not use the $language_tag in $lang->load(); - by adding the $language_tag one should be able to change the language.

Code: Select all

$lang->load('plg_emailalerts_' . $this->_name, JPATH_ADMINISTRATOR, $language_tag);
The strange thing is when using the $language_tag option, then some JText variables change but not all of them. Those JText variables that do not change, do change when one toggle the back-end language of admin.

It doesn't matter if I create new JText varibles and override them with Language Override.

I use three plugins of JmailAlerts (jma_latestnews, jma_latest_post_kunena and jma_latestphoto). The titles of these three plugins to be presented in the MailAlert is generated by the following code:

Code: Select all

<?php echo JText::_($pluginParams->get('plugintitle')); ?>
This code is the same for all three plugins, but just for generating their titles.

The titles do not toggle between the languages for two of them (jma_latestnews and jma_latest_post_kunena), but does it for the third plugin (jma_latestphoto).

If I replace the code in jma_latestphoto with its language variable (<?php //echo JText::_("PLG_JMA_LP_JS_TRANSLATABLE_TITLE"); ?>), then the language does not change either for its title when changing the language of $language_tag.

Other JText language variables do change when one change the language of $language_tag. The following JText language variable do change the language when one change the language of $language_tag.

Code: Select all

<?php echo JText::_("JMA_KUNENA_DATE_CREATED"); ?>
I don't have any idea of what creates this strange and dysfunctional behavior.

Post Reply

Return to “Language - Joomla! 3.x”