Template:module cat/documentation

Introduction
This template is used to add modules to the appropriate categories based on the module's name and/or parameters indicating the language(s) and type(s) of the module.

The module underlying this template can automatically categorize modules that are named in predictable ways: with language code, a hyphen, and a word explaining what the module is. For example, it recognizes the title  and adds the categories Ukrainian modules and Pronunciation modules. The list of correspondences between the last part of the module name and the category are found in Module:module categorization, which generates the content for this template. The module also adds the appropriate sortkeys.

For the most part, it is not necessary to invoke this template explicitly as it will automatically be called from Module:documentation whenever the module's categories aren't explicitly specified on the module's documentation page. (Specifically, Module:documentation checks to see if there is an  section or an explicit invocation of module cat. If not, it automatically invokes Module:module categorization, which is the Lua code that implements module cat, to categorize the module appropriately.)

If the automatic algorithm doesn't work out of the box, you can call module cat with the appropriate parameters to get the right categorization. It can be included in an  section, but need not be. (You can also add the categories manually inside of an  section, but this is not recommended as it is tedious and error-prone.)

Parameters
The template accepts the following parameters:
 * 1
 * Comma-separated list of language, script and/or family codes that this module applies to. If omitted, it is inferred from the prefix of the module name. Use for non-language-specific modules. To specify a family code, prefix it with, which is equivalent to specifying all the languages in the family. (Specifying the family code without the prefixed  refers to the family's proto-language.) Note that multiple language and/or script codes are automatically inferred from the module name when possible. For example, given Module:uk-be-headword or any subpage such as a hypothetical Module:uk-be-headword/data/testcases, the language codes  (Ukrainian) and  (Belarusian) will be inferred. Given Module:ks-Arab-to-Deva-translit, the language code  and script codes  and  are all inferred. ( is a valid language code corresponding to Tongan, but as a special case it's ignored unless it occurs first.)


 * 2 or type
 * Comma-separated list of module types for this module. Module types should be capitalized, e.g., or . A module type may be followed by a colon and a sortkey, which overrides the automatically-generated one. Underscores are replaced with spaces; for example, Module:Swadesh uses - to categorize into Category:Swadesh modules with a sort key consisting of a space character (so that the module appears at the beginning of the list of modules, before all language-specific moduels).  If omitted, it is inferred from the suffix of the module name and/or any subpage component following a slash. See below.

This template is also used by to add categories for all languages that list the transliteration module in their data tables. For instance, Module:sa-translit has the language code for Sanskrit in its title, but it is currently used for languages besides Sanskrit.

Module types
If 2 or type (the module type) is omitted, the module type is inferred from the pagename. Specifically, the rightmost hyphen-delimited or space-delimited suffix in the root part of the module name is used to look up the appropriate module type. (The root part is obtained from the full module name by stripping the prefix and any subpages following a slash. The suffix used to infer the module type is the text following the last hyphen or space. For example, given the module Module:uk-be-headword or any subpage such as a hypothetical Module:uk-be-headword/data/testcases, the keyword  will be extracted and used to infer a module type .) In addition, modules containing the string  followed by a hyphen, slash or end of string will be considered -type modules as well as any other types inferrable from the portion before the slash. Similarly, modules containing the string followed by a hyphen, slash or end of string will be considered -type modules, or in some cases -type or -type modules, in addition to any other types inferrable from the portion before the slash.

The following is the table used to map the keyword found in the rightmost portion of the root pagename (as described above) to module types:

Note that you can specify other types. In particular, see the list of subcategories of Category:Modules, which includes the name of the subcategory and the description. The module type is the same as the name of a module category minus the word at the end, including the initial capital letter. (No validation is done on the module type; for example, if you specify type, the module will be duly categorized in Category:Foobar modules. However, this is probably not helpful.)

Module types by patterns
The module may also infer additional module types based on Lua patterns. In particular, there are two such patterns recognized currently: Both patterns can operate simultaneously for a module like Module:la-verb/testcases/data.
 * 1) Page names containing  (followed by a hyphen, slash or end of string) will infer the additional module type.
 * 2) Page names containing  (followed by a hyphen, slash or end of string) will infer one or more additional module types based on the existing module types. Specifically, if  is one of the existing module types,  is inferred; if  is one of the existing module types,  is inferred; and if a module type other than  and  is one of the existing module types,  is inferred.