As per today there is no satisfying solution how to integrate Zoo-elements easily in a translated language but I found a simple solution. As the Zoo component has a very complex database structure it is difficult to translate all the points using Joomfish. There are no usable "Content Elements" covering all the needs in Joomfish.

I discovered a simple way to determine the actual language and, depending on the chosen language, to translate in to it, to show the desired output regarding the translation. To be honest, this works on any other part of Joomla! as well (i.e. templates, modules, plugins). The tutorial focuses on Zoo because I needed multilanguage support on my own site.

You may determine the selected language in Joomla! with the following syntax:

// References the global language object
$lang = JFactory::getLanguage();  

// Display the full name
echo $lang->getName(); // Example: German (DE-CH-AT)  

// Display the short name (tag) 
echo $lang->getTag(); // Example: de-DE

As shown, you have to execute PHP codes. This is not possible without an appropriate extension. If you would use this code in any input window it would be filtered by default. To execute PHP code I opted for the very popular extension from NoNumber! called Sourcerer (see link above). With Sourcerer you may execute PHP-, HTML-, Javascript- and CSS code in any content field. The big advantage of Sourcerer is that the plugin not only works on Input fields itself but as well in modules, components, META tags and so on. This functionality is used to translate Zoo elements.

To activate Sourcerer, you have to use the following syntax: { source }CODE{ /source } (without any spaces in the following examples I will use the spaces but they are not used in real programming codes!)

To determine if the German language had been chosen, I use the following syntax. I limit myself to 2 conditions, because I need only 2 languages on the project page. You can extend the if statement accordingly if you offer 3 or more languages. We use the shorthand writing as this will shorten the query and it is easier to use.

$lang = JFactory::getLanguage();
if ($lang->getTag() == "de-DE")
{
    echo "German is activated!";
}
else
{
    echo "German is not activated!";
}

Here we see, that we will reference first the global language object and then, using a simple getTag() method inside the if-statement, we determine if the de-DE (i.e. German) is active. If it isn\'t we will execute the else-statement.

This might be used in all Zoo elements for translation. The only problem is the title. There it will not work as it is filtered separately and the Sourcerer syntax will be lost.

As an example, I entered at the Meta information element (below) the following syntax (here the complete code is in a line, because it is not about text areas, but lines of text):

// Translation for Author
{ source }getTag() == "de-DE") { echo 'Geschrieben von'; } else { echo 'Written by'; } ?>{ /source }

// Translation for the publishing category
{ source }getTag() == "de-DE") { echo 'Veröffentlicht in'; } else { echo 'Posted in'; } ?>{ /source }

To see the translated output, just click on the German / English flag above. The Meta data will be changed accordingly.

Conclusion:

It is really easy to translate almost any text even when JoomFish does not function properly or it is complicated to set it up. The tutorial is not connected to any specific component (although I showed it here in combination with Zoo). As well it will work almost everywhere in Joomla!. Using this tutorial you may translate quickly parts where you normally wouldn\'t have access. The only downside is it will not work on titles.

Have fun!

Translated by X-Bit (MCM Swiss)