My suggestion for a new version of multilanguage filter

My suggestion for a new version of multilanguage filter

by Vanyo Georgiev -
Number of replies: 6

The essence of my suggestion is the multilanguage filter to search only for lang="xx" attributes in html tags regardless of the kind of tag and other tag attributes. The new version of the multilang filter finds each sequence of identical tags with lang="xx" attributes. For example:

 

<h1 lang="en">A heading in English</h1>

<h1 lang="bg">A heading in Bulgarian</h1>

 

or

 

<p lang="en" style="...">A paragraph in English</p>

<p lang="bg" class="...">A paragraph in Bulgarian</p>

<p lang="ro">A paragraph in Romanian</p>

 

and so on.

 

And the filter chooses and shows only the tag with a lang attribute for the current language.

 

The advantages of this are:

 

  • Flexibility.

  • Compatibility - this works with old multilanguage syntax with <lang> tags as well as with the new syntax with <span class="multilang" lang="xx"> tags and with <div> tags in case the MDL-32257 improvement is used.

  • Opportunity to add and remove lang tags with TinyMCE editor. I think it will be easy to implement such functionality in TinyMCE.

  • Simplicity of the regexpresion used for search pattern resulting in a higher speed.

 

I implemented this suggestion and the source code is here:

 

https://github.com/vanyog/moodle/blob/master/filter/multilang/filter.php

or as attachment to this message.

Please, if you are interested, test it and give some feedback.

Average of ratings: Useful (4)
In reply to Vanyo Georgiev

Re: My suggestion for a new version of multilanguage filter

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Tested, works fine for me. Thanks!

Joseph

In reply to Vanyo Georgiev

Re: My suggestion for a new version of multilanguage filter

by Nadav Kavalerchik -
Picture of Core developers Picture of Plugin developers Picture of Testers Picture of Translators

Same here (With Hebrew. not that it matters which language)

Works great smile

In reply to Nadav Kavalerchik

Re: My suggestion for a new version of multilanguage filter

by Sarah Jane -

I have spent an entire day working through all the suggests within the forums on this - as soon as I found this forum and changed the filter Hey presto all is working.

Even able to add colour and images to each language

Great Job - thank you x

In reply to Sarah Jane

Re: My suggestion for a new version of multilanguage filter

by Sarah Jane -

I spoke too soon this isn't working in the name sections and having a dreadful time to get it work anywhere else. Don't understand as it works fine in the front page but not anywhere else.

will keep trying

In reply to Sarah Jane

Re: My suggestion for a new version of multilanguage filter

by Sarah Jane -

Can anyone help please, I have this working in the content of a course but it just will not work in the name section: I have tried div and span and nothing is sticking -

(I have upload the latest filters.php files )

can anyone point me in the right direction please.

Sarah - using moodle 2.4.3  thanks

In reply to Sarah Jane

Re: My suggestion for a new version of multilanguage filter

by Sarah Jane -

Can not beleive how thick I have been. out of desperation I went to admin to check that I haven't removed the mulitlang settings to off and discover that I had the settings set to content only - I change this to headers and content and hey presto smile

I wish I thought of this earlier this morning arhhhhhh!

Sarahx