Language switch using PHP

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

Moderators: infograf768, 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.
Locked
developeronex
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

Hi,

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( 'DS', DIRECTORY_SEPARATOR );
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');
$mainframe->initialise();
$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.
$lang->load(null,null,"en-GB",true);

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

Any help appreciated.

Kind Regards
Kay

Locked

Return to “Language - Joomla! 2.5”