Search
Other Sourcerer questions
Forum

Migrating strings on yootheme

Luis's Avatar Luis
Hi Peter,

I was trying to migrate my translations strings that I have inside yootheme Pro pages from Jtext to text:

[source]<?php echo JText::_('estilos_diferenciados'); ?>[/source]

The problem is that is that by doing that I get:

Class "Text" not found

If I add use Joomla\CMS\Language\Text; it solves it, however thats not a good solution since I have a lot of them.

Im not sure if this is something to do from sourcerer side...

Could you have a look?

Regards
Peter van Westen's Avatar Peter van Westen ADMIN
JText was a class name globally available in Joomla 3. It is not available in Joomla 4, as everything moved to namespaces.
You would have to change your syntax to:
<?php echo \Joomla\CMS\Language\Text::_('estilos_diferenciados'); ?>

You could make these replacements pretty easily with DB Replacer:
regularlabs.com/dbreplacer
Please post a rating at the Joomla! Extensions Directory
Luis's Avatar Luis
That's what I did, however it returns the error when using it on yootheme.
Peter van Westen's Avatar Peter van Westen ADMIN
What exact syntax are you using? And what exact error are you getting?
Please post a rating at the Joomla! Extensions Directory
Luis's Avatar Luis
Using:
[source]<?php echo Text::_('estilos_diferenciados'); ?>[/source]

Getting:
Class "Text" not found
Peter van Westen's Avatar Peter van Westen ADMIN
See my previous reply then.
Please post a rating at the Joomla! Extensions Directory
Luis's Avatar Luis
Sorry, I did not noticed that in your reply there was an extra syntax, however that's the same class that I´ve refered to in the first comment, that I wouldn´t want to add at every translation.

Could there be a way to add the class to to component itself?

Im saying this because even without Yootheme the problem remains with the use of Cassiopeia and the string inserted directly at the article, here´s the call stack if you find it usefull.
Confidential information:
(hidden)
Peter van Westen's Avatar Peter van Westen ADMIN
No, you will not be able to use JText (or Text) directly through php (using Sourcerer).
You will have to add the use statement or use the full namespace class.

Use my initial reply to see how. And how you can easily change that in your existing uses.
Please post a rating at the Joomla! Extensions Directory
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription