2

In Joomla 2.5 it is possible to get the current language of a visitor in an external script like this:

$mainframe = JFactory::getApplication('site');
$mainframe->initialise();
$jdocument = JFactory::getDocument();
$jdocument->getLanguage();

I couldn't find out how to get the language in Joomla 3.3. The framework loads, but the language is always defined as 'en'.

I’ve also tried various other options like:

$japplication = JApplicationWeb::getInstance();
$japplication->initialise();

Did anyone experience the same issue? Is this a Bug?

2

2 Answers 2

1

I had kinda the same problem, but in the end I figured out how to make it work for my specific application using an alternative method. Watch my solution here: Getting current language in Joomla 3 in external script seems difficult.. but works fine in J2.5

Hope you can use the same method :)

0

This question was asked here a while ago and the key was to get and initialise the application like so:

$app = JFactory::getApplication('site');
$app->initialise();

$lang = JFactory::getLanguage()->getTag();
echo $lang;
1
  • Thanks for your answer. The question you linked relates to Joomla 2.5, in Joomla 2.5 my posted approach is working fine, but it is not in Joomla 3.3, I always get ‘en-GB’ instead of ‘de-DE’
    – Tobi
    Commented Jan 22, 2015 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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