Development:Places to search for lang strings

From MoodleDocs
Revision as of 09:07, 11 July 2008 by Howard Miller (talk | contribs)

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).