Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-55197

multilang filter ignores parent language if that is 'en'

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      This is covered by a new unit test, but to test manually:

      1. Ensure that the language packs en, en_us and de are installed on the site.
      2. Create a page resource in a course and enter the text

        <span lang="de" class="multilang">your_content_in_German</span>
        <span lang="en" class="multilang">your_content_in English</span>
        

        (disabling the HTML editor)

      3. Save the page resource and then try viewing it with en_us selected as preferred user language.
      4. Verify that 'your_content_in English' is displayed.

      Previously 'your_content_in_German' would have been displayed.

      Show
      This is covered by a new unit test, but to test manually: Ensure that the language packs en, en_us and de are installed on the site. Create a page resource in a course and enter the text < span lang = "de" class = "multilang" >your_content_in_German</ span > < span lang = "en" class = "multilang" >your_content_in English</ span > (disabling the HTML editor) Save the page resource and then try viewing it with en_us selected as preferred user language. Verify that 'your_content_in English' is displayed. Previously 'your_content_in_German' would have been displayed.
    • Workaround:
      Hide

      If your site uses a child language pack, then the first span tag must be the parent language. Otherwise, when a user using the child language views the text, it will not be in the correct language for them. For example, if your site uses en_us then the en span tag (as parent language) must be first i.e.

      <span lang="en" class="multilang">your_content_in English</span>
            <span lang="de" class="multilang">your_content_in_German</span>
      

      Note that this workaround only works if your site uses only one child language pack.

      Show
      If your site uses a child language pack, then the first span tag must be the parent language. Otherwise, when a user using the child language views the text, it will not be in the correct language for them. For example, if your site uses en_us then the en span tag (as parent language) must be first i.e. < span lang = "en" class = "multilang" >your_content_in English</ span > < span lang = "de" class = "multilang" >your_content_in_German</ span > Note that this workaround only works if your site uses only one child language pack.
    • Affected Branches:
      MOODLE_29_STABLE, MOODLE_30_STABLE, MOODLE_31_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE
    • Fixed Branches:
      MOODLE_36_STABLE, MOODLE_37_STABLE
    • Pull 3.5 Branch:
    • Pull 3.6 Branch:
    • Pull Master Branch:

      Description

      Steps to reproduce:

      1. Ensure that the language packs en, en_us and de are installed on the site.
      2. Create a page resource in a course and enter the text

        <span lang="de" class="multilang">your_content_in_German</span>
         <span lang="en" class="multilang">your_content_in English</span>
        

        (disabling the HTMl editor)

      3. Save the page resource and then try viewing it with en_us selected as preferred user language.

      Expected result: 'your_content_in English' is displayed.

      Actual result: 'your_content_in_German' is displayed.


      see https://moodle.org/mod/forum/discuss.php?d=336204

      The problem: if a field has span block for several languages but not for en_us, the multilang filter picks the first span block from the field, ignoring the fact that en_us has en set as its parent language.

      To quote David: The English (en) is implicit parent of all language packs in Moodle (so if a string is not translated, the English original is used). In most places in the code, if the parent language is reported to be English (en), it is actually interpreted as if there was no parent language. And I believe this is what is happening here.

      Comment: The issue is built-in so to speak for en_us but I think it will also appear when, for example, I use a locally defined language de_de which has de as the parent.

      Workaround: set the first span bloc for en (in case of en_us) or whatever the parent language is. Easy to do but requires documentation. Problematic if I have more than one language with different parents is used (like using en_us and de_de on my site).

      Solution: The code should distinguish when a given language has parent language set explicitly from when the en is used when no other language is available.

      Note: this problem does not exist in Moodle 1.9 (not that this really helps)

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  8/Jul/19

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 2 hours, 20 minutes
                  2h 20m