Moodle Plugins directory: Multi-lingual Content | Moodle.org
Multi-lingual Content
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.
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.
Please help us solving the issue.
Thanks
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
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
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
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
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?
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