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.

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
    Mon, Mar 31, 2014, 10:12 PM
    Hi Vanyo,

    I was very excited to try out your most recently enhancements. However when I tried it, I got an error message. I've posted details in the bug tracker:

    Notice: Undefined index: en in filter.php on line 106 #1

    Please let me know when you are ready for me to try it again as I am currently in the process of putting several Moodle plugins including yours through some quality assurance testing.

    Looking forward to hearing from you.

    Best regards,

  • Picture of Vanyo Georgiev
    Tue, Apr 1, 2014, 3:20 AM
    Hi Michael,

    Thank you for paying attention on this issue!

    I made a correction:

    Now there are no warning messages any more.
    The file for download here was updated too.

    Best regards.
  • Picture of Michael Milette
    Tue, Apr 1, 2014, 4:42 AM
    Well done Vanyo!

    Thank you very much for the fix and the quick solution Looks good so far. I'll let you know if I come across anything else.

    Best regards,

  • Picture of Michael Milette
    Wed, Apr 2, 2014, 3:50 AM
    Hi Vanyo,

    Would it be possible to add a new feature to your already excellent plugin?

    The new tag called {lang} would allow people entering information to easily tag text as being an a particular language when no alternative language is provided.

    For example, lets assume that I am entering information on an otherwise French page but want to put a link to a company with an English company name. Since the editor doesn't currently have an option to tag text in a particular language, the {lang} tag could be typed in plain text such as:

    [a href=""]{lang en}General Motors{lang}[/a]

    The filter would simply convert this into:

    [a href=""][span lang="en"]General Motors{lang}[/span][/a]

    (sorry, had to replace < and > characters with [ and ] or they would be filtered out of this message.)

    This would enable screen readers to properly read the tagged text in the correct language (if available).

    I think it would be very easy to implement as it amounts to little more than a simple search and replace of the opening and closing tags. The only thing I haven't thought out yet is how to make it support larger blocks of text. But then again, large blocks should probably be translated and inserted using mlang tags anyway.

    Let me know if this is something you would be interested in adding to your plugin. Otherwise I might try my hand at it.

    Best regards,

    Michael Milette
  • Picture of Vanyo Georgiev
    Sat, Apr 5, 2014, 2:16 PM
    Hi Michael,
    The problem is that the search pattern in the present version of multilansecond filter is made to find multilingual blocks and to skip individual {mlang xx}…{mlang} elements. At the moment I have no Idea how to integrate the feature you like in the present filter. My be It would be easier to make a separate filter for your need first, and after setting it up and running to think how to combine multilansecond filter with this new filter.
    Best regards
  • 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!
1 2
Please login to post comments