Moodle
  1. Moodle
  2. MDL-17763

get_string: parent language not getting checked for blocks and similar additional locations in particular cases

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9.3
    • Fix Version/s: 2.0
    • Component/s: Libraries
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE
    • Rank:
      31620

      Description

      The current program logic for getting parent language strings is:

      1) check location for existence of parent language
      2) check parent language for string in that parent language location

      The problem is that if the site has a parent language defined one would expect that parent language to be checked for the block; however, if the block does not have the parent language defined there is no langconfig.php for that location and a parent language for that location never gets checked. To re-create the issue with a fresh install:

      1) Install the de_utf8 language pack
      2) Install the de_du_utf8 language pack
      3) Install a 3rd party block (for this example mrbs which has a lang folder for de_utf8 but not de_du_utf8)
      4) Set your language to de_utf8
      5) You should notice that all the regular blocks get translated to German; however, the mrbs block does not and is shown in English because the one location that defines the parent language /lang/de_du_utf8/langconfig.php then looks in that location for the string /lang/de_utf8/block_mrbs.php but the file is not there. Instead it is in /blocks/mrbs/lang/de_utf8/block_mrbs.php. But when the location /blocks/mrbs/lang/de_du_utf8 is checked there is no folder and thus no langconfig.php and thus no parent language is detected. However, I would still want and I think most users would expect that /blocks/mrbs/lang/de_utf8/block_mrbs.php would be checked.

      I wonder if having a separate function for parent_lang would help defined along the lines of:

      parent_lang($lang, $locations)
      $lang is the current language (say de_du_utf8)
      $locations are the various locations defined by get_string
      if there is a parent language defined it will return it as a string (i.e. de_utf8)
      if not it will return false

      That way we can simply check
      if ($parentlanguage=parent_lang($lang, $locations)) {
      then if the $location/$module file does not exist ($CFG->dirroot/blocks/mrbs/lang/de_du_utf8/block_mrbs.php)
      and there is a $parentlanguage defined we can check for $CFG->dirroot/blocks/mrbs/lang/de_utf8/block_mrbs.php

      One problem is that if different langconfig.php files point to different parent languages. I cannot think of a case when this would practically happen but theoretically that could confuse things but for the sake of this issue I think it can be presumed that each child language has one and only one parent language.

      CONTRIB-957 has more information about what brought about this issue. Let me know if there are any questions. I will try to work on a patch.

      Peace - Anthony

      1. MDL-17763.diff
        4 kB
        Anthony Borrow
      2. MDL-17763 block lang fix.diff
        3 kB
        Alastair Munro

        Issue Links

          Activity

          Anthony Borrow created issue -
          Anthony Borrow made changes -
          Field Original Value New Value
          Link This issue will help resolve CONTRIB-957 [ CONTRIB-957 ]
          Anthony Borrow made changes -
          Attachment MDL-17763.diff [ 15983 ]
          Anthony Borrow made changes -
          Link This issue is duplicated by CONTRIB-1127 [ CONTRIB-1127 ]
          Tim Hunt made changes -
          Fix Version/s 2.0 [ 10122 ]
          Assignee moodle.com [ moodle.com ] Tim Hunt [ timhunt ]
          Anthony Borrow made changes -
          Link This issue has been marked as being related by MDL-18669 [ MDL-18669 ]
          Tim Hunt made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Tim Hunt made changes -
          Assignee Tim Hunt [ timhunt ] David Mudrak [ mudrd8mz ]
          Martin Dougiamas made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Martin Dougiamas made changes -
          Workflow jira [ 30068 ] MDL Workflow [ 61692 ]
          Martin Dougiamas made changes -
          Workflow MDL Workflow [ 61692 ] MDL Full Workflow [ 90887 ]
          Alastair Munro made changes -
          Attachment MDL-17763 block lang fix.diff [ 25683 ]

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: