Advertisement

use Joomla\CMS\Language\Text; GLOBAL ?

For Joomla! 5.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, 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
erick-b
Joomla! Explorer
Joomla! Explorer
Posts: 320
Joined: Tue Feb 17, 2015 10:25 am

use Joomla\CMS\Language\Text; GLOBAL ?

Post by erick-b » Fri Sep 06, 2024 10:44 am

as I need en each template overrides use Joomla\CMS\Language\Text;
is it possible to declare it as Global once fo all in index.php ?

thank you

Advertisement
SharkyKZ
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3057
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: use Joomla\CMS\Language\Text; GLOBAL ?

Post by SharkyKZ » Thu Sep 12, 2024 7:59 am

If you're using a proper code editor, it will automatically add import statements. So you don't have to worry about them. There is also an alternative way to use namespaced classes by writing fully qualifying class names everywhere, e.g.:

Code: Select all

Joomla\CMS\Language\Text::_('SOME_STRING')
There's also a silly way by creating a class alias. This is how JText works. You should not use this in current year though.
As of Joomla 4.4.0 you can and should use getLanguage() method in view and plugin layouts:

Code: Select all

$this->getLanguage()->_('SOME_STRING')

erick-b
Joomla! Explorer
Joomla! Explorer
Posts: 320
Joined: Tue Feb 17, 2015 10:25 am

Re: use Joomla\CMS\Language\Text; GLOBAL ?

Post by erick-b » Thu Sep 12, 2024 9:00 am

i am using Visual Studio Code
therefore there is no way , the silly way being the best one

thanks

SharkyKZ
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3057
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: use Joomla\CMS\Language\Text; GLOBAL ?

Post by SharkyKZ » Thu Sep 12, 2024 10:23 am

Code should do that. If it doesn't work, try installing a an extension like Intelephense. If Joomla classes are not found, add Joomla directory to the workspace.

erick-b
Joomla! Explorer
Joomla! Explorer
Posts: 320
Joined: Tue Feb 17, 2015 10:25 am

Re: use Joomla\CMS\Language\Text; GLOBAL ?

Post by erick-b » Fri Sep 13, 2024 9:36 am

thanks

Advertisement

Post Reply

Return to “Joomla! 5.x Coding”