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

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


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


      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

        Gliffy Diagrams


            Issue Links



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


                  • Created:
                    Fix Release Date: