This is a fork of Moodle Filter Translations. We implemented our custom self hosted machine translation API, and a widget that can translate courses based on the specified languages.
This plugin requires the Moodle Atto Translations plugin.
- Unzip the plugin in the moodle .../filter/translations directory.
- Also install the Atto plugin from: https://github.com/andrewhancox/moodle-atto_translations
- Go to "Site Administration >> Plugins >> Filters >> Manage filters" and enable the 'Content translations' plugin there.
- Go to "Site Administration >> Plugins >> Filters >> Content translations" and choose a caching level appropriate to your site.
Since the filter makes database calls and web service calls, it is advisable to enable caching by working with the cachingmode setting. If you have a small volume of course material in active use then Application mode caching is advised, if you have a large volume then Session. In any case, the default of Request is rarely the optimal choice.
-
Get a prioritised list of the languages we could translate into - starting with the user's preferred language, then working through parent languages.
-
Get the translation(s) that fit the highest priority language.
-
If a span tag with an MD5 key in the data-translationhash property and a translation with a matching md5key can be found then use that one.
-
Otherwise, if a translation can be found which has an MD5 key matching the MD5 hash of the content then use that.
-
Finally, if a translation has a 'last generated hash' (meaning the MD5 hash of the content it was last updated in reference to) which matches the MD5 hash of the content then use that.
In order to use this plugin, you have to first install and enable the plugin. If you don't know how to install or how to enable the plugin, the instructions can be found at the beginning of this page.
After enabling the plugin, you can set the course content language, and enable or disable widget/popup translations that typically pops up when a user selects text from the course content. You can also set the target language for the widget/popup translations.
Let's take a look at how we are going to do that.
You can set the course content language using one of the following ways:
- The easy way to do this is to use the top navigation bar. That navigation bar can only be accessed when you are on a course page.
You can enable or disable widget/popup translations using one of the following ways:
- The easy way to do this is to use the top navigation bar. That navigation bar can only be accessed when you are on a course page.
You can enable or disable widget/popup translations using one of the following ways:
- You can set this in settings
N.B: Users with the 'filter/translations:edittranslations' capability will see an icon in the top right hand corner of the screen to enable the translator view of the course. At this point all translatable text will have an icon injected next to it to allow it to be translated.
A CLI tool is available to migrate all translations across from the filter_fulltranslate.
It is recommended that you clean out any unwanted translations that may have been generated as follows:
delete from mdl_filter_fulltranslate where sourcetext like '%{mlang%';
You can then copy the translations from filter_fulltranslate into filter_translations as follows:
php cli/migrate_filter_fulltranslate.php --confirm
A CLI tool is available to automatically add span tags to existing data. Please use with extreme caution.
You can run the tool as follows which will show help text:
php cli/insert_spans.php
The module has been written and is currently maintained by Andrew Hancox but now it is being maintained by Elvis Peace NDAHAYO RUGERO on behalf of Digital Umuganda.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.