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

Comments

  • Oktawia Hryp
    Thu, 19 Nov 2020, 9:23 PM
    Hi! I want to know whether this plugin is available by default in any of the version of Moodle or I need to install it separatelly every time I want to upgrade the Moodle version? I can not find this information (or I don't know where to search ;) ). Thank you for help in advance.
  • Iñigo Zendegi Urzelai
    Thu, 19 Nov 2020, 9:40 PM
    Hi Oktawia,

    All the plugins of the plugin database (and this one too) are non-standard plugins, so you'll have to install them in addition to the Moodle core on every Moodle instance you want to use it.
  • Oktawia Hryp
    Tue, 5 Jan 2021, 12:28 AM
    Hi!
    I have a question about this plugin according to course names. I'm using this plugin to create a platform fully displayed in 9 different languages. How can I apply this to course names? I know that it is working - I checked based on 2-3 languages, but the field is too short to type all 9 languages. Is there any way of how I can overcome this issue? Maybe you have some tips for me how can I make it possible to apply all of the 9 languages?
    Thank you for any advices and information in advance!
  • Michael Milette
    Tue, 5 Jan 2021, 3:54 AM
    Unfortunately it is not easily possible to expand the course name field. It would require you to make and maintain at least two customizations in Moodle, one to increase the size of the field in the database and the other to modify the size of the field for the course name. Note that you may encounter similar limitations in other parts of Moodle.

    For more information on this issue and some workarounds, see https://tracker.moodle.org/browse/MDL-70556
  • Raymond C
    Fri, 12 Feb 2021, 11:04 PM
    Hello Iñaki, Iñigo and Kepa,

    Your plugin is absolutely amazing. Thank you so much for this.
    I am using it with the Edwiser RemUI theme and Edwiser's course formats. In some areas such as course description in the list of all courses, the {mlang} tags do not work. Instead you see the entire string unfiltered, i.e. {mlang en}Let's study together{mlang}{mlang ja}一緒に勉強しましょう{mlang}.

    Reading the comments here it seems like it may be an issue with the Edwiser course formats and theme not calling specific functions or missing something in their code that can display your plugin. I would like to ask them about this and if they can fix it.

    Can you please advise what your plugin requires in their code to properly display? I do not know how to describe it to them so they can see if it is something they can fix on their side.

    Thank you in advance.
  • Iñigo Zendegi Urzelai
    Fri, 12 Feb 2021, 11:12 PM
    Hi Raymond,

    This plugin only require the call of the standard functions to apply the filters in Moodle, usually format_string or format_text.
  • tiago feio
    Sun, 30 May 2021, 2:36 AM
    Dear Multilanguage plugin team,
    First of all, thank you for this plugin, it simplified a lot my life, definitively.
    But I'm having a problem, and I can't find a solution for it. When applying the language mark separator in menus with links, it turns out that it doesn't recognize the link, and this is crucial to make proper use of a multilanguage site (proper use of the menus). Can you give some hint of how to overcome this?

    Anyway, thank you for your work. It continuos amazing

    TF
  • Michael Milette
    Sun, 30 May 2021, 3:24 AM
    Hi Tiago,

    I am not the developer of the Multi-Language Content v2 plugin but I am a big fan and the developer of the FilterCodes plugin which works in a very similar way but for different purposes (like creating context aware dynamic menus).

    Unfortunately Moodle does not yet include support for these types of {tags} in the custom menu. You have three options:

    1) Fix your Moodle theme or get the developer who created it to add the fix.

    2) Fix Moodle. The advantage of this approach is that it will not only fix it for your theme but almost any Moodle theme that you might use.

    The instructions on how to do #1 and #2 above can be found at:
    https://github.com/michael-milette/moodle-filter_filtercodes#filtercodes-in-a-custom-menu

    And of course, if you fix it for Multi-language Content v2, the fix will also work for FilterCodes which might be useful for you too. I have been creating multi-language Moodle sites since many years using this plugin and these fixes work great. Just remember to re-apply the patch anytime you upgrade Moodle or your theme.

    3) if you don't to modify Moodle or your theme, there is a way to do multi-language menus without any plugins or tags at all. You will find information on how to do this at:
    https://docs.moodle.org/en/Theme_settings#Multilanguage_support

    Tip: Depending on your version of Moodle, you may need to group your menu items by language in order for it to work. Example: all your English menu items followed by all your French ones.

    Consider asking your questions in the Moodle discussion forums in the future. You will find many more people like me who love to help people with their Moodle questions. You might even discover that you can pay it forward and help others too.

    Hope you found something useful in all of this.

    Best regards,

    Michael Milette
  • Naaman Fallouh
    Sun, 27 Jun 2021, 7:49 PM
    Hi,
    Is there any plans to enable translating the Tags using this plugin?
    Regards,
  • Iñaki Arenaza
    Mon, 28 Jun 2021, 5:03 PM
    Hi @Naaman

    I'm afraid that's not in our hands sad. The plugin can only translate (filter) content that is run through format_string() or format_text() functions. So it's up to the Tags code to use those functions to renderi the Tags on the page. You will need to open an issue in the Moodle Tracker for the Tags component and ask about it.

    Saludos.

    Iñaki.
  • davide pesenti
    Thu, 29 Jul 2021, 2:40 PM
    Good morning, and thanks for the plugin!
    Is it possible to have multilang titles as well? I tried to use lang tags, but of course they are ignored!
    Moodle 3.10
    Thanks again
    davide
  • Iñigo Zendegi Urzelai
    Thu, 29 Jul 2021, 6:05 PM
    Hi Davide,

    Yes, indeed. To apply the multilang filter to the course and category titles you have to set it to apply to "Content and headings" in 'Site administration' > 'Plugins' > 'Filters' > 'Manage filters'.
  • Mentxu Zaldua Nieto
    Mon, 8 Aug 2022, 1:49 AM
    Hola Iñaki/Iñigo/Kepa,

    existe la posibilidad de aplicar el filtro a un título, por ejemplo de una sección o un tema?

    eskerrik asko
  • Iñaki Arenaza
    Mon, 8 Aug 2022, 5:27 PM
    Hola Mentxu,

    sí, como el resto de filtros de Moodle, se puede aplicar tambén a los títulos. La documentación del filtro multi-idioma estándar indica como hacerlo en la dirección https://docs.moodle.org/all/es/Filtro_de_contenido_multi-idioma#Habilitando_el_filtro_de_contenido_muti-idioma

    Siguiendo esos mismos pasos, pero aplicándolos al filtro "Multi-Language Content (v2)", lograrás lo que buscas.

    Short English translation for those who don't speak Spanish: the question was about whether the filter can be applied to titles / headings too; which it can, as any other Moodle filter. My answer simply links to the Spanish docs detailing how to to it for the standard multi-lang filter.
  • Mentxu Zaldua Nieto
    Mon, 8 Aug 2022, 6:10 PM
    Thanks Iñaki, solved!!!!
Please login to post comments