Multi-Language Content (v2)

Filters ::: filter_multilang2
Maintained by Iñaki Arenaza, Iñigo Zendegi Urzelai, Kepa Urzelai
This filter is a greatly simplified multi-language filter. It uses very simple non-HTML tags to mark multi-language blocks. Namely {mlang XX} {mlang} pairs, where XX is the Moodle short name for the language pack (i.e., en, fr, eu, es, es_mx, etc.) It uses the same tags as the filter_multilangsecond plugin (to be compatible with it), but there is one difference between the two. This filter allows standalone {mlang} tags that don't require adjoining alternative language tags. This makes the filter more flexible at the cost of potentially producing empty sets of tags.
Latest release:
4046 sites
1k downloads
77 fans
Current versions available: 4

To Install it manually

  • Unzip the plugin in the moodle .../filter/ directory.

To Enable it

  • Go to "Site Administration >> Plugins >> Filters >> Manage filters" and enable the plugin there.

To Use it

  • Create your contents in multiple languages.
  • Enclose every language content between {mlang NN} and {mlang} tags:
    {mlang XX}content in language XX{mlang}
    {mlang YY}content in language YY{mlang}
    {mlang other}content for other languages{mlang}
  • where XX and YY are the Moodle short names for the language packs (i.e., en, fr, de, etc.) or the special language name 'other'.
  • Version 1.1.1 and later: a new enhanced syntax to be able to specify multiple languages for a single tag is now available. Just specify the list of the languages separated by commas:
  {mlang XX,YY,ZZ}Text displayed if current lang is XX, YY or ZZ, or one of their parent laguages.{mlang}
  • Test it (by changing your browsing language in Moodle).

How it works

  • Look for "lang blocks" in the text to be filtered.
  • For each "lang block":
    • If there are texts in the currently active language, print them.
    • Else, if there exist texts in the current parent language, print them.
    • Else, as fallback, print the text with language 'other' if such one is set.
  • Text outside of "lang blocks" will always be shown.

Definition of "lang block"

Is any text (including spaces, tabs, linefeeds or return characters) placed between '{mlang XX}' and '{mlang}' markers. You can not only put text inside "lang block", but also images, videos or external embedded content. For example, this is a valid "lang block":

{mlang es,es_mx,es_co}
First paragraph of text. First paragraph of text. First paragraph of text.

Second paragraph of text. Second paragraph of text. Second paragraph of text.

                   An image could go here

Third paragraph of text. Third paragraph of text. Third paragraph of text.

                   An embedded Youtube video could go here

Fourth paragraph of text. Fourth paragraph of text. Fourth paragraph of text.
{mlang}

A couple of examples in action

Using text only

This text:

  {mlang other}Hello!{mlang}{mlang es,es_mx}¡Hola!{mlang}
  This text is common for all languages because it's outside of all lang blocks.
  {mlang other}Bye!{mlang}{mlang it}Ciao!{mlang}
  • If the current language is any language except "Spanish International", "Spanish - Mexico" or Italian, it will print:
  Hello!
  This text is common for all languages because it's outside of all lang blocks.
  Bye!
  • If the current language is "Spanish International" or "Spanish - Mexico", it will print:
  ¡Hola!
  This text is common for all languages because it's outside of all lang blocks.
  • Notice the final 'Bye!' / 'Ciao!' is not printed.
  • If the current language is Italian, it will print:
  This text is common for all languages because it's outside of all lang blocks.
  Ciao!
  • Notice the leading 'Hello!' / '¡Hola!' and the final 'Bye!' are not printed.

Using text, images and external embedded content

We create a label with the content shown in the following image:

Multi-Language content in Spanish, English, an language-independent content

The "lang block" tags are highlighted using blue boxes. You can see that we have three pieces of content: the Spanish-only content (light yellow box), the language-independent content (light blue) and the English-only content (light red).

If the user browses the page with English as her configured language, she will see the common content (light blue box) and the English-only content (light red):

Multi-Language content when browsed in English

If the user browses the page with Spanish as her configured language, she will see the Spanish-only content (light yellow) plus the common content (light blue box):

Multi-Language content when browsed in Spanish

Screenshots

Screenshot #0
Screenshot #1
Screenshot #2

Contributors

Iñaki Arenaza (Lead maintainer)
Iñigo Zendegi Urzelai
Please login to view contributors details and/or to contact them

Comments RSS

コメントを表示する
  • Iñigo Zendegi Urzelai
    2024年 01月 5日(金) 17:19
    Hi Dan,

    The syntax seems correct, have you checked that the plugin is enabled both at site level and at course/activity level?

    https://docs.moodle.org/en/Managing_filters
  • Dan Jeffries
    2024年 01月 5日(金) 17:56
    Yes - both are on at course and site level. I've also moved it to the top of the list.

    Been trying to use it in our Theme's Slider block (appreciate that might not work and I'll contact the Space theme developer), but I see no reason why this wouldn't work in a Label.
  • Iñigo Zendegi Urzelai
    2024年 01月 5日(金) 18:44
    Hi Dan,

    I've copy-pasted your text to a label in our site ('Text and media area' since 4.1) and it works as expected, but if you think it's a bug open an issue at https://github.com/iarenaza/moodle-filter_multilang2/issues with the details and we'll check what's happening.
  • Dan Jeffries
    2024年 01月 5日(金) 19:44
    Thanks. I've asked the Theme developer for some guidance too.
  • Iñaki Arenaza
    2024年 01月 5日(金) 22:32
    Hi Dan,

    before opening an issue in the plugin tracker, check that the standard multi-language plugin from Moodle works. If the standard plugin doesn't work, then most probably the issue is on the theme side.

    Saludos.

    Iñaki.
  • Fabian Glagovsky
    2024年 01月 25日(木) 16:31
    Hi, we are using this plugin in Moodle 4.1. Will it be compatible with 4.3? Any ETA? Best!
  • Iñaki Arenaza
    2024年 01月 25日(木) 17:42
    The plugin is already compatible with 4.2 and 4.3. We simply haven't updated the compatibility data here in the plugins database. Sorry about that!
  • Iñaki Arenaza
    2024年 01月 25日(木) 17:44
    I just updated the supported Moodle versions.
  • Fabian Glagovsky
    2024年 01月 28日(日) 23:08
    Thank you!
  • Freelance Shree Ram
    2024年 03月 4日(月) 03:43
    Here is the latest video link. How in case be used. Steps by steps guide from installation to using this
  • Craig Ferguson
    2024年 04月 30日(火) 02:05
    Hi, Iñaki and team (and anyone else who might have insight into this),

    I love this plugin. We've been using it for a few years and really appreciate the work you put into it.

    We've been having an issue since the start where, once a learner reaches the end of a lesson, the automatically generated Lesson Completion page isn't being parsed by the mlang filter. So, when you reach the end of a lesson, you get a button that says, "Proceed to {mlang en}Chapter 2: Lesson{mlang} {mlang fr_ca}Chapitre 2: Leçon{mlang}" or "Aller à {mlang en}Chapter 2: Lesson{mlang} {mlang fr_ca}Chapitre 2: Leçon{mlang}" depending on your language.

    To get around this, we created fake end of lesson pages and have had to get creative with the completion settings. I'm wondering if there's a fix for this? Is there a way to make the multilang filter parse the "Proceed to" button text?

    Thanks!

    Craig
  • Iñigo Zendegi Urzelai
    2024年 04月 30日(火) 14:56
    Hi Craig,

    I've been able to replicate that issue, but it's not an issue of this plugin but on core lesson module.

    It's easy to fix but it has to be done in the Moodle core, so I've created an issue on the tracker and proposed a patch: https://tracker.moodle.org/browse/MDL-81733
  • tom müller
    2024年 05月 2日(木) 02:09
    Hi,
    I have the problem that words in the glossary do not stand under the correct first character. "Operating system" stands under Special and not under O. This word has keywords. Titles, which has (yz) stands under Special, too. Titles with "Ä", too, and 62-bit stand under 2 and not under 6. How can I fixed this?
  • Iñaki Arenaza
    2024年 05月 2日(木) 17:12
    Hi Tom,

    could you provide us with an example to try and reproduce the issue? I'm not sure I'm understanding it right. If you could provide us a couple of the problematic multilang2 strings (their raw definition, before they are processed by the filter), how they are displayed once filtered (e.g, by providing a screenshot), and where they end up in the Glossary (again, with a screenshot), that could help us.

    Thanks in advance.
  • Iñigo Zendegi Urzelai
    2024年 05月 2日(木) 18:32
    Hi Tom,

    I've been able to replicate your issue, it seems that the glossary's filter by the concept's first letter is using the concept's name before applying the filters and in consequence all of them appear under the "Special" filter because it detects the first character being "<" (core mlang syntax) or "{" (this plugin's mlang syntax), and that's incongruous with the way it shows the concept list (order after applying the filters)

    I'll try to find and propose a solution to this issue, but it has to be done in the Moodle core and not within this plugin.

1 2 3 4 5 6 7 8 9
Please login to post comments