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

Use the same list of places to search in get_string and help.php (patch attached)

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.8
    • Fix Version/s: 1.8, 1.9
    • Component/s: Language
    • Labels:
      None
    • Affected Branches:
      MOODLE_18_STABLE
    • Fixed Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE

      Description

      Apologies for adding another 1.8 bug, but ...

      Yesterday, you extended the list of places that get_string searches, to include more plugin types. Then I added qtype_ plugins myself.

      Then I realised that help.php needs to do a similar search, and that was not updated.

      That made me do a little rewrite, the result is the attached patch. There is now one place where the list of things to search is defined:

      /**

      • @return array places to look for lang strings based on the prefix to the
      • module name. For example qtype_ in question/type. Used by get_string and
      • help.php.
        */
        function places_to_search_for_lang_strings() {
        return array(
        '__exceptions' => array('moodle', 'langconfig'),
        'block_' => array('blocks'),
        'report_' => array($CFG->admin.'/report', 'course/report', 'mod/quiz/report'),
        'resource_' => array('mod/resource/type'),
        'assignment_' => array('mod/assignment/type'),
        'enrol_' => array('enrol'),
        'auth_' => array('auth'),
        'format_' => array('course/format'),
        'qtype_' => array('question/type'),
        '' => array('mod')
        );
        }

      and get_string and help.php both use this.

      However, this is a slightly riskly change, so I did not want to just check it in. Could you review it and decide if you want it. Thanks.

      THE PATCH CHANGES ONE THING: in the past, if you did get_string('whatever', 'module_with_underscores'), it would look in /mod/module_with_underscores/lang/.... After this patch, it won't. I think we don't use or want underscores in module names, so this change is actually a good thing. But of you want identical behavior to before, then I can change it back.

      I have not made any attempt to measure performance of the change. Guessing, I see no reason why is should be slower, and it might even be faster.

      If you don't want this patch, we need to fix help.php manually.

        Attachments

          Activity

            People

            Assignee:
            timhunt Tim Hunt
            Reporter:
            timhunt Tim Hunt
            Tester:
            Nobody
            Participants:
            Component watchers:
            David Mudrák (@mudrd8mz), Helen Foster, Víctor Déniz Falcón
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              31/Mar/07