I´m aware that a similar qustion is asked here: Get current language in external script (Joomla 3.3)
but it seems that noone has understood the problem correctly. I´m having the exact same problem, so here is my example, maybe it is easier to understand:
On previous Joomla sites I´ve used this script to get the current language in external script, and it works perfectly in Joomla 2.5 framework, but for some reason it doesn´t in Joomla 3.xx. In Joomla 3 $CurrentlangString always resolves to "en-GB" even though another language is active:
define( '_JEXEC', 1 ); define( '_VALID_MOS', 1 ); define( 'JPATH_BASE', $_SERVER["DOCUMENT_ROOT"]); define( 'DS', DIRECTORY_SEPARATOR ); require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' ); require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' ); require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'factory.php' ); $mainframe = JFactory::getApplication('site'); $mainframe->initialise(); $Currentlang = JFactory::getLanguage(); $CurrentlangString = $Currentlang->getTag();
Please advice what is wrong here..
Here is a little bonus info that may help a little. When loading the code above in external file under Joomla 3, it seems that it does indeed load the framework, because I have no problem accessing the user object and get the current user´s infos, but for some strange reason I cannot get the current language..
define( '_VALID_MOS', 1 );