I'm trying to get the current selected language.

Here is the part of my code:

define('_JEXEC', 1);

if (file_exists(dirname(__FILE__) . '/defines.php')) {
    include_once dirname(__FILE__) . '/defines.php';

if (!defined('_JDEFINES')) {
    define('JPATH_BASE', dirname(__FILE__));
    require_once JPATH_BASE.'/includes/defines.php';

require_once JPATH_BASE.'/includes/framework.php';

$lang =& JFactory::getLanguage()->getTag();


echo $lang;

allways returns en-GB.

The website has the possibility of Ger and Eng. It also changes languages for different articles. I don't understand how I did not get the current selected language within php.

1 Answer 1


I do not think that it is possible. You are trying to get language outside of the application scope. You can try to instantiate the application:

$app = JFactory::getApplication('site');

But I doubt that it will help.

  • I thank you sir it helped.. but their is another line which has to be added after $app = JFactory::getApplication('site'); it is : $app->initialise(); Oct 31, 2014 at 13:10
  • Yeah forgot it. Glad that you made it. Oct 31, 2014 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.