Moodle plugins directory: Multi-Language Content (v2) | Moodle.org
Multi-Language Content (v2)
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:
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):
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):
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.
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!
For more information on this issue and some workarounds, see https://tracker.moodle.org/browse/MDL-70556
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.
This plugin only require the call of the standard functions to apply the filters in Moodle, usually format_string or format_text.
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
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
Is there any plans to enable translating the Tags using this plugin?
Regards,
I'm afraid that's not in our hands . 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.
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
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'.
existe la posibilidad de aplicar el filtro a un título, por ejemplo de una sección o un tema?
eskerrik asko
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.