Your Moodle version

Filters: Multi-lingual Content

Maintained by Picture of Vanyo Georgiev Vanyo Georgiev
This filter is a more flexible version of multilang filter. One of three possible choices can be selected by the filter admin setting: HTML syntax, Non HTML syntax or Both. If the non html syntax is chosen language block looks like: {mlang en}English{mlang}{mlang bg}Bulgarian{mlang}. In case of Html syntax, language block is a sequence of identical html tags with lang="XX" attributes span or div or any other.
Moodle 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9

This filter is a more flexible version of Moodle multilang filter.

It has an admin setting filter_multilangsecond_mode.

One of three possible choices can be selected by this setting:

* HTML syntax
* Non HTML syntax or
* Both

In case of HTML syntax the language block is a sequence of identical
html tags with lang="XX" attributes:

<h1 lang="en" xml:lang="en">Heading in English</h1>
<h1 lang="bg" xml:lang="bg">Heading in Bulgarian</h1>


<p lang="en" xml:lang="en">Paragraph in English</p>
<p lang="bg" class="..." xml:lang="bg">Paragraph in Bulgarian</p>
<p lang="ro" xml:lang="ro">Paragraph in Romanian</p>

The old syntax with <lang> tags is valid too.

In case of Non HTML syntax the language block looks like this:

{mlang en}English{mlang}{mlang bg}Bulgarian{mlang}

Each language dependent string is enclosed by {mlang xx} and {mlang}
elements. Between closing {mlang} element and the next opening
{mlang yy} element must not be any other symbols, or html tags. Avoid
to insert spaces, line or paragraph brakes between {mlang}{mlang yy}
elements in language blocks.

When the Both option is chosen for filter_multilangsecond_mode setting,
the filter processes the strings twice. First time to replace the non
HTML language blocks and second time to replace the HTML language
blocks. For performance reasons choose Both option only if you really
need both syntaxes.


Picture of Vanyo Georgiev
Vanyo Georgiev (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Picture of Michael Milette
    Wed, Apr 9, 2014, 9:23 PM
    Hi Vanyo, thank you for your response.

    I am suggesting that you could used {lang xx}, not {mlang xx}. It would be {lang} because it is for specifying the language of text, not specifying multi-language text.

    The tag would specifically be used for tagging text in a specific language. That way it would not interfere with existing functionality or code.

    The code would search for {lang xx} tag and replace it with: < span lang="xx" >.

    The only complicated part of this is parsing the {lang} tags to extract the specified language which your plugin already does.

    The closing {lang} tag would get replaced with the closing for the span tag, a simple search and replace.

    Best regards,

  • Picture of Mihai Bojonca
    Wed, May 28, 2014, 10:57 PM
    Dear Vanyo are you planing a 2.7 version of the plugin, It installed fine on my test site but i do not seem to be able to make it work. Thanks for a great plugin.
  • Picture of Naaman Fallouh
    Wed, Aug 27, 2014, 4:19 PM
    I'd enabled the filter in the BOTH mode on my moodle 2.7 and when trying it in: my front-page > (Full site name)

    it worked correctly by only input this in the field textbox:
    {mlang en}English Moodle{mlang}{mlang ar}Arabic Moodle{mlang}

    But when trying to put it in a .php page exactly like this, I intended to add spaces in the < p > and < /p > to let them appear as I want in this comment:

    < p >{mlang en}English{mlang}{mlang ar}Arabic{mlang}< /p >
    < p lang="en" xml:lang="en">Heading in English< /p >
    < p lang="ar" xml:lang="ar">Heading in Arabic< /p >
    None of the above syntax worked, and it keeps displaying everything.

    I'm really stuck here, is there anything special I should configure/do to get it work fine, any help is appreciated ??!!

  • Picture of Vanyo Georgiev
    Wed, Aug 27, 2014, 9:39 PM
    Hi Naaman,

    If you want the full site name like

    {mlang en}English Moodle{mlang}{mlang ar}Arabic Moodle{mlang}

    to be processed correctly by the multilangsecond filter you have to:

    1. From admin/filters.php page of your Moodle site set:
    Active? = On
    Apply to = Content and headings
    2. From the filter’s Settings choose Non HTML or Both for Syntax setting.

    If you want filters to work in a .php file you have to pass the html code thought format_string function. In your case, if you chage the code in your .php file to:

    <?php echo format_string(‘<p>{mlang en}English{mlang}{mlang ar}Arabic{mlang}</p> <p lang="en" xml:lang="en">Heading in English </p> <p lang="ar" xml:lang="ar">Heading in Arabic </p>’); ?>
    the multilang second filter my be will work.
  • Picture of David Manning
    Tue, Sep 9, 2014, 6:32 AM
    Thank you so much for this plugin! You have saved me so many hours of work!
  • Picture of David Manning
    Thu, Sep 11, 2014, 12:29 AM
    Hi Vanyo,

    In php, the mlang tags don't seem to work when embedded in hyperlink tags?
    e.g. in the snippet below, I see the English or French text, but the link doesn't get created... (pretend there's an a href tag right before the {mlang en}, it keeps dropping from my comment)
    <?php echo format_string('{mlang en}bla english{mlang}{mlang fr}français{mlang}'); ?>
  • Picture of Vanyo Georgiev
    Thu, Sep 11, 2014, 1:37 AM
    Hi David,

    Try to add a second parameter with value of false to format_string() function:

    <?php echo format_string('{mlang en}bla english{mlang}{mlang fr}français{mlang}', false); ?>
  • Picture of David Manning
    Thu, Sep 11, 2014, 3:24 AM
    Hi Vanyo,

    Oops, I might not have described it very well. The < a > tag seems to break with or without the 'false' parameter... hopefully this explains what I've tried, and the link works in neither option:

    echo format_string('{mlang en}< a href="">link to google English< /a >{mlang}{mlang fr}< a href="" >lien a google Français< /a >{mlang}', false);
    echo format_string('< a href="">{mlang en}english{mlang}{mlang fr}français{mlang}< /a >', false);
  • Picture of Vanyo Georgiev
    Thu, Sep 11, 2014, 4:27 AM
    Hi David,

    Another thing I would suggest is to try to use format_text() instead of format_string().
  • Picture of Apostolos Kechagias
    Thu, Mar 5, 2015, 4:57 AM
    Hello Vanyo,

    first let me congratulate you on a great plugin! Very good job indeed.
    I just installed the latest moodle release 2.8.3+ and I installed your plugin as well and It works great!

    I have a question about it though. I don't know if it is something that your plugin can do or not but if it possible please tell me how it can be done.

    I need to create a multilingual site with multilingual content. The content is in scorm and pdf format. Is it possible to add two activities, each containing a different translation of the same scorm/pdf and only the appropriate to be visible?

    I have managed to only show the title and the description of the one that matches the selected language but the icon of the file still appears. Is it possible somehow to make that 'dissapear'?

    I have a screenshot in case It's not clear what I mean.

    Thank you very much and keep up the great work!
  • Picture of Michael Milette
    Mon, May 4, 2015, 12:43 AM
    Hi Apostolos,

    We do a lot of SCORM courses on multilingual Moodle sites. Our solution was to make your SCORM course multilingual as well instead of having two SCORM courses.

    As for the files, ideally you should be able to simply put a restriction by user profile field however the Preferred Language field is unfortunately not included in the list of available profile fields. Your choices are to:

    1) Make your PDF documents multilingual.

    2) Link to your documents from a Label or Page type activity where you can wrap the URL in some {mlang} tags

    3) Give the "Restriction by language" plugin by Renaat Debleu ( ) a try. This is only available for Moodle 2.7+. Don't forget to click the open eye to hide the activity if the condition is not meet.

    Options #2 and #3 will both enable you to display content just in the users preferred language and #2 will enable you to even get rid of the icon if so desired.
  • Picture of Michael Milette
    Fri, May 22, 2015, 8:55 PM
    Just a quick note to confirm that the plugin seems to work for me on Moodle 2.8, 2.9 and 3.0-Alpha.
  • Picture of Michael Milette
    Tue, May 26, 2015, 1:22 PM
    If you change the "$plugin->requires =..." line in the plugin's version.php file to 2011033010, it actually is compatible all the way back to Moodle 2.0!!!
  • Picture of nikhil jagatiya
    Fri, Aug 14, 2015, 2:22 PM
    Hello I installed your plugin but it not working in my site. I'm using moodle 2.9. Can you help me??
  • Picture of Josh Franz
    Wed, Sep 2, 2015, 1:54 AM
    Hello, firstly, thank you very much for the wonderful plugin! I've installed on Moodle 2.9, and it's working great, with one exception. Within my 'Book' settings, I have the Name: field using nonHTML syntax, for example... {mlang en}Settings Tab{mlang}{mlang es}Ficha Configuración{mlang}{mlang pl}Zakładka Ustawienia{mlang}. This displays perfectly in each respective language, everywhere except at the top of each Chapter page. The full non-parsed string is being displayed. Any ideas? Thanks again!
1 2
Please login to post comments