I want to return a JText value from my helper.php file from my own module.
class modMyFormularHelper
{
public static function getValue()
{
$test = JText::_('MOD_MYFORMULAR_VALUE');
return $test;
}
For this I have a "de-DE.mod_myformular.ini" in the language folder. The problem is I only get MOD_MYFORMULAR_VALUE in the Frontend.
If I write the JText in the default.php from the tmpl-folder... This works fine!
So how can I get the language strings in the helper file? Thanks
You have two options. The first you already know, which is to migrate the JText::_(); method to the default.php file. The second is to manually load the language file inside the getValue() method like so:
Although not required, you might need to set the second $basePath if the needed language file is in the back-end.
For this instance however, Since you are not performing any CRUD operations and as is the getValue() method will always return the same value; it makes more sense to simply render the language translation text inside your default.php file.