Moodle
  1. Moodle
  2. MDL-32257

Multilanguage filter work for <div> as well as <span> tags

    Details

    • Testing Instructions:
      Hide
      1. Add language packs 'en' and 'ar' to moodle site
      2. Navigate to Site Administration > Plugins > Filters > Manage filters and enable the Multi-language content filter
      3. Return to the site front page and turn editing on
      4. Edit the sitetopic summary element on the front page, and paste the following markup into the HTML editor (not the WYSIWYG)
        <div lang="en" class="multilang">
        <p>For Lesson 1, you must:</p>
        <ul>
        <li>Complete the Lesson 1 Pre-Assessment</li>
        <li>Listen to and watch the "Mawhiba" Presentation</li>
        <li>Complete the Lesson 1 Post-Assessment</li>
        </ul>
        <p>Before beginning this lesson, check the glossary if you are unfamiliar with these terms:</p>
        <ul>
        <li>Mawhiba initiatives</li>
        <li>Mawhiba's mission</li>
        <li>Mawhiba's vision and goals</li>
        <li>Stakeholders</li>
        </ul>
        </div>
        
        
        <div lang="ar" class="multilang">
        <p>للدرس الأول يجب عليك :</p>
        <ul>
        <li>إكمال التقييم القبلي للدرس الأول</li>
        <li>الاستماع إلى ومشاهدة العرض التقديمي لـ"موهبة"</li>
        <li>إكمال التقييم البعدي للدرس الأول</li>
        </ul>
        <p>قبل بداية الدرس ارجع لقائمة المصطلحات في حال عدم معرفتك بالمصطلحات التالية:</p>
        <ul>
        <li>مبادرات موهبة</li>
        <li>رسالة موهبة</li>
        <li>رؤية موهبة وأهدافها</li>
        <li>أصحاب المصلحة</li>
        </ul>
        </div>
        
        
      5. Save your changes
      6. View the front page. Toggle the language selection. When lang ar is selected, only the Arabic content in sitetopic summary should be displayed. When lang en is selected, only the English content in sitetopic summary should be displayed.
      Show
      Add language packs 'en' and 'ar' to moodle site Navigate to Site Administration > Plugins > Filters > Manage filters and enable the Multi-language content filter Return to the site front page and turn editing on Edit the sitetopic summary element on the front page, and paste the following markup into the HTML editor ( not the WYSIWYG) <div lang= "en" class= "multilang" > <p>For Lesson 1, you must:</p> <ul> <li>Complete the Lesson 1 Pre-Assessment</li> <li>Listen to and watch the "Mawhiba" Presentation</li> <li>Complete the Lesson 1 Post-Assessment</li> </ul> <p>Before beginning this lesson, check the glossary if you are unfamiliar with these terms:</p> <ul> <li>Mawhiba initiatives</li> <li>Mawhiba's mission</li> <li>Mawhiba's vision and goals</li> <li>Stakeholders</li> </ul> </div> <div lang= "ar" class= "multilang" > <p>للدرس الأول يجب عليك :</p> <ul> <li>إكمال التقييم القبلي للدرس الأول</li> <li>الاستماع إلى ومشاهدة العرض التقديمي لـ "موهبة" </li> <li>إكمال التقييم البعدي للدرس الأول</li> </ul> <p>قبل بداية الدرس ارجع لقائمة المصطلحات في حال عدم معرفتك بالمصطلحات التالية:</p> <ul> <li>مبادرات موهبة</li> <li>رسالة موهبة</li> <li>رؤية موهبة وأهدافها</li> <li>أصحاب المصلحة</li> </ul> </div> Save your changes View the front page. Toggle the language selection. When lang ar is selected, only the Arabic content in sitetopic summary should be displayed. When lang en is selected, only the English content in sitetopic summary should be displayed.
    • Affected Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull from Repository:
    • Rank:
      39045

      Description

      Solution proposed by Michael de Raadt in MDL-31531 to allow use of multilang filter on long passages. <span> tags applied to long passages are stripped out by TinyMCE.

      <span> tags are stripped from passage below.

      
      <span lang="en" class="multilang">
      <p>For Lesson 1, you must:</p>
      <ul>
      <li>Complete the Lesson 1 Pre-Assessment</li>
      <li>Listen to and watch the "Mawhiba" Presentation</li>
      <li>Complete the Lesson 1 Post-Assessment</li>
      </ul>
      <p>Before beginning this lesson, check the glossary if you are unfamiliar with these terms:</p>
      <ul>
      <li>Mawhiba initiatives</li>
      <li>Mawhiba's mission</li>
      <li>Mawhiba's vision and goals</li>
      <li>Stakeholders</li>
      </ul>
      </span>
      
      
      <span lang="ar" class="multilang">
      <p>للدرس الأول يجب عليك :</p>
      <ul>
      <li>إكمال التقييم القبلي للدرس الأول</li>
      <li>الاستماع إلى ومشاهدة العرض التقديمي لـ"موهبة"</li>
      <li>إكمال التقييم البعدي للدرس الأول</li>
      </ul>
      <p>قبل بداية الدرس ارجع لقائمة المصطلحات في حال عدم معرفتك بالمصطلحات التالية:</p>
      <ul>
      <li>مبادرات موهبة</li>
      <li>رسالة موهبة</li>
      <li>رؤية موهبة وأهدافها</li>
      <li>أصحاب المصلحة</li>
      </ul>
      </span>
      
      

      Alternative would be something like this:

      
      <div lang="en" class="multilang">
      <p>For Lesson 1, you must:</p>
      <ul>
      <li>Complete the Lesson 1 Pre-Assessment</li>
      <li>Listen to and watch the "Mawhiba" Presentation</li>
      <li>Complete the Lesson 1 Post-Assessment</li>
      </ul>
      <p>Before beginning this lesson, check the glossary if you are unfamiliar with these terms:</p>
      <ul>
      <li>Mawhiba initiatives</li>
      <li>Mawhiba's mission</li>
      <li>Mawhiba's vision and goals</li>
      <li>Stakeholders</li>
      </ul>
      </div>
      
      
      <div lang="ar" class="multilang">
      <p>للدرس الأول يجب عليك :</p>
      <ul>
      <li>إكمال التقييم القبلي للدرس الأول</li>
      <li>الاستماع إلى ومشاهدة العرض التقديمي لـ"موهبة"</li>
      <li>إكمال التقييم البعدي للدرس الأول</li>
      </ul>
      <p>قبل بداية الدرس ارجع لقائمة المصطلحات في حال عدم معرفتك بالمصطلحات التالية:</p>
      <ul>
      <li>مبادرات موهبة</li>
      <li>رسالة موهبة</li>
      <li>رؤية موهبة وأهدافها</li>
      <li>أصحاب المصلحة</li>
      </ul>
      </div>
      
      
      1. filter.php
        4 kB
        Vanyo Georgiav
      2. filter.php
        4 kB
        kiswap

        Issue Links

          Activity

          Hide
          Michael de Raadt added a comment -

          Thanks for creating this issue, Amy.

          Show
          Michael de Raadt added a comment - Thanks for creating this issue, Amy.
          Hide
          kiswap added a comment - - edited

          moodle 2.3.2:
          extending regexp with "div":

          filter/multilang/filter.php, line: 57
                      $search = '/(<(?:span|div)(\s+lang="[a-zA-Z0-9_-]+"|\s+class="multilang"){2}\s*>.*?<\/(?:span|div)>)(\s*<(?:span|div)(\s+lang="[a-zA-Z0-9_-]+"|\s+class="multilang"){2}\s*>.*?<\/(?:span|div)>)+/ism';
          
          filter/multilang/filter.php, line: 60
          $search = '/(<(?:lang|span|div) lang="[a-zA-Z0-9_-]*".*?>.*?<\/(?:lang|span|div)>)(\s*<(?:lang|span|div) lang="[a-zA-Z0-9_-]*".*?>.*?<\/(?:lang|span|div)>)+/is';
          
          filter/multilang/filter.php, line: 88
              $searchtosplit = '/<(?:lang|span|div)[^>]+lang="([a-zA-Z0-9_-]+)"[^>]*>(.*?)<\/(?:lang|span|div)>/is';
          
          Show
          kiswap added a comment - - edited moodle 2.3.2: extending regexp with "div": filter/multilang/filter.php, line: 57 $search = '/(<(?:span|div)(\s+lang= "[a-zA-Z0-9_-]+" |\s+class= "multilang" ){2}\s*>.*?<\/(?:span|div)>)(\s*<(?:span|div)(\s+lang= "[a-zA-Z0-9_-]+" |\s+class= "multilang" ){2}\s*>.*?<\/(?:span|div)>)+/ism'; filter/multilang/filter.php, line: 60 $search = '/(<(?:lang|span|div) lang= "[a-zA-Z0-9_-]*" .*?>.*?<\/(?:lang|span|div)>)(\s*<(?:lang|span|div) lang= "[a-zA-Z0-9_-]*" .*?>.*?<\/(?:lang|span|div)>)+/is'; filter/multilang/filter.php, line: 88 $searchtosplit = '/<(?:lang|span|div)[^>]+lang= "([a-zA-Z0-9_-]+)" [^>]*>(.*?)<\/(?:lang|span|div)>/is';
          Hide
          Vanyo Georgiav added a comment -

          This is my suggestion for a solution

          Show
          Vanyo Georgiav added a comment - This is my suggestion for a solution
          Hide
          Sebastien Michel added a comment -

          What about nested divs?

          Show
          Sebastien Michel added a comment - What about nested divs?
          Hide
          Maiquel Sampaio de Melo added a comment -

          I had problems with nested <div>'s while using both patches.

          Probably, a final solution for this problem would be about finding a tag that is a container and that is not used commonly with another nested tags of the same type.

          Another issue we need to have in account is that the tag should not be filtered by TinyMCE when using the 'Edit HTML Source' view. Additionally, I don't think that enabling the 'enabletrusttext' is not a good solution because it is an extra risk for the platform (some colleagues had discussed this option here: https://moodle.org/mod/forum/discuss.php?d=179540).

          I have successfully used the old <lang> tag without having to do any changes in the code, only editing the config.php to include the following setting:

          $CFG->filter_multilang_force_old = true;

          Although <lang> is not an HTML tag, I don't think this is an issue because the tag will not be displayed in the final HTML source code.

          Show
          Maiquel Sampaio de Melo added a comment - I had problems with nested <div>'s while using both patches. Probably, a final solution for this problem would be about finding a tag that is a container and that is not used commonly with another nested tags of the same type. Another issue we need to have in account is that the tag should not be filtered by TinyMCE when using the 'Edit HTML Source' view. Additionally, I don't think that enabling the 'enabletrusttext' is not a good solution because it is an extra risk for the platform (some colleagues had discussed this option here: https://moodle.org/mod/forum/discuss.php?d=179540 ). I have successfully used the old <lang> tag without having to do any changes in the code, only editing the config.php to include the following setting: $CFG->filter_multilang_force_old = true; Although <lang> is not an HTML tag, I don't think this is an issue because the tag will not be displayed in the final HTML source code.
          Hide
          Vanyo Georgiav added a comment - - edited

          The problem with nested <div> is a matter of organization of your html code.

          Something like sthis:

          <div class="multilang" lang="xx">
          <div>Nested 1 in langguage xx</div>
          <div>Nested 2 in langguage xx</div>
          </div>
          <div class="multilang" lang="yy">
          <div>Nested 1 in language yy</div>
          <div>Nested 2 in language yy</div>
          </div>

          does not work. But if you use:

          <div>
          <div class="multilang" lang="xx">Nested 1 in language xx</div>
          <div class="multilang" lang="yy">Nested 1 in language yy</div>
          </div>
          <div>
          <div class="multilang" lang="xx">Nested 2 in language xx</div>
          <div class="multilang" lang="yy">Nested 2 in language yy</div>
          </div>

          this will work fine.

          Show
          Vanyo Georgiav added a comment - - edited The problem with nested <div> is a matter of organization of your html code. Something like sthis: <div class="multilang" lang="xx"> <div>Nested 1 in langguage xx</div> <div>Nested 2 in langguage xx</div> </div> <div class="multilang" lang="yy"> <div>Nested 1 in language yy</div> <div>Nested 2 in language yy</div> </div> does not work. But if you use: <div> <div class="multilang" lang="xx">Nested 1 in language xx</div> <div class="multilang" lang="yy">Nested 1 in language yy</div> </div> <div> <div class="multilang" lang="xx">Nested 2 in language xx</div> <div class="multilang" lang="yy">Nested 2 in language yy</div> </div> this will work fine.
          Hide
          Amy Groshek added a comment -

          It's important that the filter work on nested divs. The original problem was caused by the inability to wrap several tags worth of content in the lang filter trigger. For example:

          <div class="multilang" lang="xx">
          <h2>Nested 1 in langguage xx</h2>
          <p>Nested 2 in langguage xx</p>
          <p>Nested 3 in langguage xx</p>
          </div>
          <div class="multilang" lang="yy">
          <h2>Nested 1 in language yy</h2>
          <p>Nested 2 in language yy</p>
          <p>Nested 3 in language yy</p>
          </div>
          

          This is the fastest (and best-organized) way to add content when you have to add content for several different languages.

          Show
          Amy Groshek added a comment - It's important that the filter work on nested divs. The original problem was caused by the inability to wrap several tags worth of content in the lang filter trigger. For example: <div class= "multilang" lang= "xx" > <h2> Nested 1 in langguage xx </h2> <p> Nested 2 in langguage xx </p> <p> Nested 3 in langguage xx </p> </div> <div class= "multilang" lang= "yy" > <h2> Nested 1 in language yy </h2> <p> Nested 2 in language yy </p> <p> Nested 3 in language yy </p> </div> This is the fastest (and best-organized) way to add content when you have to add content for several different languages.
          Hide
          Vanyo Georgiav added a comment -

          Hi, Amy,
          If you try your example with the first filter.php file uploaded here it will work.

          Show
          Vanyo Georgiav added a comment - Hi, Amy, If you try your example with the first filter.php file uploaded here it will work.
          Hide
          Amy Groshek added a comment -

          Added M23 pull branch and diff

          Show
          Amy Groshek added a comment - Added M23 pull branch and diff
          Hide
          Amy Groshek added a comment -

          Test on M23 works. Attempted to test this on M24. There appears to be a bug with language pack switching in 24 so I'm holding off on that for now.

          Show
          Amy Groshek added a comment - Test on M23 works. Attempted to test this on M24. There appears to be a bug with language pack switching in 24 so I'm holding off on that for now.
          Hide
          Amy Groshek added a comment -

          Added diff URL and branch based off of master

          Show
          Amy Groshek added a comment - Added diff URL and branch based off of master
          Hide
          Mary Evans added a comment -

          Can we get this fixed Amy?

          Show
          Mary Evans added a comment - Can we get this fixed Amy?
          Hide
          Vanyo Georgiav added a comment -

          A new version of this improvement.

          <span class="multilang" lang="XX" xml:lang="XX">

          or

          <div class="multilang" lang="XX" xml:lang="XX">

          now work too.

          Show
          Vanyo Georgiav added a comment - A new version of this improvement. <span class="multilang" lang="XX" xml:lang="XX"> or <div class="multilang" lang="XX" xml:lang="XX"> now work too.
          Hide
          hanna edelman added a comment -

          Any news?

          Show
          hanna edelman added a comment - Any news?
          Hide
          Joseph Rézeau added a comment -

          Any update?

          Show
          Joseph Rézeau added a comment - Any update?
          Hide
          Amy Groshek added a comment - - edited

          It's still waiting for peer review. If anyone wants to review it, I've just rebased everything.

          Show
          Amy Groshek added a comment - - edited It's still waiting for peer review. If anyone wants to review it, I've just rebased everything.
          Hide
          Mary Evans added a comment -

          Just about to start Peer Review. It's not my area, but will have a bash.

          Show
          Mary Evans added a comment - Just about to start Peer Review. It's not my area, but will have a bash.
          Hide
          Amy Groshek added a comment -

          w00t!!

          Show
          Amy Groshek added a comment - w00t!!
          Hide
          Mary Evans added a comment -

          It works great!

          Submitting for Integration Review

          Show
          Mary Evans added a comment - It works great! Submitting for Integration Review
          Hide
          Mary Evans added a comment -

          Be prepared to have to rebase this again as I doubt now that it will be looked at this week as this weeks integration is already underway.

          Show
          Mary Evans added a comment - Be prepared to have to rebase this again as I doubt now that it will be looked at this week as this weeks integration is already underway.
          Hide
          Amy Groshek added a comment -

          Yay! Thanks to Mary Evans!

          Show
          Amy Groshek added a comment - Yay! Thanks to Mary Evans !
          Hide
          Eloy Lafuente (stronk7) added a comment -

          The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

          TIA and ciao

          Show
          Eloy Lafuente (stronk7) added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
          Hide
          Amy Groshek added a comment -

          Rebased.

          Show
          Amy Groshek added a comment - Rebased.
          Hide
          Sam Hemelryk added a comment -

          Hi guys,

          Sending this back sorry.
          If you try testing with the following you'll see the issue:

          <div lang="en" class="multilang">Check that you can see a 3 numbers: 1 <span>2</span> 3</div> <div lang="ar" class="multilang">Check that you can see a 3 numbers: 1 <span>2</span> 3</div>
          

          The problem is that the regex is now matching a div at the start and a span at the end.
          Using a back reference is probably the solution http://www.php.net/manual/en/regexp.reference.back-references.php

          I've also pm'd Petr just to check he has no objections to this.

          Cheers
          Sam

          Show
          Sam Hemelryk added a comment - Hi guys, Sending this back sorry. If you try testing with the following you'll see the issue: <div lang= "en" class= "multilang" >Check that you can see a 3 numbers: 1 <span>2</span> 3</div> <div lang= "ar" class= "multilang" >Check that you can see a 3 numbers: 1 <span>2</span> 3</div> The problem is that the regex is now matching a div at the start and a span at the end. Using a back reference is probably the solution http://www.php.net/manual/en/regexp.reference.back-references.php I've also pm'd Petr just to check he has no objections to this. Cheers Sam
          Hide
          CiBoT added a comment -

          Moving this reopened issue out from current integration. Please, re-submit it for integration once ready.

          Show
          CiBoT added a comment - Moving this reopened issue out from current integration. Please, re-submit it for integration once ready.
          Hide
          Vanyo Georgiav added a comment - - edited

          The problem pointed by Sam Hemelryk is solved in this file:

          https://tracker.moodle.org/secure/attachment/32076/filter.php

          (The first file attached here)

          Show
          Vanyo Georgiav added a comment - - edited The problem pointed by Sam Hemelryk is solved in this file: https://tracker.moodle.org/secure/attachment/32076/filter.php (The first file attached here)
          Hide
          Amy Groshek added a comment -

          Vanyo, is there any way you can make the changes in github and send me pull requests. Branches above.

          Show
          Amy Groshek added a comment - Vanyo, is there any way you can make the changes in github and send me pull requests. Branches above.
          Show
          Vanyo Georgiav added a comment - https://github.com/vanyog/moodle/commit/36c2c5af4cf754f4457d9ab9041ce637fe5162aa
          Show
          Amy Groshek added a comment - Vanyo Georgiav It's not going to pass code review as it is. http://docs.moodle.org/dev/Coding_style#Maximum_Line_Length Also see: http://docs.moodle.org/dev/Git_for_developers#Preparing_a_patch
          Show
          Vanyo Georgiav added a comment - Is this ok? https://github.com/vanyog/moodle/commit/03112d5bd98798ae42aac8a0320a158ae135909b
          Hide
          Amy Groshek added a comment -

          Requesting peer review once again. I've tested Vanyo's revision and it works ok with the code sample provided by Sam.

          Show
          Amy Groshek added a comment - Requesting peer review once again. I've tested Vanyo's revision and it works ok with the code sample provided by Sam.
          Hide
          Mary Evans added a comment - - edited

          @Amy: I know this is a bit trivial, but at line 44 in multilang/filter.php in the opening comments you have multiland (twice) instead of multilang see below:

          //   <div class="multiland" lang="XX">one language</div><div class="multiland" lang="YY">another language</div> 
          
          
          Show
          Mary Evans added a comment - - edited @Amy: I know this is a bit trivial, but at line 44 in multilang/filter.php in the opening comments you have multiland (twice) instead of multilang see below: // <div class= "multiland" lang= "XX" >one language</div><div class= "multiland" lang= "YY" >another language</div>
          Hide
          Mary Evans added a comment -

          In the mean time I'll try and review it and then submit for integration to ensure it gets in before tomorrows deadline.

          Show
          Mary Evans added a comment - In the mean time I'll try and review it and then submit for integration to ensure it gets in before tomorrows deadline.
          Hide
          Mary Evans added a comment -

          Looks and works OK.
          Submitting for integration.

          Show
          Mary Evans added a comment - Looks and works OK. Submitting for integration.
          Hide
          Mary Evans added a comment -

          @Amy you will need to rebase these branches as Moodle was updated yesterday

          Show
          Mary Evans added a comment - @Amy you will need to rebase these branches as Moodle was updated yesterday
          Hide
          Amy Groshek added a comment -

          Mary Evans Thanks for the review. Typos corrected and branches rebased.

          Show
          Amy Groshek added a comment - Mary Evans Thanks for the review. Typos corrected and branches rebased.
          Hide
          Mary Evans added a comment -

          It's looking good.

          Show
          Mary Evans added a comment - It's looking good.
          Hide
          Damyon Wiese added a comment -

          The new regex adds in support for xml:lang="XX" - I don't know enough about the use of multilang to know why you want this to work - but it seems odd to me to add support just for that tag even though it is not used and must appear at the end of the attributes list.

          I would prefer to see

          <div or span (any attribute) class="multilang" (any attribute)>content</matching div or span>
          

          with the lang appearing before or after the class.

          Show
          Damyon Wiese added a comment - The new regex adds in support for xml:lang="XX" - I don't know enough about the use of multilang to know why you want this to work - but it seems odd to me to add support just for that tag even though it is not used and must appear at the end of the attributes list. I would prefer to see <div or span (any attribute) class= "multilang" (any attribute)>content</matching div or span> with the lang appearing before or after the class.
          Hide
          Damyon Wiese added a comment -

          Alternatively - just stick to the single issue that this bug describes and address the xml:lang requirement in a new issue.

          (Note - I am just trying to make sure we dont end up with an oddly behaving filter that people don't understand).

          Show
          Damyon Wiese added a comment - Alternatively - just stick to the single issue that this bug describes and address the xml:lang requirement in a new issue. (Note - I am just trying to make sure we dont end up with an oddly behaving filter that people don't understand).
          Hide
          Aparup Banerjee added a comment -

          stopping - Damyon was on this one already.

          Show
          Aparup Banerjee added a comment - stopping - Damyon was on this one already.
          Hide
          Vanyo Georgiav added a comment -

          I found xml:lang="XX" attribute in <span> tags in some forum posts on my site and that is why I decided to check for them. I tried to remove it, but I do no know why, it was added again after I was saving the post. Without this check multilang filter does not work in this case.

          Show
          Vanyo Georgiav added a comment - I found xml:lang="XX" attribute in <span> tags in some forum posts on my site and that is why I decided to check for them. I tried to remove it, but I do no know why, it was added again after I was saving the post. Without this check multilang filter does not work in this case.
          Hide
          Aparup Banerjee added a comment -

          this is unlikely to go into STABLE branches as its an improvement. might need to open a backport request if needed.

          Show
          Aparup Banerjee added a comment - this is unlikely to go into STABLE branches as its an improvement. might need to open a backport request if needed.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          uhm... ... more coming soon.

          Show
          Eloy Lafuente (stronk7) added a comment - uhm... ... more coming soon.
          Hide
          Eloy Lafuente (stronk7) added a comment - - edited

          I'm sorry, but I think we cannot continue changing and changing and changing (or increasing) the combinations this filter handles (slower and riskier).

          In fact, since years ago there are continuous comments about to switch it to any other alternative, because using open and close standard html tags that way won't be ever perfect.

          The 2 alternatives (exclusive or complementing) are:

          1) use non html tags. The old, glorious <lang> tag was far better (and deterministic) that current <span>...
          2) use full tags instead of open/close pairs, so sections would be something like <span class="multilang en start" />....<span class="multilang en end" />.

          Any of them are way better that current approach. And should be seriously considered, but not for 2.5, I'm afraid.

          Also, surely it should be implemented as a new filter "multilang2", while keeping the old one available for BC, plus some conversion utility (risky indeed). And verify editors/cleaners support for them (edited).

          So, I'm sorry but I'm reopening this (and surely should be considered as won't fix). Feel free to continue discussing it... but adding more html tags to the filter is not the way at all.

          Ciao

          Show
          Eloy Lafuente (stronk7) added a comment - - edited I'm sorry, but I think we cannot continue changing and changing and changing (or increasing) the combinations this filter handles (slower and riskier). In fact, since years ago there are continuous comments about to switch it to any other alternative, because using open and close standard html tags that way won't be ever perfect. The 2 alternatives (exclusive or complementing) are: 1) use non html tags. The old, glorious <lang> tag was far better (and deterministic) that current <span>... 2) use full tags instead of open/close pairs, so sections would be something like <span class="multilang en start" />....<span class="multilang en end" />. Any of them are way better that current approach. And should be seriously considered, but not for 2.5, I'm afraid. Also, surely it should be implemented as a new filter "multilang2", while keeping the old one available for BC, plus some conversion utility (risky indeed). And verify editors/cleaners support for them (edited). So, I'm sorry but I'm reopening this (and surely should be considered as won't fix). Feel free to continue discussing it... but adding more html tags to the filter is not the way at all. Ciao
          Hide
          José Miguel Andonegi Martínez added a comment -

          IMHO, a new approach should be better for multilang environment:

          Option A) Full field multilang treatment, not html pieces. May use CDATA to enclose each language?

          Option B) much better: Database level support of html fields. A table supporting the translated HTML text.

          Show
          José Miguel Andonegi Martínez added a comment - IMHO, a new approach should be better for multilang environment: Option A) Full field multilang treatment, not html pieces. May use CDATA to enclose each language? Option B) much better: Database level support of html fields. A table supporting the translated HTML text.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          I agree there are alternatives, just let's ignite a new issue / discussion / docs about them and try to get it fixed for 2.6 (once the "best" way is decided, in term of usability/speed/safety/support...).

          Show
          Eloy Lafuente (stronk7) added a comment - I agree there are alternatives, just let's ignite a new issue / discussion / docs about them and try to get it fixed for 2.6 (once the "best" way is decided, in term of usability/speed/safety/support...).
          Hide
          CiBoT added a comment -

          Moving this reopened issue out from current integration. Please, re-submit it for integration once ready.

          Show
          CiBoT added a comment - Moving this reopened issue out from current integration. Please, re-submit it for integration once ready.
          Hide
          Amy Groshek added a comment -

          We've been trying to get this into any branch for over a year now. Would have been nice to know that "this is not the right solution" at some prior point. I'm unassigning myself. Good luck to whoever is up for the disappointment of the next round.

          Fortunately, I had my clients that needed this solution a year ago use a CSS hack instead. I guess that's what I'll have to resort to until some future time when the correct solution is agreed upon and arrived at. Just pack more and more hacks into the theme when issues can't be addressed in core.

          Show
          Amy Groshek added a comment - We've been trying to get this into any branch for over a year now. Would have been nice to know that "this is not the right solution" at some prior point. I'm unassigning myself. Good luck to whoever is up for the disappointment of the next round. Fortunately, I had my clients that needed this solution a year ago use a CSS hack instead. I guess that's what I'll have to resort to until some future time when the correct solution is agreed upon and arrived at. Just pack more and more hacks into the theme when issues can't be addressed in core.
          Hide
          Eloy Lafuente (stronk7) added a comment - - edited

          Hi Amy, I understand and I'm afraid of your frustration with this, sincerely.

          But it's impossible to allow it to land, not only because it's not the "right solution" (in my hyper charged mind), but because it may cause regressions to people already nesting <span> and <div>, block and inline dispositions, because of performance, because the filter is already hyper-loaded/heavy, because there are already a lot of of multilang issues that only would become worse if we add the div support...

          Really hope this helps us to get it fixed in a near future... and again apologies if you need them.

          Ciao

          Edited: And many thanks for your effort here and in other areas, I forgot that!

          Show
          Eloy Lafuente (stronk7) added a comment - - edited Hi Amy, I understand and I'm afraid of your frustration with this, sincerely. But it's impossible to allow it to land, not only because it's not the "right solution" (in my hyper charged mind), but because it may cause regressions to people already nesting <span> and <div>, block and inline dispositions, because of performance, because the filter is already hyper-loaded/heavy, because there are already a lot of of multilang issues that only would become worse if we add the div support... Really hope this helps us to get it fixed in a near future... and again apologies if you need them. Ciao Edited: And many thanks for your effort here and in other areas, I forgot that!
          Hide
          Mary Evans added a comment - - edited

          I have a lot of respect for you Eloy, perhaps more than you appreciate, and it's a pity you can't been integrator all the time, because you appear to have more knowledge about Moodle, which is good and praiseworthy. However, this is just so disheartening to see this being rejected after so much has go into it. Why is there no one to tell us, any of us, where we are going wrong until it's too late?

          This is the second time I have seen this happen today...and it breaks my heart!

          Show
          Mary Evans added a comment - - edited I have a lot of respect for you Eloy, perhaps more than you appreciate, and it's a pity you can't been integrator all the time, because you appear to have more knowledge about Moodle, which is good and praiseworthy. However, this is just so disheartening to see this being rejected after so much has go into it. Why is there no one to tell us, any of us, where we are going wrong until it's too late? This is the second time I have seen this happen today...and it breaks my heart!
          Hide
          Eloy Lafuente (stronk7) added a comment - - edited

          Hi Mary,

          first of all, let me express my feelings (about you) reciprocity (you rock!).

          I'm really afraid about things like this happening and I'm not happy when something has to be rejected "radically" (without an alternative solution). Especially when it has involved effort and work from many people.

          Note that all we have had "frustrations" like this in the past, when you go for a solution that, apparently, is good enough, so you invest lots of time & love with it, just to be rejected at the end. I has happened to me, both with Moodle and in my life in general. So no, you're not alone, I can understand your feelings.

          But sometimes, it happens, and we cannot do anything but try to minimize the number of situations like this along the time (knowing that they will continue happening).

          By default we (HQ) cannot be on top of all issues, especially if they evolve and evolve without our participation (along a whole year in this case). And the "final filters", aka peer review and integration are, surely, "too late".

          So what can we do? Well, there are channels (forum discussions, chat, ping/re-ping/rere-ping, skype, mail, tracker watchers...). We (the development community) aren't thousands, so I'm sure we can communicate a bit better. Personally I get development questions/requests daily and, when possible, I try to take a look to them (although I'm sure I don't reply to everything I'm asked, it's simply impossible for me).

          So surely the best way to try to get more people involved is to share the issue in places with broader audience, like forums and development chat. And, of course, from our side (HQ / core devs / ...) we should try to pay more attention to those requests and be more participative indeed.

          I'm sure that just improving a bit those communications the number of frustrations will go down noticeably although, being honest, I'm also sure that they won't ever be reduced to 0. It's life.

          With love, Eloy, ciao

          Show
          Eloy Lafuente (stronk7) added a comment - - edited Hi Mary, first of all, let me express my feelings (about you) reciprocity (you rock!). I'm really afraid about things like this happening and I'm not happy when something has to be rejected "radically" (without an alternative solution). Especially when it has involved effort and work from many people. Note that all we have had "frustrations" like this in the past, when you go for a solution that, apparently, is good enough, so you invest lots of time & love with it, just to be rejected at the end. I has happened to me, both with Moodle and in my life in general. So no, you're not alone, I can understand your feelings. But sometimes, it happens, and we cannot do anything but try to minimize the number of situations like this along the time (knowing that they will continue happening). By default we (HQ) cannot be on top of all issues, especially if they evolve and evolve without our participation (along a whole year in this case). And the "final filters", aka peer review and integration are, surely, "too late". So what can we do? Well, there are channels (forum discussions, chat, ping/re-ping/rere-ping, skype, mail, tracker watchers...). We (the development community) aren't thousands, so I'm sure we can communicate a bit better. Personally I get development questions/requests daily and, when possible, I try to take a look to them (although I'm sure I don't reply to everything I'm asked, it's simply impossible for me). So surely the best way to try to get more people involved is to share the issue in places with broader audience, like forums and development chat. And, of course, from our side (HQ / core devs / ...) we should try to pay more attention to those requests and be more participative indeed. I'm sure that just improving a bit those communications the number of frustrations will go down noticeably although, being honest, I'm also sure that they won't ever be reduced to 0. It's life. With love, Eloy, ciao
          Hide
          Vanyo Georgiav added a comment - - edited

          My new suggestion for a solution of multilanguage problem is this:

          https://github.com/vanyog/moodle/tree/master/filter/multilang

          Please, comment in this forum discussion:

          https://moodle.org/mod/forum/discuss.php?d=226145#p981992

          Show
          Vanyo Georgiav added a comment - - edited My new suggestion for a solution of multilanguage problem is this: https://github.com/vanyog/moodle/tree/master/filter/multilang Please, comment in this forum discussion: https://moodle.org/mod/forum/discuss.php?d=226145#p981992
          Hide
          Mary Evans added a comment - - edited

          Hi Vanyo,
          I have just assigned MDL-32257 to myself temporarily, mainly to keep this moving.

          If possible can you supply some testing instructions so that we can test this for all cases that the patch covers?

          I can then ask Eloy to Peer Review, or at best get some feedback to see if this is a viable option in light of his last comments?

          Many thanks

          Show
          Mary Evans added a comment - - edited Hi Vanyo, I have just assigned MDL-32257 to myself temporarily, mainly to keep this moving. If possible can you supply some testing instructions so that we can test this for all cases that the patch covers? I can then ask Eloy to Peer Review, or at best get some feedback to see if this is a viable option in light of his last comments? Many thanks
          Hide
          Mary Evans added a comment -

          @Eloy: If you have a minute to spare can you please give some feedback with this latest patch? Thanks

          Show
          Mary Evans added a comment - @Eloy: If you have a minute to spare can you please give some feedback with this latest patch? Thanks
          Hide
          Nadav Kavalerchik added a comment -
          Show
          Nadav Kavalerchik added a comment - +1 to Mary's comment
          Hide
          Petr Škoda added a comment -

          Hello,

          1/ There are other places that deal with multilang syntax such as PARAM_TEXT cleaning in lib/moodlelib.php.
          2/ Changes like this need extensive phpunit test coverage.
          3/ Somebody should measure regex performance.
          4/ It seems that it might be eating whitespace after the multilang block, is it?
          5/ I suppose some of those new comments should go to the git commit message instead.
          6/ It is not going to work if you want to enclose text with both spans and divs, right?

          Anyway I would vote for implementation of a new multilang filter syntax instead of half fixing the current problematic span/div design. I suppose it might be easier to implement non-html markup such as:

           {multilang en}English{multilang}{multilang de}Deutsch{multilang}
          
          Show
          Petr Škoda added a comment - Hello, 1/ There are other places that deal with multilang syntax such as PARAM_TEXT cleaning in lib/moodlelib.php. 2/ Changes like this need extensive phpunit test coverage. 3/ Somebody should measure regex performance. 4/ It seems that it might be eating whitespace after the multilang block, is it? 5/ I suppose some of those new comments should go to the git commit message instead. 6/ It is not going to work if you want to enclose text with both spans and divs, right? Anyway I would vote for implementation of a new multilang filter syntax instead of half fixing the current problematic span/div design. I suppose it might be easier to implement non-html markup such as: {multilang en}English{multilang}{multilang de}Deutsch{multilang}
          Hide
          Mary Evans added a comment -

          That would be good. And how do you go about doing this...furthermore...why has it not been done already!

          Show
          Mary Evans added a comment - That would be good. And how do you go about doing this...furthermore...why has it not been done already!
          Hide
          Petr Škoda added a comment -

          I guess nobody worked on alternative multilang syntax because Martin did not approve it, using span/div is a dead end.

          Show
          Petr Škoda added a comment - I guess nobody worked on alternative multilang syntax because Martin did not approve it, using span/div is a dead end.
          Hide
          Mary Evans added a comment -

          Without being disrespectful Martin makes some odd decisions sometimes.

          Show
          Mary Evans added a comment - Without being disrespectful Martin makes some odd decisions sometimes.
          Hide
          Nadav Kavalerchik added a comment -

          The entire non-English community is looking for a resolution

          Show
          Nadav Kavalerchik added a comment - The entire non-English community is looking for a resolution
          Hide
          Mary Evans added a comment -

          As I am not sure what is happening with this issue, I have unassigned myself from it. However, if anyone is willing to propose an alternative solution for this 'bug', then you are welcome to assign it to yourself.

          Show
          Mary Evans added a comment - As I am not sure what is happening with this issue, I have unassigned myself from it. However, if anyone is willing to propose an alternative solution for this 'bug', then you are welcome to assign it to yourself.
          Hide
          Marcus Hoberg added a comment -

          Is there any progress on this topic? We are in the course of migrating from 1.9 to 2.5 and experienced that the <span> tag is migrated correct, but kicked out of the tinyMCE when editing multi-lang text fields. The <div> tag work around is OK, but would mean that we have to adopt all existing multi-lang entries. This is not feasable. Any ideas?

          Show
          Marcus Hoberg added a comment - Is there any progress on this topic? We are in the course of migrating from 1.9 to 2.5 and experienced that the <span> tag is migrated correct, but kicked out of the tinyMCE when editing multi-lang text fields. The <div> tag work around is OK, but would mean that we have to adopt all existing multi-lang entries. This is not feasable. Any ideas?
          Hide
          Amy Groshek added a comment -

          Hi Marcus Hoberg, there hasn't been any progress. I like Petr's suggestion above for a new filter syntax, but no one has worked on it that I know.

          Show
          Amy Groshek added a comment - Hi Marcus Hoberg , there hasn't been any progress. I like Petr's suggestion above for a new filter syntax, but no one has worked on it that I know.
          Hide
          Vanyo Georgiav added a comment - - edited

          I tried to implement a non-html markup such as:

          {multilang en}English{multilang}{multilang de}Deutsch{multilang}

          But I faced a problem with possible white space. If there is no white space between {} elements it is OK, but if someone writes something like:
          {multilang en}

          English

          {multilang} {multilang de}Deutsch{multilang}

          just for readability the html code of this in the simplest cases is:

          <p>

          {multilang en}English{multilang}</p>
          <p>{multilang de}Deutsch{multilang}</p>

          or

          <p>{multilang en}

          English

          {multilang}<br />{multilang de}Deutsch{multilang}

          </p>

          It is difficult to identify the multilanguage block in one case with <br /> and in other case with </p>\n<p> or some other html tags between {} elements. The implementation becomes fare more complex than the present one.

          Sorry for bad formatting of this comment! I don't know why all these line breaks are added...

          Show
          Vanyo Georgiav added a comment - - edited I tried to implement a non-html markup such as: {multilang en}English{multilang}{multilang de}Deutsch{multilang} But I faced a problem with possible white space. If there is no white space between {} elements it is OK, but if someone writes something like: {multilang en} English {multilang} {multilang de}Deutsch{multilang} just for readability the html code of this in the simplest cases is: <p> {multilang en}English{multilang}</p> <p>{multilang de}Deutsch{multilang}</p> or <p>{multilang en} English {multilang}<br />{multilang de}Deutsch{multilang} </p> It is difficult to identify the multilanguage block in one case with <br /> and in other case with </p>\n<p> or some other html tags between {} elements. The implementation becomes fare more complex than the present one. Sorry for bad formatting of this comment! I don't know why all these line breaks are added...
          Show
          Vanyo Georgiav added a comment - An alternative: https://moodle.org/plugins/view.php?plugin=filter_multilangsecond

            Dates

            • Created:
              Updated: