Tuesday, March 26, 2013

Fixing Multi language support in Moodle

Deutsch: Logo der freien Software Moodle moddl...

Last week I was asked by +Charles Matthews to review WM.UK upcoming Wikipedia tutoring system being developed on on the open source Moodle system.

I've been thinking of different option to better support Wikipedia coaching in different languages  I have been reviewing and testing Moodle in the last few weeks to that end.

I'm really interested in developing course ware for both English and Hebrew editions (as a start).

Multilingual content


While Moddle is internationalized, support of multilingual content requires using a somewhat clumsy technique. One need to use html and store different languages content in top level div elements. Then you have to switch on Moodle's multilingual filter which can hide all the language version which are incompatible with the language selector's settings.

However due to a bug the the html editor mangles the html code and mangles the top level <span> element required.
 <span lang="XX" class="multilang">your_content_here</span>
 <span lang="YY" class="multilang">your_content_in_other_language_here</span>


Luckily I found a patch in the forum - but it did not work. However it got me started hacking the filter and I was soon able to get it to work with more and more elements.

I thought I'd share the bug fix online in case someone is stuck with this. Once I figure how I'll send a patch to the Moodle dev team.

the fix is as follows - search and replace span with div
then replace in line 57 with:

this just tells the filter to also consider some extra attributes that certain Moodle module  (e.g. wiki) place into divs such as xml:lang="XX"

the change is that you need to use <div> elements as your top level tags:

<div lang="en" class="multilang">your English content here</div>
<div lang="he" class="multilang">your Hebrew content here</div>

Remaining Tasks

One things is still unclear - how to specify title translation. While the filter's documentation states this is supported and it comes up in different places in the U.I. it is unclear how this can be done - if it is even supported at all.

See also

  • http://docs.moodle.org/23/en/Multi-language_content_filter
  • http://www.moodlenews.com/2013/23-moodle-videos-from-lynda-com-for-free/

Enhanced by Zemanta