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
(Started to put in more headings)
 
(60 intermediate revisions by 7 users not shown)
Line 1: Line 1:
Moodle will allow different resources to appear to users based upon their language. This is a filter called Multi language content. This page goes into details of several ways of displaying resources to users based on 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.


This is the information that was in [[Filters_%28administrator%29]].
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.


== Overview multi language ==
== How to use in a course ==


The Multi-language content filter enables resources to be created in multiple languages. When turned on, it looks for <lang> 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. 
To use this feature first create your contents in multiple languages (in the same resource). Then enclose each language block (aka multilang block) in the following tags:


== How to use ==
      <nowiki><span lang="XX" class="multilang">your_content_here</span>
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="YY" class="multilang">your_content_in_other_language_here</span></nowiki>


      <nowiki><span lang="XX">your_content_here</span>
It is essential to be in '''the code editing mode''' (press <nowiki>[<>]</nowiki> in the HTML editor), when you enter these tags for them to work. Only spaces, tabs and enters can be used between the individual languages in the multilang block. Please note that ''class="multilang"'' is not required prior to 1.8. There is a lang drop-down markup tool in the HTML editor in later versions of Moodle. The first versions, at least to 1.8.2, do not make "multilang" language tags. If you are working in a sufficiently new version of the HTML editor you can add these tags without going to the code editing mode.  If something doesn't work properly you should check how the markup looks in code mode.
      <span lang="YY">your_content_in_other_language_here</span>
</nowiki>


It is essential to be in the "code" editing (press <nowiki>[<>]</nowiki> in the HTML editor), when you enter these tags for them to work.
Following code
      <nowiki><lang="XX">your_content_here</lang>
      <lang="YY">your_content_in_other_language_here</lang></nowiki>
does NOT work.


Even the HTML tagging
The obsoleted HTML tagging
       <nowiki><lang lang="XX">your_content_here</lang>
       <nowiki><lang lang="XX">your_content_here</lang>
       <lang lang="YY">your_content_in_other_language_here</lang>
       <lang lang="YY">your_content_in_other_language_here</lang>
</nowiki>
works, but may be unsupported from 1.7.
      <nowiki><lang="XX">your_content_here</lang>
    <lang="YY">your_content_in_other_language_here</lang>
</nowiki>
does NOT work.


      <span lang="XX">your_content_here</span>
      <span lang="YY">your_content_in_other_language_here</span></nowiki>
will not work in 1.8 and later. In 1.8 the lang attribute without ''class="multilang"'' can be used to mark the language of the text - see http://www.w3.org/TR/html4/struct/dirlang.html
== How it works internally ==
# Filter first looks for ''multilang blocks'' in the text
# For each multilang block:
#* If there are texts in the currently active language, print them
#* Else, if there exists texts in the current parent language, print them
#* Else, print the first language found in the text
# Text outside of multilang blocks will be shown always
==Course summary and title tags==
To be able to change text such as resource titles and summaries, an administrator must choose ''Filter all strings'' in the site administration.


To be able to change even resource titles and summaries, you must chose "all strings" in the adminstration choices.
  <nowiki> <span lang="en" class="multilang">Matematically</span> <span lang="sv" class="multilang">Matematiskt (svenska)</span></nowiki>
  <nowiki> <span lang="en">Matematically</span> <span lang="sv">Matematiskt (svenska)</span></nowiki>
functions as English or Swedish title.
would function as English or Swedish title.


It doesn't seem to work for course titles (neither long nor short version).
It doesn't work for course titles and site names (neither long nor short version) in some versions of Moodle. At least from 1.8.2 long course titles and site name, both full and breadcrumb were multilang filtered. 


In the course summary:
In the course summary:


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


Can show in the chosen language (and point out that the other language is there).
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.


That the filter works on multilanguage blocks is important, see forum: http://moodle.org/mod/forum/discuss.php?d=51603 :
== Translations with tags ==
From which this is copied (and ought to be shortened):
If you wish to translate a word or phrase in an English text to another language:
<nowiki>
... how the multilang filter works:


  1) First of all it looks for multilang Blocks.
  <nowiki>If I want to include an explanation <span lang="en"> </span>
One Multilang block of text is defined as one group of <span lang="XX">  
<span lang="sv" class="multilang">(sv: förklaring)</span> in a running text
tags together, without anything between them.
can I do it?</nowiki>
or
<nowiki><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></nowiki>


2) After this detection of Blocks, for each of them, Moodle selects
would both work, but not:
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>
<nowiki>If I want to include an explanation <span lang="en" class="multilang></span>
Block B:<span lang="en"><span="en"><font size="3"> </font></span>from the left</span>
<span lang="sv" class="multilang>(sv: förklaring)</span> in a running text
can I do it?</nowiki>
or
<nowiki>If I want to include an explanation <span lang="sv" class="multilang>
(sv: förklaring)</span> in a running text can I do it?</nowiki>
which would show the Swedish even if English was the chosen language. NOTE that before 1.8 the "span lang=en" must contain something, at least a space.


2) For each block, Moodle display the better language. As Both blocks
== New multilang syntax ==
only contain ONE lang tag, it's returned, so results are:
{{Moodle 1.8}}
* <nowiki><span lang="xx"> and <lang></nowiki> should not be used anymore
* Existing content can be upgraded using the admin/multilangupgrade.php script, there is a link in the admin notification page if a multilang upgrade is required.
* The multilang filter can be configured to use old syntax only - see ''Multi-Language Content Settings''; this setting may be removed in 1.9
* New syntax is forced during a new 1.8 installation, for upgraded sites the new syntax is enabled after the multilang upgrade


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


Then obviously, in one web page, those results are showed as:
* The multilang filter is not enabled. The administrator for the Moodle site you are using must go to Site administration> modules> Multilanguage Content and enable it (by clicking on the "eye")
* ''Filter all strings'' not enabled on sites that need multilang in titles, navigation, headings, etc.  The administrator for the Moodle site you are using must go to Site administration> appearance> Filter settings and set a check in "filter alll strings". This will increase server load slightly, so don't do it unless you really need it.
* Extra characters between language span tags - editor might add <nowiki><br /></nowiki> or other tags, please review the html in source view
* If the course setting is "force" some language, you won't be able to change the displayed language.
* Extra spaces in language span tag
* Can not easily access language choice dropdown! Unfortunately you must go to the site homepage or your own profile to change the displayed language. Want a change? see [http://tracker.moodle.org/browse/MDL-11531 MDL-11531]. It is possible to manually quickly change displayed lang by editing the URL in the browsers address bar. See Tips and tricks below!


von links
==Tips and tricks==
from the left
===Lang dropdown in HTML editor===
In later versions of Moodle there is a lang dropdown in the HTML editor that can be used to do multilang markup. You may have to go to the "edit source" mode (with the ['''<>'''] button) to check, and maybe correct, how things turned out.
===Changing language displayed without going to front page===
It is possible to change the displayed language by manually changing the link. 
*Here is the default language page at id=2306. This link is in English, the default language:
:http://moodle.org/mod/resource/view.php?id=2306
*The link to change the page display to Spanish is
:http://moodle.org/mod/resource/view.php?id=2306&lang=es ,
*When the default language is an other language, to change the page to an English version, the link would be:
:http://moodle.org/mod/resource/view.php?id=2306&lang=en


The key concept here is the Block of lang. Once you get it, everything is easily to understand.  
Thusly, with a bit of editing, you can manually change the displayed language by adding "&lang=xx" to the URL in the location bar of the browser. Where xx is the abbreviation for the language you want.


Also note that the HTMLEditor seems to introduce an excess of "noisy" tags
===Bandwidth-adaptivity===
under some circumstances and, if it does so between lang tags, it will be,
One inventive fellow has made a hack to use the multilang filter to be able to adapt the sent content to a users chosen bandwidth. Especiallly international courses can have users with extremely varied Internet connection speeds and this can allow them to chose what level of content (Low = text and small pictures, medium = some mp3, high = some video and other heavy stuff) suits them.
in fact, breaking your blocks of langs! It's always recommended to check the
[http://paaralan.blogspot.com/2009/08/hack-bandwidth-adaptivity-for-moodle.html the blog with description and downloads]
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.</nowiki>


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


<nowiki>If I want to include an explanation <span lang="en"> </span>
*[[Filters|Filters administration]]
<span lang="sv">(sv: förklaring)</span> in a running text can I do it?
Using Moodle forum discussions:
<br />
<br /><span lang="en">If I want to include an explanation in a running text
can I do it? </span>
<span lang="sv">If I want to include an explanation (sv: förklaring) in a
running text can I do it?</span></nowiki>


would both work, but not:
*[http://moodle.org/mod/forum/discuss.php?d=51603 Multilanguage filter - does not work ...]
*[http://moodle.org/mod/forum/discuss.php?d=74340 Problems with multilang filter and SPAN tags]
*[http://moodle.org/mod/forum/discuss.php?d=94006 Multilingual Content]
*[http://moodle.org/mod/forum/discuss.php?d=95134 Multilingual VS HTML editor]


<nowiki>If I want to include an explanation <span lang="en"></span>
<span lang="sv">(sv: förklaring)</span> in a running text can I do it?
<br />If I want to include an explanation <span lang="sv">(sv: förklaring)</span>
in a running text can I do it?<br /></nowiki>
which would show the Swedish even if English was the chosen language. NOTE the "span lang=en" must contain something, at least a space.


== See Also ==
[[Category:Teacher]]
[[Filters_%28administrator%29]]
[[Category:Filter]]
[[Category:Language]]


Forum discussion  http://moodle.org/mod/forum/discuss.php?d=51603
[[es:Filtros (Administrador)]]
[[fr:Contenu multilingue]]
[[ja:多言語シンタックス]]

Latest revision as of 08:16, 22 March 2010

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 in a course

To use this feature first create your contents in multiple languages (in the same resource). Then enclose each language block (aka multilang 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 mode (press [<>] in the HTML editor), when you enter these tags for them to work. Only spaces, tabs and enters can be used between the individual languages in the multilang block. Please note that class="multilang" is not required prior to 1.8. There is a lang drop-down markup tool in the HTML editor in later versions of Moodle. The first versions, at least to 1.8.2, do not make "multilang" language tags. If you are working in a sufficiently new version of the HTML editor you can add these tags without going to the code editing mode. If something doesn't work properly you should check how the markup looks in code mode.

Following code

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

does NOT work.

The obsoleted HTML tagging

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

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

will not work in 1.8 and later. In 1.8 the lang attribute without class="multilang" can be used to mark the language of the text - see http://www.w3.org/TR/html4/struct/dirlang.html

How it works internally

  1. Filter first looks for multilang blocks in the text
  2. For each multilang block:
    • If there are texts in the currently active language, print them
    • Else, if there exists texts in the current parent language, print them
    • Else, print the first language found in the text
  3. Text outside of multilang blocks will be shown always

Course summary and title tags

To be able to change text such as resource titles and summaries, an administrator must choose Filter all strings in the site administration.

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

functions as English or Swedish title.

It doesn't work for course titles and site names (neither long nor short version) in some versions of Moodle. At least from 1.8.2 long course titles and site name, both full and breadcrumb were multilang filtered.

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.

Translations with tags

If you wish to translate a word or phrase in an English text to another language:

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?

or

<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?

or

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

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

New multilang syntax

Moodle1.8


  • <span lang="xx"> and <lang> should not be used anymore
  • Existing content can be upgraded using the admin/multilangupgrade.php script, there is a link in the admin notification page if a multilang upgrade is required.
  • The multilang filter can be configured to use old syntax only - see Multi-Language Content Settings; this setting may be removed in 1.9
  • New syntax is forced during a new 1.8 installation, for upgraded sites the new syntax is enabled after the multilang upgrade

Common problems

  • The multilang filter is not enabled. The administrator for the Moodle site you are using must go to Site administration> modules> Multilanguage Content and enable it (by clicking on the "eye")
  • Filter all strings not enabled on sites that need multilang in titles, navigation, headings, etc. The administrator for the Moodle site you are using must go to Site administration> appearance> Filter settings and set a check in "filter alll strings". This will increase server load slightly, so don't do it unless you really need it.
  • Extra characters between language span tags - editor might add <br /> or other tags, please review the html in source view
  • If the course setting is "force" some language, you won't be able to change the displayed language.
  • Extra spaces in language span tag
  • Can not easily access language choice dropdown! Unfortunately you must go to the site homepage or your own profile to change the displayed language. Want a change? see [https://tracker.moodle.org/browse/MDL-11531 MDL-11531]. It is possible to manually quickly change displayed lang by editing the URL in the browsers address bar. See Tips and tricks below!

Tips and tricks

Lang dropdown in HTML editor

In later versions of Moodle there is a lang dropdown in the HTML editor that can be used to do multilang markup. You may have to go to the "edit source" mode (with the [<>] button) to check, and maybe correct, how things turned out.

Changing language displayed without going to front page

It is possible to change the displayed language by manually changing the link.

  • Here is the default language page at id=2306. This link is in English, the default language:
http://moodle.org/mod/resource/view.php?id=2306
  • The link to change the page display to Spanish is
http://moodle.org/mod/resource/view.php?id=2306&lang=es ,
  • When the default language is an other language, to change the page to an English version, the link would be:
http://moodle.org/mod/resource/view.php?id=2306&lang=en

Thusly, with a bit of editing, you can manually change the displayed language by adding "&lang=xx" to the URL in the location bar of the browser. Where xx is the abbreviation for the language you want.

Bandwidth-adaptivity

One inventive fellow has made a hack to use the multilang filter to be able to adapt the sent content to a users chosen bandwidth. Especiallly international courses can have users with extremely varied Internet connection speeds and this can allow them to chose what level of content (Low = text and small pictures, medium = some mp3, high = some video and other heavy stuff) suits them. the blog with description and downloads

See also

Using Moodle forum discussions: