GRAMMAR in MediaWiki

GRAMMAR is a parser function which is used to produce the correct form of a word when:

  • it can take different grammatical forms in a particular language, and
  • it occurs in wikitext as the output of other magic words.

The magic word, or variable, {{SITENAME}} is the magic word which most often has multiple forms, for which GRAMMAR is needed.

The different grammatical forms of each word can be coded in the language.php file either as an array or as a set of simple grammatical rules.

  • Array. Each grammatical form of a word is recorded in an array, according to its grammatical form, for example Irish.
  • Grammar rules. Grammar rules for writing the correct form can be recorded for each grammatical case, but only where the grammar rules are very simple, for example Russian.

See MediaWiki for a brief explanation, a summary and the software description page. See Meta for a summary of language-dependent word conversions.

If your language needs to implement GRAMMAR then please discuss this with other contributors to your language, if any, and then request it on Support. If new words need to be added to an array, for example new sitenames, again please request it on Support. It is a good idea to keep a complete set of test cases on your languages Portal page or a subpage thereof.

Using GRAMMAR in wikitext

When GRAMMAR has been coded in the Language.php file it can then be used in wikitext with other words as follows:

  • {{GRAMMAR:N|word}} where N is the name of the grammatical form needed and word is the word being operated on. See an example in Finnish - wikitext {{GRAMMAR:elative|wiki}} produces wikistä in Finnish.

Languages using GRAMMAR

See a list of languages for which GRAMMAR has been implemented in convertGrammar, together with links to the code and arrays for each language, by searching all convertGrammar functions.

Month names magic word in MediaWiki

Before GRAMMAR was introduced the magic word CURRENTMONTHNAMEGEN was used to produce the genitive form of the month names. The genitive forms are entered as messages in core messages; january-gen ("January") and so on.

Grammar conversions in other projects recommends that all projects offer support for grammatical forms. You should find details of grammar support on the project pages, if any is provided.