How to translate a Moodle course A reliable procedure to localize the content of a course developed in Moodle, the open-source LMS.




  • Greater than 5 minutes, my friend!

    This article explains a procedure to translate the content of a course developed in Moodle, the open-source LMS (Learning Management System). Moodle doesn’t have out-of-the-box features to translate courses, even though its interface is available in over 100 languages. The workaround we suggest consists of the following 5 main steps:

    1. export the course through Moodle’s backup feature
    2. convert the relevant content to XLIFF
    3. translate these XLIFFs externally
    4. convert them back to XML, and
    5. restore the translated package as a new course.

    In order to fully translate a Moodle course, you need to translate several elements:

    • interface
    • system messages
    • course content
    • files (images, videos, attached documents, etc.)

    The interface, the system messages and all other strings of the core system are included in the Language Packs. Currently, there are over 100 languages available. If you want your course in a specific language, the first step is to download the corresponding language pack. We suppose you’re familiar with this task, otherwise check https://docs.moodle.org/31/en/Language_FAQ.

    The files that are uploaded into Moodle (from version 2.0) are given an SHA1 hash value, that is used as the basis to store the file. Without going into further details, this behaviour has several technical advantages, but it makes it also more difficult to read and edit the files by looking at the exported backup directory where files are stored. Our suggestion is to download the files to translate from Moodle instead, translate them offline following your usual workflow and finally upload the translated files once the rest of the contents are already translated.

    The last element is the course content. Moodle doesn’t provide (yet) a way to translate courses. Until a proper feature is offered by Moodle, our workaround leverages the XML files that are exported for backup purposes, and can be converted to XLIFF through Okapi Rainbow. XLIFF is a standard format for localization that can be opened in OmegaT or other CAT tools. After the translation phase, the last step is to import the course back to Moodle using the Restore function.

    Export

    1. Access Moodle as an administrator
    2. Click on the course you want to translate
    3. Go to Administration > Course administration > Backup
    4. Follow this procedure: https://docs.moodle.org/31/en/Course_backup
    5. Select activities, blocks, and all other items you want to translate and then click the Next button. Do not include data specific to the course history, such as users, user information, user role assignments, groups, groupings, user files, comments, user completion details, course logs and grade history in the backup.

    The exported file is a MBZ file, which is a compressed file including all course elements as XML files and all other files related to the course.

    directory2

    Filter creation

    In order to translate the course content in a CAT tool, first you need to identify the XML elements that are translatable. Then create a filter in the program used to convert the XML to XLIFF, Okapi Rainbow. We created a filter including all the elements that should be translated in an average course. You can download the filter here. Further information about filter creation can be found on http://okapiframework.org/wiki/index.php?title=XML_Filter. Course administrators might want to add further elements to the filter by editing it accordingly.

    Conversion from XML to XLIFF

    General instructions to convert one file format into another with Okapi Rainbow can be found on http://okapiframework.org/wiki/index.php?title=How_to_Extract_Text_for_Translation. There are a few details that you must pay attention to:

    • You should use the XML filter, not the XML Stream filter.
    • If you’re using OmegaT as a CAT tool, you should choose the “OmegaT Project” option in the Package Format tab, leaving the default options. The “Include post-processing hook” setting is very important: it will allow you to automatically create the return package.
    • If you’re using another CAT tool, then select the “Generic XLIFF” option in the Package Format tab.
    • Make sure the Filter Configuration is not set (set to <None> in the Input Document Properties dialog), if you want Rainbow to ignore some files. They will be copied to the working folder and later to the final folder, but they will not be converted/processed. This is especially useful if you have media files in your course, which can’t be translated with this procedure.

    Rainbow

    Translation

    The output of the conversion process is either an OmegaT project package or a directory with XLIFF files. The first one can be directly opened by OmegaT, the free and open-source translation tool. The XLIFF files can be opened by the vast majority of other CAT tools. Using OmegaT gives you the advantage to make use of the post-processing hook feature: when you create the target files, they will be automatically converted back to XML, therefore skipping the next step. In order to do so, you the “Also allow per-project external commands” option in Options > Saving and Output Options should be selected.

    Options

    Conversion from XLIFF to XML

    If you haven’t used OmegaT for translation, you need to go back to Rainbow and follow this procedure: http://okapiframework.org/wiki/index.php?title=How_to_Post-Process_Extracted_Text. The output of this step is a folder containing the translated XML and all the files/folders that you marked as non-translatable in the initial conversion step. You can now zip the whole directory to be imported back into Moodle.

    Import

    In order to import the course back into Moodle you need to use the Restore feature (not the Import feature, that is used to copy content from one course to another). Follow this procedure: https://docs.moodle.org/31/en/Course_restore. Make sure that you’re restoring the course as a new course and you’re not overwriting an existing one. Please note that your hosting provider might prevent you from importing new files larger than the server’s file size limit. If you’ve installed Moodle on a shared hosting there’s little you can do about it. Our suggestion is to reduce the zip file size by deleting one or more media file folders.

    backupRestore

    Final review

    Once you’re done, check the language settings (see https://docs.moodle.org/31/en/Language_settings). You can force Moodle’s interface language to be the same as the new course target language (i.e., if you have translated your course to Spanish, you can force Moodle to be shown in Spanish).

    At this point, you only need to review the whole course, double checking that everything is translated. We can’t guarantee that the sample filter provided above will expose each and every translatable element, so it’s important that you perform this final check before publishing the course.

    If you’re unsure about one of the above steps, please use the Comments section to ask. Also consider that I can help you translate your Moodle training course.

    Marco Cevoli

    About Marco Cevoli

    Technical translator, graphic designer, web localization expert and author of the first manual about OmegaT, the free and open-source CAT tool. Joiner-of-dots in my spare time.

    4 thoughts on “How to translate a Moodle course

    1. Awesome article, Mario! I love technical guides! So thank you so much for publishing it on The Open Mic as well. I have a question, though: don’t you think converting XML into XLIFF is a bit of an overkill?

      As far as I know some CATs can work work with XML, can’t they?

      I occasionally have to work with editable PDFs and most of the time I use Infix PDF Editor to convert the files into XML and then I just translate everything in MemoQ and import it back. Never really had any problem with that (*knocks on wood*) :)

    2. The conversion is meant to be done by a web designer or a project manager or a lead translator, so that he can send files to (fellow) translators without worrying about the tool the translators will use and without the translators worrying about tagging files or configure their CAT tools. The XML produced by Moodle backup include ALL content in a course, most of it being non-translatable content. Dealing with those files in your CAT tool is quite complex, because there are many elements to scan and tag. If you’re working alone you might want to try, but if you need to share the project and being tool-agnostic, it’s advisable to produce a bilingual file to work with.

    Leave a Reply