Multi-lingual Content

Filters ::: filter_multilangsecond
Maintained by 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.
Latest release:
96 sites
16 downloads
11 fans
Current versions available: 2

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>

or

<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>

Note: In headings only the "official" multilang HTML syntax with <span class="multilang" lang="xx"> tags works. Example:
<span class="multilang" lang="en">English Title</span><span class="multilang" lang="bg">Заглавие на български</span>
This is because of removing of other html tags by format_string function.

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.

If you find that this filter is not working with some string, check in the source code if this string is processed with format_string or format_text function before it is displayed. In not, correct the source code.


Contributors

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

Comments RSS

Show comments
  • Michael Milette
    Mon, 4 May 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 ( https://moodle.org/plugins/view/availability_language ) 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.
  • Michael Milette
    Fri, 22 May 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.
  • Michael Milette
    Tue, 26 May 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!!!
  • nikhil jagatiya
    Fri, 14 Aug 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??
  • Josh Franz
    Wed, 2 Sept 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!
  • Alessandro Zampa
    Fri, 11 Sept 2015, 9:52 PM
    Hi Vanyo, let me add my thanks to others. I'm facing the same problems of Josh: as an example, I name cathegories and courses using {mlang xx}name in xx{mlang}{mlanh yy}name in yy{mlang} (Moodle 2.9.1; settings: nonHTML syntax, filter contents and headings). Categories are correctly displayed showing the name corresponding to the language selected. Instead, names of courses are correct when displayed within the list of categories, while the full non-parsed text is shown in the list of available courses (or in the list New courses displayed by the Klass theme I'm using). The same thing happens regarding block titles and other places, as the footnote in the footer, and the title and the description of front page for the theme (not on the front page summary, where the filter works nicely). You can give a look at the phenomenon opening https://mathverse.org/learn .
    Please help us solving the issue.
    Thanks
  • Josh Franz
    Fri, 11 Sept 2015, 10:04 PM
    Hello Alessandro, I actually found a solution to my problem that may also help in your case. Please see here: https://moodle.org/mod/forum/discuss.php?d=319398 . My recommendation for you would be, search your \learn\view.php file for cases of (just for example, variable names will be different): "$OUTPUT->variable($var->name);". Try changing this to: "$OUTPUT->variable(format_string($var->name));". This was the fix for me, and hopefully it is as simple as this for you as well.
  • Alessandro Zampa
    Sat, 12 Sept 2015, 4:33 AM
    Thank you, Josh.
    After some work, I found that the issues are due to some multi-language support bugs in moodle and in the Klass theme.

    Concerning blocks one has to add calls to the function format_string() at lines 165 and 239, so as to have format_string($this->title) instead of $this->title, of file moodle//moodleblock.class.php.

    Concerning the Klass theme one has to substitute format_string($course->fullname) to $course->fullname wherever it appears in file moodle/theme/klass/renderers/course_renderer.php

    These fixes have been written here to help users of Multi-lingual Content filter, so they need not search everywhere for a solution. When I will have time to do it, I will also report the bugs and the fixes to the dedicated forums.
    Bye
  • Alessandro Zampa
    Sat, 12 Sept 2015, 4:35 AM
    Sorry, for bloks the file to be fixed is moodle/blocks/moodleblock.class.php instead of moodle//moodleblock.class.php (obviously).
  • Darci Dambros Junior
    Fri, 16 Oct 2015, 3:19 AM
    Hello,

    Is it possible to use this plugin with fields on forms like on field "Course full name"? How?

    The language portuguese Brazil (pt_br) must be used as {mlang pt_br}?

    Thank you!

    Darci
  • Vanyo Georgiev
    Sat, 17 Oct 2015, 2:17 PM
    Hello Darci,

    I just published a new version. Please, try it. The problem you reported must be solved in this version.

    Thank you for your comment!

    Vanyo
  • Alessandro Zampa
    Fri, 20 Nov 2015, 12:25 AM
    Hello Vanyo,

    I'm using your filter a lot in my math site, but I have this problem: math formulae are written with the latex language and the MathJax filter translates them to a two dimensional representation (which is the one we humans are used to). The fact is that latex formulae need to use the curly bracket to apply some formatting, e.g. if I want to display the formula 1/(x+y) bidimensionally (that is, with the denominator standing under the numerator) I need to write \(\frac{1}{x+y}\). The \frac command informs MathJax to put the first argument enclosed by {} (i.e. 1) over the fraction line and the second argument (i.e. x+y) under it. When I put such formulae between {mlang XX} and {mlang} because they need to be inserted into the text, the presence of the curly brackets breaks down the functionality of your filter. Can you please make your filter more robust allowing to insert these brackets inside the text?

    Thanks

    Alessandro
  • Alessandro Zampa
    Fri, 20 Nov 2015, 12:30 AM
    Oh, I forgot: I could use your filter in the HTML-mode, but students would undoubtedly prefer to use the {mlang} construct instead of delving into the HTML code they don't know...

    Alessandro
  • David Manning
    Sat, 27 Feb 2016, 1:42 AM
    Hi Vanyo,

    I'm stuck and was hoping for your help. The badges pages aren't set up to filter text and I'm really challenged with fixing them. E.g. if you go into your Site -> Site badges, the mlang tags aren't filtered properly.

    I've tried looking through the moodle/badges/view.php file but can't seem to figure out what to format as a string. I think the rendering line is here, but I'm not sure what to do with it:
    echo $output->render($badges);

    Would you be willing to take a look and give me some ideas?
  • Vanyo Georgiev
    Sat, 5 Mar 2016, 4:07 PM
    Hi David,

    You have to make changes in badges/renderer.php and some other files in badges module.
    Replace the $badge->name with format_string($badge->name) and
    $badge->description with format_text($badge->description) in all places where you want the multilangsecond filter to work.

    Please, look at the changes made here:
    https://github.com/vanyog/moodle/commit/8e9871ace2a9d272baa59570c9bab12f4f1e63a2

    Vanyo
1 2 3
Please login to post comments