bfh / moodle-tiny_multilang2

GNU General Public License v3.0
1 stars 3 forks source link
hacktoberfest moodle-plugin open-source

TinyMCE multilanguage plugin

Release Moodle Plugin CI PHP Support Moodle Support License GPL-3.0 GitHub contributors

This plugin will make the creation of multilingual contents on Moodle much easier with the TinyMCE editor.

The plugin is developed to work with the optionally installed Iñaki Arenaza's multilang2 filter.

This plugin was started as an adaption of Iñaki Arenaza's plugin for legacy TinyMCE editor and has been made to work with TinyMCE 6 that is included in Moodle ≥ 4.1. Further development of this plugin added support for the builtin multilanguage tags that are suppored in Moodle core, so that the multilang2 filter is no requirement anymore.

After the installation of the plugin, the TinyMCE shows a new Button (with a globe icon) and a menu entry in the "Format" section where you can select a language. Clicking on a language entry adds a language opening and closing tag to your text at the current cursor position. If there is a selection then the language tags are placed around the selection. In case you use the highlighting option and see the yellow language tags, you may click one of these tags then select a new language from the menu and that will change the language of the existing tag. You may also remove it by hitting the backspace or delete key. This will remove the tag, and it's counterpart in case the formatting of the text is correct.

Current version

The latest release is v1.3 (build 2024100900) for Moodle 4.1 and newer.

Requirements

There are no additional requirements. To benefit from the plugin capabilities the TinyMCE editor must be used in text area (either set as a user preference or being the standard editor set by the Moodle site admin). If you use the plugin with the multilang2 filter the {mlang} tags for the filter are used. If the filter is not installed, the standard <span class="multilang"> tags are used.

Installation

Troubleshooting

If the language selection does not appear in the editor:

If your language tags are saved correctly but all language content is displayed, no matter which user language is selected, then check that you have the language tags for a certain phrase within the same block element (e.g. paragraph). See details at the Moodle documentation.
This does not apply if you use the multilang2 filter because there is a strict filtering even though elements (referring to the same content in different languages) span via multiple paragraphs.

Usage

Editor

Whenever a textfield appears where the editor is used, the plugin can be used either by clicking the globe icon button in the toolbar or via the Format menu. To make a text language dependent mark the text, then select a language from the menu. As soon as the language is selected, you see language markers at the beginning and the end of your previously selected text.

The language tags itself cannot be edited. Instead, click on a language tag and the context menu appears. This allows you to change the language of an existing tag or remove the language tags for that selection. These options can also be accessed via the Format menu or via the toolbar button.

Text conversion between markers and html

Whenever the save button is hit to save the text, the language tag marker in the WYSIWYG mode of the editor are converted to correct language tags that can be used within the text. If the multilang2 filter is installed and active on the Moodle site, the {mlan xx} annotation is used, where xx is the iso code of the selected language. If the multilang2 filter is not installed, the language tags are transformed into the standard Moodle annotation. These are span elements that look like <span class="multilang" lang="xx" dir="ltr">, where xx contains the iso code of the language and the dir attribute annotates whether this is a left to right language or vice versa.

Note: for the moment the dir="ltr" attribute is not included in the code because it breaks the Moodle multilanguage filter.

When loading a text, both annotations are read and translated into marked language tags in the WYSIWYG mode. If mixed annotations are used in the text, these are preserved upon saving.

Possible languages options

The languages that are shown in the toolbar menu, Format menu or context menu are the same. However, there are a few exceptions. The Remove all language tags is not displayed in the context menu. This option removes any language tags that are currently in the edited text.

The context menu has no Remove all tags option. Instead, it shows a trash icon that removes the selected language tag pairs.
Furthermore, there is no context menu at all if showalllangs is enabled, because that would make the menu having too many options.

The option Fallback (other) is available only when the multilang2 filter is installed because the standard Moodle has no fallback option.

The languages are ordered alphabetically when using the installed languages or the option showalllang is enabled. If the languages are defined via languageoptions the order of the provided iso codes is preserved.

Version History

1.3

1.2

1.1

1.0

Many thanks to Tai Le Tan from the Open University that provided a comprehensive pull request.

0.3

0.2.3

0.2.2

0.2.1

Initial release