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

multilang filter ignores explicitly set parent language

    XMLWordPrintable

    Details

    • 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

      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

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              robek Robert Brenstein
              Participants:
              Component watchers:
              Jake Dallimore, Jun Pataleta, cameron1729, Helen Foster, Amaia Anabitarte, David Mudrák (@mudrd8mz), Sara Arjona (@sarjona)
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: