How to translate a training course created in Moodle
This article, reprinted from https://qabiria.com/en/blog/item/552-how-to-translate-a-moodle-course with a few edits, 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:
- Export the course through Moodle’s backup feature
- Convert the relevant content to XLIFF standard format for localization
- Translate these XLIFF files externally, in the tool of your choice
- Convert the XLIFF files back to XML
- Restore the translated package as a new course
In order to fully translate a Moodle course, you need to translate several elements:
- Text included in the user 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 are familiar with this task, otherwise check the official Moodle documentation https://docs.moodle.org/31/en/Language_FAQ.
You might also have files included in your course. The files included 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 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, but more important, 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. These files can be converted to XLIFF through a specific tool developed for software localization, Okapi Rainbow. XLIFF is a standard format for localization that can be opened in OmegaT or other Computer-Assisted Translation tools. After the translation phase, the last step is to import the course back to Moodle using the Restore function.
These are the detailed steps:
- Access Moodle as an administrator
- Click on the course you want to translate
- Go to Administration > Course administration > Backup
- Follow this procedure: https://docs.moodle.org/31/en/Course_backup
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.
In order to translate the course content in a CAT tool, first you need to identify the XML elements that are translatable. You don’t want to expose codes or contents that are not relevant. Once you identify those elements, you 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 from our website. Further information about filter creation can be found on the support Wiki for Okapi, available at 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.
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.
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.
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.
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 get in touch with me or use the Comments section. Also consider that Qabiria.com can help you translate your Moodle training course.