Hi Daniele,
The Moodle API functions to extract the text in the correct language are listed on the following page of the Moodle Output API:
https://moodledev.io/docs/apis/subsystems/output#output-functions
Note that this is not specific to language but to processing content through Moodle filters.
If you happen to have a language filter installed AND enabled for content AND headings, it will process multi-language content through the language filter.
If you are just getting started with muti-language content, I recommend that you take a look at the Multi-Language Content (v2) filter available from:
https://moodle.org/plugins/filter_multilang2
There are many advantages to using this plugin over the one that comes bundled with Moodle including:
- It uses plain text tags like: {mlang en}In English{mlang}{mlang fr}En Français{mlang} instead of having to edit more complex HTML.
- It is easy to see where the tags are since they are just plain text. No more having to guess or view the HTML codes to see where the span tags start and end.
- The {mlang} tags are much shorter leaving more room for your content which is great when dealing with fields like course names which have length limitations.
- Plain text tags also work in more places in Moodle than the HTML span tags because some fields in Moodle don't allow HTML tags.
- There is a plugin available for the Atto editor to make life easier for content creators. See: https://moodle.org/plugins/atto_multilang2
- Unlike span tags, you can put several paragraphs of content inside sets of {mlang} tags and still end up with valid HTML. You just need to format on multiple lines as follows:
{mlang en}
Multiple paragraphs in English.
{mlang}{mlang fr}
Plusieur paragraphe de texte en Français.
{mlang}
Hope you find this information useful.
Best regards,
Michael Milette