Multilanguage filter - does not work ...

Multilanguage filter - does not work ...

by Peter Sereinigg -
Number of replies: 27

I cant get the multilanguage filter become working ....
this is what i copy into html:

<br /><font size="1"><span lang="de">von links</span>&nbsp; <br /><span lang="en"><span="en"><font size="3">&nbsp;</font></span>from the left</span> </font>

 this is was you can find on the page after multilanguage filter should have "worked"

<br /><font size="1">von links&nbsp;
  <br /><span="en"><font size="3">&nbsp;</font>from the left</span> </font>

and this is what you find in the block

von links 
from the left

no change depending on german or english ...

any idea what i am doing wrong?

Filter is enabled on the first position!

1.6.1+, 11.8.2006

Thanks for your help Peter 

Average of ratings: -
In reply to Peter Sereinigg

Re: Multilanguage filter - does not work ...

by Helen Foster -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi Peter,

Perhaps the tag <span="en"> is causing the problem. Please try the following:
<span lang="de">von links</span>
<span lang="en">from the left</span>
In reply to Helen Foster

Re: Multilanguage filter - does not work ...

by Peter Sereinigg -

Sorry - no result ... I tried this in different blocks and ressourceparts ...

Latest update, 1.6.1+ 11.8.2006

Peter

In reply to Peter Sereinigg

Re: Multilanguage filter - does not work ...

by Petr Skoda -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers
Hmm, there is no 'de' language in 1.6.1+ and 'en' should not be used anymore too, you should try 'de_utf8' and 'en_utf8' instead.
In reply to Petr Skoda

Re: Multilanguage filter - does not work ...

by Peter Sereinigg -

No result ..

HTML

><font face="verdana,arial,helvetica,sans-serif"><font size="1"><span lang="de_utf8">von links</span> <br /></font></font><font face="verdana,arial,helvetica,sans-serif" size="2"><span lang="en_utf8"><font size="1">from the left</font></span> <br /><br /></font>

after multilanguage filter in the code

 von links from the left

and no result on the page,

 

if you dont mind, i will send you a link and an account

Peter

 

In reply to Helen Foster

Re: Multilanguage filter - does not work ...

by Claire Browne -
Hi

I am having problems with the Multilang.

I have a course where i want each resource to be displayed in "TW" OR "EN".

I have put this in at present, but it does not work because i see both english and tawain.

Preparation and Guidance for Portfolio



How do I get it to show 1 or the other not both.

I am working in 1.9.7
In reply to Claire Browne

Re: Multilanguage filter - does not work ...

by Joerg Maschtaler -
Hi Claire,

can you post an example of the HTML source of the text for which Multilang doesn't work?

cheers,
Joerg
In reply to Joerg Maschtaler

Re: Multilanguage filter - does not work ...

by Claire Browne -
Hi,

Thanks for your prompt reply, i have successfully worked this one out on my own.

I was using the correct code but when it come to putting the language in i was just putting in tw or en and using the full language code.

zh_tw and en_utf8
In reply to Peter Sereinigg

Re: Multilanguage filter - does not work ...

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Peter,

I really think that the example you wrote above is wrong! First of all, letme explain a bit 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

(as you defined in your initial post)

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

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.

Hope this helps...ciao smile
In reply to Eloy Lafuente (stronk7)

Re: Multilanguage filter - does not work ...

by Petr Skoda -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers
I found a bug in my regex code and one design flaw - removing the patch sad

But anyway I do not like the idea of "lang and span blocks" in html code and 'en' being the default language.

I guess I found following problems in current implementation:

* text caching could be optimized when multilang enabled
* users sometimes use single quotes instead of double-quotes
* some non-english languages have language parent 'en_utf8' which is IMHO wrong, because it should be reserved for really close languages such as "en" and "en_US" - this should not affect current implementation of multilang, but could bite us later...
In reply to Petr Skoda

Re: Multilanguage filter - does not work ...

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
do not like the idea of "lang and span blocks" in html code

Going to the past, the multilang filter only supported the "lang" tag. Then, officially, we changed it to the "span" tag (it's standard HTML), but the "lang" tag continued working (deprecated) for compatibility with previous contents. A lot of time has passed since then, perhaps it would be a good idea to kill "lang" support soon (1.7, 2.0)?

and 'en' being the default language

Well, current matches order is (without differences between utf8 or non utf8 langs):

- exact match: user lang is found and showed.
- parent match: parent lang of the user lang is found and showed.
- en: English lang is found and showed.
- first lang found is showed.

Really I should agree that it seems that defaulting to English could not have too much sense in the filter, so +1 to kill it.

* text caching could be optimized when multilang enabled

Agree, I remember us sometime ago, talking about it. The drawback was that it could need to add one new "lang" column to the cache table, and we were a bit worried about the "multiplication" effect if could cause. But yes, it should be done. I think.

* users sometimes use single quotes instead of double-quotes

Single quotes are wrong, I think, from a HTML perspective. So I think it really has sense to keep only double-quotes working.

* some non-english languages have language parent 'en_utf8' which is IMHO wrong

100% agree. If I'm not wrong recently a lot of that "false paternities" have been cleaned from a lot of langs. Only closer langs (the English family, the Spanish family...) shoud use them. And of course, setting the parentlang to "en_utf8", only has sense in the "English Family" and it hasn't sense to set it in other langs (out from the family) because Moodle itself defaults to English without need to specify it as parentlang.

Ciao smile

P.S.: About the bug report above, I'm a bit lost.... mixed
In reply to Eloy Lafuente (stronk7)

Re: Multilanguage filter - does not work ...

by Peter Sereinigg -

1.) Is there any reason to write direct to html - code?

TEX-Filter works with signs direct in text to filter the subjects.

There should be a possible easy way to do the same here

  • $ $\tiny 3x$ $ (without the blank) will bring this result $$\tiny 3x$$
  • why should we not do similar thoughts with multilanguage
    • will start here
      /&&&de(selected language)
      &&&result in that language
      /&&&fr((selected language)
      &&&result in that language
      /&&&alternate text (may be empty, the last one in that row)
      &&&/ 
      end

"&" is just an example, but it could be a possible description for IF - IFelse - IFelse ... ELSE ... System

This would be easier much to write ...

2.) Fallbacklanguage: English at LAST choice would be a good idea. because its the only language which is realy up to date ... but languages are quite different (GERMAN - German or Austria or Swiz...) there are importand differences and it makes sense to have one globale GERMAN (de_utf8), you may change single therms in German - Austria but it would fall back to GERMAN (de_utf8) and then to ENGLISH (en_utf8)

Peter

In reply to Peter Sereinigg

Re: Multilanguage filter - does not work ...

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Peter,

1) I haven't nothing against other tagging alternatives, absolutely! But IMO the current one is pretty descriptive and uses well known standard html tags. Also, I really think that IF/ELSE tagging doesn't fit exactly in what the filter does (take the BEST from a group of alternatives).

2) Not sure about you wan't to say here. Your example about different "flavours" of German are exactly the same than the Spanish (where "es" is the parent lang of a buch of variations "es_mx", "es_es"...). So, it's ok to define "de" as parentlang to the rest of the family. Multilang filter will use it. No problem. (note that I've stripped all the "_utf8" suffixes for readability). wink

What I was considering is if it has sense that the "fallback to English", that is really useful in the language strings architecture, has any real sense in the multilang filter architecture. I cannot find any good reason to prioritise English there. Perhaps other languages could be prioritised instead (site lang...).

Ciao smile
In reply to Eloy Lafuente (stronk7)

Re: Multilanguage filter - does not work ...

by Peter Sereinigg -

Hi Eloy,

1.) ... accepted - but a changed version would be easyer for "normal" useres .. shy

2.) ... accepted until i have more/better arguments wink

Peter

 

the filter now works on my page, after Petr changed something in the tags ...thanks for ypur help!
<span lang="de">von links</span><span lang="en">from the left</span>

In reply to Peter Sereinigg

Re: Multilanguage filter - does not work ...

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Yay!

and from I've been able to read in Bug 6245, it seems that, if all the tests go ok. Moodle 1.6.2 will debut a really better filtering system plus great improvements in the multilang filter.

Great job, Petr! cool
In reply to Eloy Lafuente (stronk7)

Re: Multilanguage filter - does not work ...

by Petr Skoda -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers
Rewritten filter with original syntax is in HEAD. If anybody wants to test it, it can be used in latest 1.6.1+ too wink

I would recommend it for large sites that are using multilang...
In reply to Petr Skoda

Re: Multilanguage filter - does not work ...

by Robert Brenstein -
> text caching could be optimized when multilang enabled

Is text caching enabled when multilang filter is used in 1.6? It was force-disabled in earlier versions. In other words, caching was suspended when multilang was active.

I put a few thoughts into docs (http://docs.moodle.org/en/Multilang_filter) a while ago about caching text when multilang is active.
In reply to Eloy Lafuente (stronk7)

Re: Multilanguage filter - does not work ...

by Jeff Forssell -
Your information helped me finally get things working. The only thing that doesn't work now is the course title (neither long nor short) in spite of my choosing "all strings" in filter configuration. Is that a limitation in the filter or have I done something wrong?

I've tried to sum up my experiences in the Doc Wiki
Wellcome to see if there's anything missleading.
In reply to Jeff Forssell

Re: Multilanguage filter - does not work ...

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Jeff,

you're right. Course names and some other strings aren't covered by the multilang filter, neither with "filter all" enabled.

Filtered and unfiltered strings can be found in http://docs.moodle.org/en/Filterall_support

Just wondering when we'll be able to extend support for all those strings... mixed

Ciao smile

P.S: And thanks for your collaboration in the Docs, Jeff and Robert! cool
In reply to Eloy Lafuente (stronk7)

Re: Multilanguage filter - does not work ...

by Patrick Martin -
Hi there Eloy,

I have been working with the Multi-lang filter quite a bit and I would likely be able to contribute to moodle by adding some of the missing calls. I have a couple questions though:

-Should I be using the filter_text() function or some other function?

-How can I have the changes go into the main moodle trunk? Do I have to use CVS? (I am using moodle 1.6.3+)


Thanks!
Patrick

In reply to Patrick Martin

Re: Multilanguage filter - does not work ...

by Tom Hogan -
Just wanted to add that we really need the multi-lang filter to work for Glossary entries.

We are using a site-wide glossary to explain very basic terms to ESL students in Korea. If they can only get the explanation in English, its usefulness will be greatly diminished.

From http://docs.moodle.org/en/Filterall_support

Glossary module:
  • glossary->name: Done!
  • ---glossary_entries->concept---
  • ---glossary_categories->name---

In reply to Tom Hogan

Re: Multilanguage filter - does not work ...

by Sebastien M. -
Hello Tore:

Assuming that all your glossary concepts are coded with the new lang tag (i.e. <span lang="xx" class="multilang">) here is a quick fix I used on v1.8.2+. Use this at your own risks as I am no php guru.

----------------
In file:
======>mod/glossary/filter.php

STEP 1 – This will prevent the lang tag from being stripped so early

-- FIND --
$currentconcept = trim(strip_tags($concept->concept));

-- replace by --
$currentconcept = trim($concept->concept);

STEP 2 – This will create your formatted concept for later use

-- FIND --
foreach ($concepts as $concept) {

-- below ADD –
$m_concept = multilang_filter($courseid, $concept->concept);

STEP 3 – This will trigger phrase filtering with the stripped concepts

-- FIND --
$conceptlist[] = new filterobject($concept->concept, $href_tag_begin, '</a>',
$concept->casesensitive, $concept->fullmatch);

-- replace by --
$conceptlist[] = new filterobject($m_concept, $href_tag_begin, '</a>',
$concept->casesensitive, $concept->fullmatch);

----------------

That’s it!

I am not sure that this is optimal coding but it is doing the job for now.

Good luck!

S
In reply to Sebastien M.

Re: Multilanguage filter - does not work ...

by András Murányi -
Multilang support is a mess in 1.8. Course category and other titles using multilang are displayed properly in the menu, however on the front page all languages are displayed at the same time and on the concerned page, even worse, the HTML source of the title is displayed.
Please this is a long-time problem and IMHO quite basic requirement, when can we hope it will be fixed?
In reply to Patrick Martin

Re: Multilanguage filter - does not work ...

by Nicolas Connault -
When you want to contribute to Moodle core code, you need to either post a diff (i.e. patch) file here, or even better, file an issue in the Moodle Tracker http://tracker.moodle.org and post your patch. Moodle HQ will then review it (as well as the rest of the Moodle community) after which it will be applied to Moodle core if it qualifies.

Thanks in advance smile
In reply to Peter Sereinigg

Re: Multilanguage filter - does not work ...

by Cameron Bunch -

I see that this is slated to get fixed in 2.0 but also that it is currently unresolved so I am not sure when the fix will actually be in place. I thought I would offer a solution that can work in some cases to get around this and might in some cases actually be better than placing complex content into multilang span blocks.

The idea here is to use iframes placing one iframe in each multilang span block. The src reference in the iframe points to a URL that provides the desired content in the required language. For example:

<span class="multilang" lang="en">
<iframe width="100%" height="1000" align="middle" src="http:example.com/mycourse/en/lesson1" border="0">
</iframe>
</span>
<span class="multilang" lang="es">
<iframe width="100%" height="1000" align="middle" src="http:example.com/mycourse/es/lesson1" border="0">
</iframe>
</span>

In this case the content is provided by a web server that has the English and Spanish versions separated into two areas of the site. The content delivered into the iframes can be arbitrarily complex. In the case that the content needs to be protected from access not controlled by a login to the course a mechanism would be required to block access from an IP that does not have a current login. I am playing around with that since I will need it. But it seems do-able enough.

This has the potential advantage of allowing course content to be updated without havine to modify the course in Moodle as long as the changes do not involve any structural modification of the course. The smaller maintenance tweaks to content may frequently fall into that category.

Regards,

Cameron


                                    
In reply to Cameron Bunch

Re: Multilanguage filter - does not work ...

by Eric Fichtl -
I had a similar idea to Cameron's. Basically, shouldn't the multilang elements be a div class, rather than a span class? This would allow us to use multiple span classes between one set of div tags, thus avoiding the issue raised in this forum: http://moodle.org/mod/forum/discuss.php?d=145421

So, could it be:

<div class="multilang" lang="en">
<h1>Title in English</h1>
<span class="special">This is special text</span>
<p>This is regular text</p>
<span class ="outro'>This is outro text</span>
</div>

<div class="multilang" lang="es">
<h1>Titulo en español</h1>
<span class="special">Esto es texto especial</span>
<p>Esto es texto normal</p>
<span class ="outro'>Esto es texto outro</span>
</div>

The fact that multilang is broken by the use of spans to apply style—a core concept of CSS—is really putting Moodle at odds with web standards. In my case, I'm applying custom styles via CSS, not just bolds and italics...

Have other users found a workaround for this lapse?

Thanks,
Eric
In reply to Eric Fichtl

Vastus: Re: Multilanguage filter - does not work ...

by Tõnis Tartes -
Picture of Core developers Picture of Plugin developers Picture of Testers Picture of Translators

As temporary hack you can try to change all the extra span tags between

<span lang="en" class="multilang"><span style="font-color:#ddd;">text</span></span>

change to

<span lang="en" class="multilang"><b style="font-color:#ddd;">text</b></span>

if you dont want the text to be bold then you need to add

<span lang="en" class="multilang"><b style="font-color:#ddd;font-weight:normal;">text</b></span>

With alot text its a pain to change all the span tags between the span tags to make it work, but still its a workaround.

 

Worked for me atleast!