Multilingual Moodle

October 25, 2011

We’re working on two Joomla-Moodle multilingual e-learning sites for a non-profit customer of ours, in English and Persian.

Moodle used to have no built-in translation capability as best I can remember (back in 2003 …) but the text filter plugins in Moodle have changed that. Now you can enter <span> tags with lang attributes and a “multilang” class to enter content as follows:

<span lang="en" class="multilang">Some English text here</span>
<span lang="fa" class="multilang">Some Persian text here</span>

I purposely didn’t type in Persian above, since it may not display properly for everyone.

The idea with the above is that Moodle will then only show the currently selected language. That works, except for the course names, which are still untranslatable. For sites with just two or three languages you can just include both language versions in the course name, e.g. “Management 101 – Persian Translation Here”. Not ideal, but gets the job done. ¬†This was our solution in our 2003 run-in with Moodle and is still our solution today. There probably is a way to do this properly but it would involve much programming and redoing of Moodle’s title fields.

We’ll be using/building a Moodle theme that supports left-to-right as well as right-to-left languages. We are doing the same in Joomla.

We are using Joomdle to connect Moodle with Joomla. This works great for Joomla 1.5 and JoomFish 2. Joomdle has a development version that’s compatible with Joomla 1.7, but does not yet offer multilingual support, so we are stuck with Joomla 1.5 and JoomFish for now.

Joomla by default will show both <span> tags, so the template needs a little PHP love to hide the non-relevant language content. Here is what we came up with, which works great for just two languages:

<?php 

$registry = JFactory::getConfig();
$jfLang = $registry->getValue("joomfish.language", false);
if($jfLang->shortcode == 'fa'){
?>
<style type="text/css">
span[lang|="en"]{
display:none!important;
}
</style>
<?php
}
if($jfLang->shortcode == 'en'){
?>
<style type="text/css">
span[lang|="fa"]{
display:none!important;
}
</style>
<?php
}
?>

We just inserted this at the end of the <head> portion of our template’s index.php file.