Note: You are currently viewing documentation for Moodle 2.9. Up-to-date documentation for the latest stable version of Moodle may be available here: Multi-language content filter.

Multi-language content filter: Difference between revisions

From MoodleDocs
(Added ==The 'Restriction by language' additional plugin==)
(assignment submission statements multilang)
Line 10: Line 10:


It is essential to be in '''the code editing mode''' (press <nowiki>[<>]</nowiki> in the HTML editor), when you enter these tags for them to work. Only spaces, tabs and enters can be used between the individual languages in the multilang block.
It is essential to be in '''the code editing mode''' (press <nowiki>[<>]</nowiki> in the HTML editor), when you enter these tags for them to work. Only spaces, tabs and enters can be used between the individual languages in the multilang block.
==How to use for assignment submission agreements==
#Since Moodle 2.8.2 it's possible to have assignment submission statements in different languages.
#With the filter enabled, go to Site administration>Plugins>Activity modules>Assignment>Assignment settings.
#In the submission statement, add (for example)
      <nowiki><span lang="en" class="multilang">This assignment is my own work, except where I have acknowledged the use of the works of other people.</span>
<span lang="fr" class="multilang">Ce devoir est le fruit de mon travail personnel, sauf aux endroits où l'utilisation d'oeuvre d'autres auteurs est clairement indiquée.</span> </nowiki>


== How it works internally ==
== How it works internally ==

Revision as of 11:57, 24 February 2015

The Multi-language content filter enables resources to be created in multiple languages. When turned on, it looks for <span lang="xx" class="multilang"> tags which indicate that a text contains multiple languages. Then it selects and outputs the best language for the current user. The language of the resource will change when the user changes their selected Moodle language.

How to use in a course

To use this feature first create your contents in multiple languages (in the same resource). Then enclose each language block (aka multilang block) in the following tags:

      <span lang="XX" class="multilang">your_content_here</span>
      <span lang="YY" class="multilang">your_content_in_other_language_here</span>

It is essential to be in the code editing mode (press [<>] in the HTML editor), when you enter these tags for them to work. Only spaces, tabs and enters can be used between the individual languages in the multilang block.

How to use for assignment submission agreements

  1. Since Moodle 2.8.2 it's possible to have assignment submission statements in different languages.
  2. With the filter enabled, go to Site administration>Plugins>Activity modules>Assignment>Assignment settings.
  3. In the submission statement, add (for example)
      <span lang="en" class="multilang">This assignment is my own work, except where I have acknowledged the use of the works of other people.</span>
<span lang="fr" class="multilang">Ce devoir est le fruit de mon travail personnel, sauf aux endroits où l'utilisation d'oeuvre d'autres auteurs est clairement indiquée.</span> 

How it works internally

  1. Filter first looks for multilang blocks in the text
  2. For each multilang block:
    • If there are texts in the currently active language, print them
    • Else, if there exists texts in the current parent language, print them
    • Else, print the first language found in the text
  3. Text outside of multilang blocks will be shown always

Common problems

  • The multilang filter is not enabled. It can be enabled by a site administrator in Settings > Site administration > Plugins > Filters > Manage filters.
  • Extra characters between language span tags - editor might add <br /> or other tags, please review the html in source view
  • If the course setting is "force" some language, you won't be able to change the displayed language.
  • Extra spaces in language span tag
  • Can not easily access language choice dropdown! Unfortunately you must go to the site homepage or your own profile to change the displayed language. It is possible to manually quickly change displayed lang by editing the URL in the browsers address bar. See Tips and tricks below!

Tips and tricks

Changing language displayed without going to front page

It is possible to change the displayed language by manually changing the link.

  • Here is the default language page at id=2306. This link is in English, the default language:
http://moodle.org/mod/resource/view.php?id=2306
  • The link to change the page display to Spanish is
http://moodle.org/mod/resource/view.php?id=2306&lang=es ,
  • When the default language is an other language, to change the page to an English version, the link would be:
http://moodle.org/mod/resource/view.php?id=2306&lang=en

Thus, with a bit of editing, you can manually change the displayed language by adding "&lang=xx" to the URL in the location bar of the browser. Where xx is the abbreviation for the language you want.

The 'Restriction by language' additional plugin

Language filters are great, but sometimes they can make your resources and activities very complex.

The 'Restriction by language' availability condition is an additional plugin for Moodle 2.7, available in the Moodle plugins database, that makes it easy to show an English resource only to English users and an activity in French only to French speaking students.

Restriction by language.png

See also