2

How could I localized the site title / headline and slogan of a Joomla site. I have got localized menus with localized pages, but I have no idea how could I make site title multilingual?

Any ideas will be highly appreciated.

2

Using PHP, you can get the current language in Joomla like this:

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

You can then use an if-else statement to display localized title:

  if ($current == "en-GB") { 
      // English title here
  } 
  elseif ($current == "es-ES") { 
      // Spanish title here
  }
  elseif ($current == "nb-NO") { 
      // Norwegian title here
  }
  else { 
      // Default title here (in case none of the above matches)
  } 

This code can be used in your templates index.php file, in a module that supports PHP code (e.g. Custom HTML Advanced), or in any module using Sourcerer to include the PHP code.

1
  • Great. It worked. I installed Sourcerer and Custom HTML Advanced modules. I placed such code there: {source} <?php $lang = JFactory::getLanguage(); $current = $lang->getTag(); ?> {/source} <h1 class="stl-headline" data-left="1.23%"> <a href="/"> {source} <?php if ($current == "en-GB") { // English title here echo "English title"; } elseif ($current == "es-ES") { echo "Spanish title"; } else { // default title echo "Мобилен Масаж"; } ?> {/source} </a> </h1>
    – joro
    Feb 12 '15 at 20:31
2

If you place the title / slogan in a module, you can assign a language to the module, so it will only appear with the desired language.

2
  • Yeah, this is a solution. But when I enter some new pages, I have to assign the correct module to them. It is much manual work. But Valentin, thanks for the solution!
    – joro
    Feb 12 '15 at 20:27
  • A multilingual website is a lot of manual work indeed! But with this solution you have everything configurative (without writing any code). Cheers. Feb 12 '15 at 20:50
1

You can override or insert your own keys when going to Extensions > Languages > Overrides. After that, you only need to put these keys into your site configuration.

If the key isn't translated, you may have to make/override a plugin.

1
  • I saw my template uses this: <?php echo $this->params->get('siteTitle'); ?> And I overrided siteTitle as you described. But It did not change the site title. If it worked, it would be the best solution! Clear and easy to extend!
    – joro
    Feb 12 '15 at 20:24

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.