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:
4054 sites
1k downloads
76 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

Show comments
  • Iñigo Zendegi Urzelai
    Mon, 13 Nov 2023, 3:50 PM
    Hi Jorge,

    I don't fully understand your issue. Moodle always is shown in a language (https://docs.moodle.org/en/Language_settings#Default_language), so using {mlang} tags should also work for non-logged-in users. And, if you're not sure about what that language could be, you can also add a {mlang other}{mlang} section to ensure that all the users will see it.

    Anyway, if you think there is an issue in the plugin, you'd better write about it on GitHub.
  • Kepa Urzelai
    Mon, 13 Nov 2023, 4:02 PM
    Hi Jorge,

    You could use {mlang other} insted of {mlang en}, and that would make English your default language. That means that a user who is navigating in Spanish or Japanese, would see the content between {mlang es} or {mlang ja} tags, but the one navigating in English or any other language would see it in English.

    Hope you find my message helpful.

    Best Regards,

    Kepa Urzelai
  • Bjørn Teistung
    Sat, 9 Dec 2023, 3:19 PM
    Hi, Iñaki and team.
    This tool has been great help for us in several years, thanks for good work. I am instructional designer at Norwegian National Center for Multicultural teaching and learning. This is might not right place to ask, so forgive me if neccessary.
    I am testing out Moodle app at the moment. We use the free version, and for me the language selector is not showing anywhere in the app, so content in multi-lang blocks do not show up. Changing language in the settings do not help, as this is controlled by the language selector. Is this a missing functionality in the Moodle app? Any idea?
  • Iñigo Zendegi Urzelai
    Mon, 11 Dec 2023, 6:51 PM
    Hi Bjørn,

    IIRC the Moodle app shows the content based on the preferred language of the user profile in Moodle, and then if the user changes the language of the app (see https://tracker.moodle.org/browse/MOBILE-2848 for more details)

    Anyway, if you see that there is an issue with the app this isn't the best place for it, instead of that you should open an issue here: https://tracker.moodle.org/projects/MOBILE/
  • Dan Jeffries
    Fri, 5 Jan 2024, 5:14 PM
    Hi! Firstly, thanks for a great plugin. I assume it's great, because right now I can't get it to work :D Could you tell me what I'm doing wrong?

    {mlang en}

    Meet Dan. WIth a background in veterinary medicine, find out more about his passion to improve veterinary education and the welfare of animals around the world.

    {mlang}

    {mlang pt}

    Conheça Dan. Com formação em medicina veterinária, descubra mais sobre a sua paixão por melhorar a educação veterinária e o bem-estar dos animais em todo o mundo.

    {mlang}

    When I view this label in both languages (using the drop down menu), both sets of text are still showing. Help!
  • Iñigo Zendegi Urzelai
    Fri, 5 Jan 2024, 5:19 PM
    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
    Fri, 5 Jan 2024, 5:56 PM
    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
    Fri, 5 Jan 2024, 6:44 PM
    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
    Fri, 5 Jan 2024, 7:44 PM
    Thanks. I've asked the Theme developer for some guidance too.
  • Iñaki Arenaza
    Fri, 5 Jan 2024, 10:32 PM
    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
    Thu, 25 Jan 2024, 4:31 PM
    Hi, we are using this plugin in Moodle 4.1. Will it be compatible with 4.3? Any ETA? Best!
  • Iñaki Arenaza
    Thu, 25 Jan 2024, 5:42 PM
    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
    Thu, 25 Jan 2024, 5:44 PM
    I just updated the supported Moodle versions.
  • Fabian Glagovsky
    Sun, 28 Jan 2024, 11:08 PM
    Thank you!
  • Freelance Shree Ram
    Mon, 4 Mar 2024, 3:43 AM
    Here is the latest video link. How in case be used. Steps by steps guide from installation to using this
1 2 3 4 5 6 7 8 9
Please login to post comments