change the JText function

General questions regarding the use of languages in Joomla! 1.5.

Moderator: General Support Moderators

Locked
ited
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Tue Jun 22, 2010 2:47 pm

change the JText function

Post by ited » Thu Aug 26, 2010 5:47 pm

Hi,

I don't know if this is the right topic to post my question in.

Well, I have a problem. I need a way to easily change the translation of a string, so I figured it would be the best to change the JText::_ function.
I changed the function so it would look like this :

JText::_($string, $jsSafe=false, $language='');

It tried it and it works great. If it's used like intended (without the 3rd argument) it works like normal.
If the $language argument is not empty, it checks if the language exists, if not it returns the active language translation.

If the language exists...Here I have no idea what to do.
I tried :

Code: Select all

else 
		{
			$lan = JLanguage::getInstance($language);
			//$lan->setLanguage($language);
			//$lan->load();			
			
			return $lan->_($string,$jsSafe);
		}
I also tried the commented lines, it doesn't work.

Does anyone know how to get the translation of a string for a specified language?
I need it, because I have to be able to dynamically and quickly change the translation of a string without changing the website language.

Any answer would be great :)

thx

jash123
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Sun Dec 06, 2009 3:49 am

Re: change the JText function

Post by jash123 » Sat Oct 15, 2011 4:10 pm

try

$locale = "es_ES"; // for example, for spanish

$lang =& JLanguage::getInstance($locale);


Locked

Return to “Language - Joomla! 1.5”