2

I would like to modify a core component of joomla by setting up a condition based on the language the website is displaying. My edit don't seems to work and I can't get what I am doing wrong.

<?php
defined('JPATH_BASE') or die;
$lang = JFactory::getLanguage();
?>

<div class="Home"> 
<?php if ($lang->language == 'en-US') : ?>Home:
<?php elseif ($lang->language = 'fr-fr') : ?>Accueil :
<?php endif; ?>
</div> 
3

You should try this:

<div class="Home"> 
<?php
  $lang = JFactory::getLanguage();
  $result = $lang->getTag();
  if ($result=="fr-FR") { 
      echo 'Accueil: ';
  } 
  else { 
      echo 'Home: ';
  }
?> 
</div> 
  • @Lodder this task should be done wholly through language constants and all-caps placeholders, right? I dont quite know the correct terminology. Might you provide a best-practice answer? – mickmackusa May 7 at 10:24
  • @mickmackusa This is what I personally use and can't think of another approach. If you know of one, please feel free to submit another answer – Lodder May 7 at 11:30

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.