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):
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.
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
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?
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/
{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!
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
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'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.
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.