Language switch using PHP

General questions regarding the use of languages in Joomla! 2.5.
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Wed Jun 25, 2014 4:13 pm

Language switch using PHP

Post by developeronex » Wed Jun 25, 2014 4:23 pm


I am trying to switch my language in a AJAX Call unfortunately couldn't do it. Default language of my site is German.

For one of the the AJAX request alone I need to switch to English.

I have added German and English languages to language packs.

Code: Select all

define( '_JEXEC', 1 );
define('JPATH_BASE', substr(dirname(__FILE__),0,strrpos(dirname(__FILE__), DS, strrpos(dirname(__FILE__), DS) - strlen(dirname(__FILE__)) - 7))); //getting the root path

require_once ( JPATH_BASE.DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe =JFactory::getApplication('site');
$session = JFactory::getSession();

//Till this all seems to work
$lang = JFactory::getLanguage();
//At this stage it says de-DE $lang->getTag()

//forcing my page to be en-GB.

//Still says de-DE $lang->getTag() and JText::_('KEY') - is not translating, just returns me KEY

Any help appreciated.

Kind Regards


Return to “Language - Joomla! 2.5”