Note: You are currently viewing documentation for Moodle 1.9. Up-to-date documentation for the latest stable version is available here: Multi language content.

Multi language content: Difference between revisions

From MoodleDocs
Line 5: Line 5:
The Multi-language content filter enables resources to be created in multiple languages. When turned on, it looks for <nowiki><span lang="xx" class="multilang"></nowiki> tags which indicate that a text contains multiple languages. Then it selects and outputs the best language for the current user. The language of the resource will change when the user changes their selected Moodle language.
The Multi-language content filter enables resources to be created in multiple languages. When turned on, it looks for <nowiki><span lang="xx" class="multilang"></nowiki> tags which indicate that a text contains multiple languages. Then it selects and outputs the best language for the current user. The language of the resource will change when the user changes their selected Moodle language.


The multilang syntax was changed in 1.8, <nowiki><lang></nowiki> is not supported any more. It is required to add ''class="multilang"'' into each <nowiki><span></nowiki> tag in multilang block. The new syntax is backwards compatible with old plugins, which means it can be used in older Moodle version.
The multilang syntax was changed in 1.8. <nowiki><lang></nowiki> is not supported any more. It is required to add ''class="multilang"'' into each <nowiki><span></nowiki> tag in multilang block. The new syntax is backwards compatible with old plugins, which means it can be used in older Moodle version.


== How to use ==
== How to use ==

Revision as of 11:27, 12 December 2006

Moodle will allow different resources to appear to users based upon their language. There is a filter called Multi language content (see Filters_(administrator)) and it should be turned on. This page goes into details of several ways of displaying resources to users based on language.

Overview multi language

The Multi-language content filter enables resources to be created in multiple languages. When turned on, it looks for <span lang="xx" class="multilang"> tags which indicate that a text contains multiple languages. Then it selects and outputs the best language for the current user. The language of the resource will change when the user changes their selected Moodle language.

The multilang syntax was changed in 1.8. <lang> is not supported any more. It is required to add class="multilang" into each <span> tag in multilang block. The new syntax is backwards compatible with old plugins, which means it can be used in older Moodle version.

How to use

To use this feature first create your contents in multiple languages (in the same resource). Then enclose each language block in the following tags:

      <span lang="XX" class="multilang">your_content_here</span>
      <span lang="YY" class="multilang">your_content_in_other_language_here</span>

It is essential to be in the "code" editing (press [<>] in the HTML editor), when you enter these tags for them to work. Please note that class="multilang" is not required prior to 1.8.

The obsoleted HTML tagging

      <lang lang="XX" class="multilang">your_content_here</lang>
      <lang lang="YY" class="multilang">your_content_in_other_language_here</lang>

will not work in 1.8 and later.

     <lang="XX">your_content_here</lang>
     <lang="YY">your_content_in_other_language_here</lang>

does NOT work.

Course summary and title tags

To be able to change even resource titles and summaries, you must chose "all strings" in the adminstration choices.

 <span lang="en" class="multilang">Matematically</span> <span lang="sv" class="multilang">Matematiskt (svenska)</span>

would function as English or Swedish title.

It doesn't seem to work for course titles (neither long nor short version).

In the course summary:

<span lang="en" class="multilang">Growth is often a major concern in planning society.
 How can one avoid superficial conclusions? <br>
(Exists in Swedish too. Finns på svenska också)</span>
 <span lang="sv" class="multilang">Tillväxt är ofta använt i samhällsdebatten. 
Hur kan man undvika ytliga slutsatser? 
 (Finns på engelska också. Exists in English too.)
<br /></span> 

Can show in the chosen language (and point out that the other language is there). Please note that class="multilang" is not required prior to Moodle 1.8.

Block tags

this part is incorrect - please consider removing it

That the filter works on multilanguage blocks is important, see forum: http://moodle.org/mod/forum/discuss.php?d=51603 : From which this is copied (and ought to be shortened):

 ... how the multilang filter works:

 1) First of all it looks for multilang Blocks. 
One Multilang block of text is defined as one group of <span lang="XX"> 
tags together, without anything between them.

 2) After this detection of Blocks, for each of them, Moodle selects 
the best language for the user displaying the info, showing its info 
and discarding the rest of lang tags in the block.

 So, applying this behaviour to the example you wrote above, we have:

1) Moodle looks for Blocks and it finds TWO blocks:

Block A: <span lang="de">von links</span>
Block B:<span lang="en"><span="en"><font size="3"> </font></span>from the left</span>

2) For each block, Moodle display the better language. As Both blocks 
only contain ONE lang tag, it's returned, so results are:

For Block A: von links
For Block B: <span="en"><font size="3"> </font></span>from the left

Then obviously, in one web page, those results are showed as:

von links
from the left

The key concept here is the Block of lang. Once you get it, everything is easily to understand. 

Also note that the HTMLEditor seems to introduce an excess of "noisy" tags
 under some circumstances and, if it does so between lang tags, it will be, 
in fact, breaking your blocks of langs! It's always recommended to check the
final HTML generated by the HTML Editor in order to verify that the lang tags 
(and their grouping together is conforming blocks of langs) are properly
 written.

Translations with tags

If I were to want to translate a word or phrase to a chosen language in an English text:

If I want to include an explanation <span lang="en"> </span>
 <span lang="sv" class="multilang">(sv: förklaring)</span> in a running text can I do it?
<br />
<br /><span lang="en" class="multilang>If I want to include an explanation in a running text
 can I do it? </span>
<span lang="sv" class="multilang>If I want to include an explanation (sv: förklaring) in a 
running text can I do it?</span>

would both work, but not:

If I want to include an explanation <span lang="en" class="multilang></span>
 <span lang="sv" class="multilang>(sv: förklaring)</span> in a running text can I do it?
<br />If I want to include an explanation <span lang="sv" class="multilang>(sv: förklaring)</span>
 in a running text can I do it?<br />

which would show the Swedish even if English was the chosen language. NOTE the "span lang=en" must contain something, at least a space.

Moodle1.8


New multilang syntax

See Also

Filters_(administrator)

Forum discussion http://moodle.org/mod/forum/discuss.php?d=51603