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

Ability to provide alternate strings manager

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Regression test: Make sure that strings are normally displayed if you do not touch the config.php
      2. Edit config.php and add $CFG->customstringmanager = 'xxx'; where xxx is some non-existing class. Make sure that an appropriate debugging message is displayed and strings continue to work.
      3. Edit config.php and set $CFG->customstringmanager to a name of existing class that can be auto-loaded (such as core_collator, moodle_url or so). Make sure that an appropriate debugging message is displayed and strings continue to work.
      4. Install a plugin that implements custom string manager. You can use https://github.com/mudrd8mz/moodle-local_stringman or implement own solution. Set the relevant value in config.php (see README if you use my dummy implementation) and make sure the custom string manager is actually used.
      Show
      Regression test: Make sure that strings are normally displayed if you do not touch the config.php Edit config.php and add $CFG->customstringmanager = 'xxx'; where xxx is some non-existing class. Make sure that an appropriate debugging message is displayed and strings continue to work. Edit config.php and set $CFG->customstringmanager to a name of existing class that can be auto-loaded (such as core_collator, moodle_url or so). Make sure that an appropriate debugging message is displayed and strings continue to work. Install a plugin that implements custom string manager. You can use https://github.com/mudrd8mz/moodle-local_stringman or implement own solution. Set the relevant value in config.php (see README if you use my dummy implementation) and make sure the custom string manager is actually used.
    • Affected Branches:
      MOODLE_28_STABLE, MOODLE_29_STABLE
    • Fixed Branches:
      MOODLE_29_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-49361-master-stringman

      Description

      Currently, the factory function get_string_manager() returns singleton instance of core_string_manager_install() in early stages of the site installation, or instance of core_string_manager_standard().

      Proposal

      This is a proposal to introduce a new config.php setting like $CFG->alternativestringmanager. If that setting is found and it contains a valid class name, and that class implements interface core_string_manager, then it is used as the string manager instead of the default one. The class would be typically provided by an additional plugin. The setting must be defined via config.php only. The value in mdl_config table will be ignored (so that malicious plugin can't inject it secretly).

      Use-cases

      • String usage accounting plugin - this will allow us to implement a plugin that collects and logs string usage (together with the context, user role etc). This can lead to a report on what strings are most important ones to be translated (for students, for teachers etc).
      • Ability to override strings in one component via additional plugin - see MDL-46582
      • Ability to have a plugin that allows local language customization and/or language pack contribution directly at the page where the string appears (it would log all the get_string() calls in the current request and then somehow inject them into the page footer so that they could be used by a JS on the client, for example).
      • Experimental implementations of advanced plural handling, Google translator integration and all other crazy stuff.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                11/May/15