Moodle
  1. Moodle
  2. MDL-19546

get_string('modulenameplural', 'user') does not exist in lang files.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Won't Fix
    • Affects Version/s: 1.9.5
    • Fix Version/s: None
    • Component/s: Global search
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE
    • Rank:
      5358

      Description

      For example, get_string('modulenameplural', 'wiki') exists in lang/en_utf8/wiki.php as $string['modulenameplural'] = 'Wikis';

      But, module name 'user' which means user-profile and blog does not have lang file.

      ---------------------(original sourse)-from here
      (1) search/query.php
      foreach($module_types as $mod) {
      if ($mod == $adv->module) {
      if ($mod != 'all')

      { print "<option value='$mod' selected=\"selected\">".get_string('modulenameplural', $mod)."</option>\n"; }

      else

      { print "<option value='$mod' selected=\"selected\">".get_string('all', 'search')."</option>\n"; }

      }
      else {
      if ($mod != 'all')

      { print "<option value='$mod'>".get_string('modulenameplural', $mod)."</option>\n"; }

      else

      { print "<option value='$mod'>".get_string('all', 'search')."</option>\n"; }

      }
      }
      -------
      (2) search/stats.php

      $table->data[] = array($documentsindatabasestr, $indexinfo->dbcount);

      foreach($indexinfo->types as $key => $value)

      { $table->data[] = array(get_string('documentsfor', 'search') . " '".get_string('modulenameplural', $key)."'", $value); }


      ---------------------(original sourse)-to here

      There are several solutions.

      (1) add user.php in lang folder (for global search only...).
      (2) make an exception the module names which does not exist in lang folder.
      (3) make an exception the module names which does not exist in lang folder and change module name 'user' to 'user' and 'blog'.

      My suggestion is that newly adding a function to get 'modulenameplural'.

      for example, add to search/lib.php

      function get_modulenameplural($modname)
      {
      if (($ret = get_string('modulenameplural', $modname)) != '[[modulenameplural]]') return $ret;
      return get_string("modulenameplural_$modname", 'search');
      }

      and replace get_string('modulenameplural', $mod) to get_modulenameplural($mod) in search/query.php and search/stats.php.

        Activity

        Hide
        Tatsuya Shirai added a comment -

        And you need to add following strings in lang/search.php

        $string['modulenameplural_user'] = 'Users';

        -----------

        On statistics view by search/stat.php,
        User does not apear.

        The cause of this problem is maybe based on this codes,

        //individual document types
        // $types = search_get_document_types();
        $types = search_collect_searchables(true, false);

        in search/indexlibphp, function __construct.

        Why does not use search_get_document_types()?

        Show
        Tatsuya Shirai added a comment - And you need to add following strings in lang/search.php $string ['modulenameplural_user'] = 'Users'; ----------- On statistics view by search/stat.php, User does not apear. The cause of this problem is maybe based on this codes, //individual document types // $types = search_get_document_types(); $types = search_collect_searchables(true, false); in search/indexlibphp, function __construct. Why does not use search_get_document_types()?
        Hide
        Charles Fulton added a comment -

        I just ran into this in 2.0.1+ while looking at MDL-26247. I think it's overkill to add a new function just to handle users (blogs has its own lang file now). I've written a patch which adds an exception for 'user' along with 'all' (since they're both unique cases). I also refactored the code to use a switch and be a little more readable. Patch here: https://github.com/mackensen/moodle/commit/09bad05b0218154be5fc7eeb18f28a0630f31142.

        Show
        Charles Fulton added a comment - I just ran into this in 2.0.1+ while looking at MDL-26247 . I think it's overkill to add a new function just to handle users (blogs has its own lang file now). I've written a patch which adds an exception for 'user' along with 'all' (since they're both unique cases). I also refactored the code to use a switch and be a little more readable. Patch here: https://github.com/mackensen/moodle/commit/09bad05b0218154be5fc7eeb18f28a0630f31142 .
        Hide
        Dan Poltawski added a comment -

        Hi,

        We removed Global Search from Moodle 2.2 onwards because it was not working reliably. I'm closing this issue as it reffers to that removed search.

        Please follow MDL-31989 for a new global search for Moodle 2.4.

        Show
        Dan Poltawski added a comment - Hi, We removed Global Search from Moodle 2.2 onwards because it was not working reliably. I'm closing this issue as it reffers to that removed search. Please follow MDL-31989 for a new global search for Moodle 2.4.

          People

          • Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: