Development:Places to search for lang strings

From MoodleDocs

Moodle has a mechanism that allows a number of places to be searched (in order) to find language strings or help files. This enables help to be packaged with optional plugins and avoids the step of having to copy the language files over to the language directory when a plugin is installed. This page provides some information about this mechanism which might be useful to plugin developers or those wishing to add a completely new pluggable feature to moodle.

Basic concepts

When it is required to lookup a string or point to a help file, two basic items of information are required. The first is the name of the string (or the help filename) and the name of the module in which it can be found. For example, get_string('editingquiz','quiz') returns "Editing Quiz" in the current language; a call to help.php?module=label&file=mods.html displays the help for a label, again in the current language.

Plugin support extends this by defining a new format for the module name. The module name becomes type_plugin, where type is a generic name common to the plugin type and plugin is the name of the individual item. To illustrate this, here is an example. Blocks are a pluggable resource - the type name is block_ and the plugin name is the name of the individual block. Some examples of block module names are block_search (type is block_ and plugin is search) and block_online_users (type is block_ and plugin is online_users).

It is important to grasp that every block is now a discrete module type. This applies to all pluggable resources, so every, e.g., questiontype, authentication plugin, grade report is a separate module and will have its own language file and it's own directory for its help files. Not all plugin types define both language strings and help files but here is an example of what you might find for a plugin module:

   Description: questiontype plugin for multichoice
   Module name: qtype_multichoice
   Language strings (English): lang/en_utf8/qtype_multichoice.php
   Help files directory (English): lang/help/qtype_multichoice/

All of the above must be in place for pluggable language and help strings to be a possibility for optional plugins.

Defining the search path(s)