YOOtheme Pro is here! The best WordPress and Joomla theme. Learn more

Avatar kiweerouge asked

[TIP] [TUTORIAL] Translate menu subtitles

Hi,

This is a little tip to have multilanguage warp subtitle without create one menu per language.
It is very useful if you use a component like FaLang to translate your website content.

Tuto for Warp 7 and Joomla. You don't have to edit core files, so you can update your template without any problem.

First, you have to define the translations in the Language > Overrides. For exemple :
SUBTITLEABOUT => EN : About / FR : À propos
In your YOO template, you put the Key, not the value, as subtiles (in that case, SUBTITLEABOUT, for your About menuitem).

Now, you have to edit the widget.php. Copy the
/templates/yoo_XXXXX/layouts/widget.php to /templates/yoo_XXXXX/styles/YOURSTYLE/layouts/widget.php

inside the /templates/yoo_XXXXX/styles/YOURSTYLE/layouts/widget.php
add

$lang=& JFactory::getLanguage();  
$langTag = $lang->getTag(); // get the current language

at the top, and

$ini_array = parse_ini_file("language/overrides/".$langTag.".override.ini"); // open the language override of the current language  
foreach ($ini_array as $c => $v) {  
    $content=str_replace($c, $v, $content);  
}

just after

$content = $this['menu']->process($widget, array('pre', 'subnav', $renderer, 'post'));

That's all :)

Now you can add as many subtitle as you want, in as many language as you need, just translate them with the override language system fo joomla, and they display correctly in your website !

  • Joomla
  • Tutorial

Edited

6 Answers

0

Avatar michael.maass Support Online answered

I could not try it myself yet, but the use of the language constants and the Joomla language overrides sounds sensible.

The fact that you described a non-destructive approach via a custom style is even better.

Thanks for sharing your findings

Edited

0

Avatar gasonline answered

Hello,

I'm using Joomla 3.5 and FaLang with yoo Uniq theme but this don't work for me,...

May be that this don't work with new update of J3.5?

Any suggestions?

Thanks.
Regards.

0

Avatar kiweerouge answered

I @gasonline,

I haven't test it with joomla 3.5 yet; but I'm pretty sure this should work.

In the Uniq theme parameters, are you sure you define the key (SUBTITLEABOUT in my example) as subtitle ?

0

Avatar gasonline answered

Thanks for your reply kiweerouge.

Sure, I define key in the subtitle params in the Uniq theme but in frontpage show these param, not the value of the language override.

I will try this in another of my Joomla site to test,...

Thanks.
Regards.

0

Avatar kiweerouge answered

I tested it with joomla 3.5 and it works fine.

If the keys are displayed instead of the value, I would double check the edit of the widget.php (right code at the right places, ...).

Know someone who can answer? Share a link to this question via email or twitter.