Code Monkey home page Code Monkey logo

moodle-local_deepler's Introduction

Deepler, Multilang Machine Translator for Moodle

Moodle Plugin CI Dependency Review Maintainability Rating Quality Gate Status

Deepler is a local moodle plugin that provides a content translation page for courses and automatic machine translation using the ©Deepl Pro Translation api. It is developed for those who want to translate a course all on one page without having to navigate to each module and update translations. Translation workflow being the following:

  1. Fine tune your ©Deepl's settings.
  2. Select the source(s) language(s).
  3. Select the target language.
  4. Select the fields to translate.
  5. Send to ©Deepl.
  6. Review and or amend automated translations.
  7. Save translations to Moodle's DB (with the multilang {mlang XX} tags).

Multi-Language Content (v2) is a dependency of this plugin and will not work without it.

Fork

This is a fork of Jamfire's https://github.com/jamfire/moodle-local_coursetranslator which was left deprecated with https://github.com/jamfire/moodle-filter_autotranslate for replacement. Though going the filter way is most probably the best way for auto translation, we found useful to improve this one adding the necessary "revision" step as Machine translation will never be 100% accurate specially in the context of knowledge transmission where accuracy is mandatory.

Installation

Clone or download this plugin to /moodlewww/local/deepler and run through the database upgrade process.

Configuration

Permissions

Course Translator will extend Moodle with the local/deepler:edittranslations capability. Assign the capability to a new Translator role or add it to one of your existing roles.

Webservices

This plugin will add a local_deepler_update_translation web service for the translation page to perform ajax requests against.

Admin

To configure the plugin, navigate to Site Administration -> Plugins -> Local plugins -> Manage local plugins. From this page you can configure ©Deepl settings, specify wether you are using ©Deepl API Free or ©Deepl API Pro, and enable/disable the autotranslate feature on the translation page. Visit the ©Deepl API page to signup for an api key that you can enter into local plugin settings.

Sub languages (expl: de_ch, en_za etc...)

Currently Deepl doesn't support any. See https://developers.deepl.com/docs/resources/supported-languages. The plugin gives you the possiblity to use these sub languages if your moodle install has them as if they were their parent language. This setting is ticked by default.

Translating

To begin translating content, visit a course, open the course settings action menu, and then go to Course Translator.

You will be sent to the translation page for the course.

Advanced settings

There you can fine tune ©Deepl's commands.

Language selection

Source language

The source language will be set to the actual Moodle language selection which will automatically be set to other. Changing the source language will act as if you'd change moodle's lang. It is important, from a translation standpoint, to select the source language from the language it was initially written (and to stick with it).

When first translating your content the plugin will insert {mlang other}Your Content...{mlang} tags . Please checkout the mlang docs to understand more.

nb: indeed you cannot select the same target language as the source and vice versa.

Target language

To change the language you want to translate to, choose a language from the Target language {mlang XX} dropdown. Note: indeed you cannot translate from and to the same language so buttons and checkboxes would be disabled if so.

Unsupported

Language that are not suppoted by ©Deepl are checked at each session so if your Moodle instance have unsupported languages, you will not be able to select it.

Header

Filters

You can filter the rows to hide/show the ones that need to be translated as wished. Clicking on the "Status" checkbox will select all visible.

These filter show/hide the textual content found in the course.

Up to date:

These are the content that are already translated and that no change were made in the source.

They will appear with the GREEN DOT indicator.

Needs update:

These are the textual contents that were never translated or that were modified after being translated.

They appear with the RED DOT indicator when they were never translated.

They appear with the ORANGE DOT indicator when they were already translated but the source text change since.

Status indicator

Each row has a little colored dot to indicate a status:

  • Red -> This field was never translated. (no {mlang xx} tag for the xx target language found)
  • Green -> The filed was already translated and up to date (in the target language).
  • Orange -> This field was translated but there were some updates made in the Database. (Needs a review)

Translation process

Editing the source

It is not possible to edit the source content from this plugin's interface. Nevertheless, clicking on the PENCIL icon will jump you to the regular place for you to do so.

Reviewing past translations and multilang's tags

Clicking on the TRANSLATION icon will toggle the display of multilang tags and all available translations.

Images and medias.

The plugin will try to fetch and display embeded images. When not found it will highlight the alt text in yellow and italicised as seen above.

Performing translations

  1. The text is not selected. No translation will occur. ( ... )
  2. The text is selected but not sent to ©Deepl yet. (hourglass)
    1. By default, the main source language is selected. It will be stored within {mlang other}* tag.
    2. You set another language as source if your content had some content written in different lang. It will be stored within {mlang xx}* tag.
  3. Translation is retrieved from ©Deepl and filed in the text editor. (floppy)
    1. Now the translator can review ©Deepl's work and amend the translation if necessary.
    2. Once happy with the content a click on the floppy button will save the text.
  4. Translation is saved in the database, with the {mlang} filter surrounding it. (DB icon)

_Note* the following process when saving to the database _

The original content has no MLANG tag and the source lang is the main:

{mlang other}SOURCE_CONTENT{mlang} {mlang target_lang}TRANSLATED_CONTENT{mlang}

The original content has no MLANG tag and the source lang is different from the main:

{mlang other}SOURCE_CONTENT{mlang} {mlang special_source_lang}SOURCE_CONTENT{mlang} {mlang target_lang}TRANSLATED_CONTENT{mlang}

The original content has already MLANG tag and the source lang is the main:

{mlang other}SOURCE_CONTENT{mlang} {mlang target_lang}TRANSLATED_CONTENT{mlang}

The original content has already MLANG tag and the source lang is different from the main and there were no {mlang other}:

{mlang other}SOURCE_CONTENT{mlang} {mlang special_source_lang}SOURCE_CONTENT{mlang} {mlang target_lang}TRANSLATED_CONTENT{mlang}

The original content has already MLANG tag and the source lang is different from the main and there were already a {mlang other:

{mlang other}ANOTHER_SOURCE{mlang} {mlang special_source_lang}SOURCE_CONTENT{mlang} {mlang target_lang}TRANSLATED_CONTENT{mlang}

Modules

Content's texts fields are displayed in the order of appearance of the course. A module (course settings, topics etc.) separator corresponding to the activities grouping is displayed with its title, underneath you can see it available for translation.

Note that: for now, the naming of the instances as well ads the fields are the DB ones, it will soon be replaced by the one used in Moodle's course layout for a better usability.

User tour (inline tutorial)

You can install a tour guide to simplify your translators' trainings.

See moodle's instructions here : User tours

WARNING

Complex structures.

Activities/resources with conplex sub content may not all work. Book does, but wiki only the first page. We planed to parse recursively the wiki pages but somehow not sure it is worse the effort as wiki content is very dynamic and mainly user ("Student") generated. We'll gladly take enhancement request based on usecases, please feel free to raise an issue.

Multi mlang xx tags inside a field

At this time, Course Translator does not have the ability to translate advanced usage of mlang in content. For example, this includes the use of multiple mlang tags spread throughout content that utilize the same language._

Note: Still you can add untranslated content, after a first insertion of mlang tags, before and/or after, the parser should then leave them in place.

Image display

Currently images are only displayed in the preview but not in the text editor. Instead, the alt attribute content is highlighted. The Alt attribute is not sent toi ©Deepl. This should be added in further improvement for better accessibility.

Compatability

This plugin has been tested on Moodle 3.11 and Moodle 4.0. Should work with the following editors:

  • Plaintext
  • Atto
  • Tiny
  • Marklar

It uses the default Moodle JS library and is tested with Boost and Classic. So there could be incompatibilities with other themes. Known so far :

How does this plugin differs from Content Translation Manager and Content Translation Filter?

This plugin does not translate every string on your site. It is only meant for translating courses and it uses Moodle's built in multilingual features along with {mlang} to translate your content. When you backup and restore courses, your translations will migrate with your content. Updating your source content will provide a "Update Needed" status message on the course translation page.

Future (todos)

  • Question banks translation.
  • Machine translation API abstraction to use other services than ©Deepl.
  • Display images all times.
  • Translations versioning.
  • Import glossaries.
  • Multiple API key setting and user mapping.

Submit an issue

Please submit issues here.

Changelog

See the CHANGES.md documentation.

Contributing

See the CONTRIBUTING.md documentation.

moodle-local_deepler's People

Contributors

brunobaudry avatar lucaboesch avatar

Stargazers

Plínio Felipe avatar Davor Budimir avatar

Watchers

Plínio Felipe avatar  avatar

moodle-local_deepler's Issues

Add section name instead of "module x"

Expected behaviour :
Each listed section header should have the current section title as un the Moodle course layout.
Current behaviour :
Each listed section header have "Module x++" for header.

User tour to be completed

  • Offeseted fileds.
  • Missing descriptions for oustanding source lang.
  • Positioning of the centered modals.
  • Better status icon description.

course id passed should adhere to Moodle naming

Current :
The course id passed as htttp param from the menu to the main page is "course_id".
Expected:
The course id passed as htttp param from the menu to the main page should adhere to Moodle naming (Frankenstyle) "courseid".

Error: when installing on 4.1.3

In the course clicking on DeepL Translator button:
Fehler: local_deepler\data\course_data::__construct(): Argument #3 ($context) must be of type core\context, context_course given, called in [dirroot]/local/deepler/translate.php on line 97

Plugin version, latest from Github on 26.6.24

Multilang toggle should be visible at init state

Current behaviour :
When a filed has no {mlang} tag the "multilang toggle" button does not display.
This is not ideal usabilty.
Expected behaviour :
At the place of the button there should be either a deactivated button with title attribute informing of the status for a better ux.

Security Issue

Hey there,

I'm the creator of the original plugin and just wanted to make sure you're aware of the major security issue in this plugin. The code in question is in externallib.php.

public static function get_field($data) {
        global $CFG, $DB;

        $params = self::validate_parameters(self::get_field_parameters(), ['data' => $data]);
        $transaction = $DB->start_delegated_transaction();
        $response = [];

        foreach ($params['data'] as $data) {
            // Check for null values and throw errors.

            // Security checks.
            $context = context_course::instance($data['courseid']);
            self::validate_context($context);
            require_capability('local/deepler:edittranslations', $context);

            // Get the original record.
            $record = (array) $DB->get_record($data['table'], ['id' => $data['id']]);
            $text = $record[$data['field']];

            $response[] = ['text' => $text];
        }

        // Commit the transaction.
        $transaction->allow_commit();

        return $response;
    }

This is the function used by the web service and if someone gets improper access to the web service (exposed accidentally, improper setup, etc), it exposes all of this data without constraint to someone. Its unfortunately an easy way to allow someone to edit almost any field in the database and the webservice really needs rewritten with constraints. I can't recommend anyone use this plugin or the deprecated one until this resolved. It's a security incident waiting to happen.

Allow skipped text DB to be set in the admin.

When discovering the text DB fields to be translated, the list of fields to be skipped should be editable in admin. So that when a new plugin is installed, if it contains funcitonal text fields, the admin can remove them from the one displayed to the trnalsator (and sent to Deepl).
Currently there is an hardcoded list of the one identified in a university instance for the main core activities.

Issue with Adaptable Theme

Installing the Adaptable theme. The plugin sends the text to Deepl (consuption is increased) but no text is fed in the editors and ^ not saved in DB.
(Lots of UI issues with this theme too).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.