Definition from Wiktionary, the free dictionary
Jump to: navigation, search
Edit-copy green.svg Documentation for User:Conrad.Irwin/creation.js. [edit]
This page contains usage information, categories, interwiki links and other content describing the template.
To edit the rules for generating new form-of entries, go to User:Conrad.Irwin/creationrules.js.

This script allows the automatic creation of entries for inflected forms of words. This makes it similar to what form bots such as User:MewBot or User:SemperBlottoBot do, but in a way that anyone can use relatively easily.

Enabling accelerated links[edit]

To enable the script, do either (only one) of those things:

  • If you have an account, enable it in the Gadgets tab of your preferences: item "⧼gadget-WiktAccFormCreation⧽"
  • Add the following to your common.js (again, if you have an account):
  • Go to WT:PREFS and tick "Add accelerated creation links for common inflections of some words". This should work even for users without an account.


  • Browse to an entry missing forms that uses one of the accelerated templates or create a new word.
  • Click on any "green links" (these would be "red links" normally)
  • Review the page it would create for you by asking for a preview.
  • Click "Save" on the page it creates for you.

If it doesn't work as advertised, try doing a hard refresh before giving up hope. If this fails, report this at WT:Grease pit.

Making a template use the script[edit]

The basic idea is to wrap a link in a <span> which contains the necessary information to create the page. The script works by looking through a page for HTML elements that contain class="form-of". This acts as a "flag" for the script that says "here is a link you need to look at". The element's class must also contain information about what kind of form it is; this tells the script what kind of entry the link should generate. The parameters are passed in the class name of the span, and one of the class-names of the span (normally the first) must be form-of.

Both Template:head and Module:headword inherently support accelerated links. They include class="form-of lang-langcode" for you, so that you only need to specify the remainder:

  • Template:head has a set of fNaccel= parameters, which specify the class and other details.
  • Module:headword allows you to specify an .accel value as part of the table of inflections to show in the headword.

When you're done, add {{isAccelerated}} to the documentation page of the template. This shows a notice that accelerated links are enabled for this template. It also adds the template to Category:Templates with acceleration.

The following is the currently supported range of parameters that can be used. Italics indicate something you need to fill in yourself.

The language that it's in. This parameter is mandatory, but Template:head and Module:headword include this for you automatically.
Which particular form the link is for. It can be just about anything, and is often language-specific. Mandatory.
The gender of the form in question. This should only be needed if it needs to be specified on the headword line. It's redundant if the "form of" definition already mentions the gender, so if the definition already says "feminine form of" then you don't need to add this.
The term that the generated form-of entry should link back to. This defaults to the name of the current page, but you can override it if you need to provide extra diacritics that are not present in the page name.
The transliteration for the form. This is usually used to provide a tr= parameter on the headword-line template of the generated entry. This means you only need to provide it if that template can't automatically generate a correct transliteration.
The transliteration of the origin. This is usually used to provide a tr= parameter in the form-of template. This means you only need to provide it if that template can't automatically generate a correct transliteration.

When this information has been gathered from the element's class definition, any red links that are inside the element are then modified. The links are made green, and the URL of the link is changed to include information for generating the form-of entry. The wiki software will pick up on this when the link is followed, and will preload the edit window with the given text.

If a link is red but with green dashes underneath, it means that the script understood the parameters that were given in the template, but it did not know how to generate an entry with them. This usually means that the script has no generation rules for a particular language yet, or that the form that you asked for isn't recognised for that language. To fix this, you need to update the rules (below).

Requesting new rules[edit]

If you are not able to edit the script yourself, please file requests for new features on the script's talk page. Specify:

  1. What you want to generate the links for. That includes at least a link to the template whose links you want to make green.
  2. What the generated entries should look like. In particular, which headword-line template it should use, and which form-of template, which parameters they should receive in which situations, and so on. A link to a word that has blue links to all the forms in the template would work best, as an example.
  3. Ideally, a link to a word that has red links to all the forms. This is useful for testing to see if the generated entries are correct.

Adding new rules[edit]

Generation rules are used to create the entry's contents from within the script. They are defined in a separate file, User:Conrad.Irwin/creationrules.js. The creation_rules array contains an entry for each recognised language. This entry is a function that takes two arguments, params and entry.

The params parameter is an array that contains the information about the lemma, the form-of entry to be created, and the information given in the <span class="form-of... of the template. It contains the following values:

The language code. This is whatever was given in the span as the language, but with the lang- at the beginning removed.
The part of speech that the new entry is created for. This is taken from whatever header precedes the template.
The name of the form. This is whatever was given in the span as the form name, but with the -form-of at the end removed.
The gender, or null. Whatever was given in the span as the gender, but with the gender- at the beginning removed.
The transliteration, or null. Whatever was given in the span as the transliteration, but with the transliteration- at the beginning removed.
The term that the new entry should link back to. If the origin- value was given in the span, it will be that. Otherwise, it's the same as origin_pagename by default.
The page name of the lemma.
The origin_transliteration, or null. Whatever was given in the span as the origin_transliteration, but with the origin_transliteration- at the beginning removed.
The form that the new entry is created for. This is taken automatically from the display form (alt) in the template's link to the form. It is used to give the head= parameter if necessary. This is the same as target_pagename in most cases, but can be different if the display form contains additional diacritics.
The page name of the entry to be created.

The entry parameter contains the different parts of the entry that is being created. Some of them have a default value, while others are null by default. The purpose of the generation function for each language is to provide these values so that the entry is generated according to what is needed for the language. The entry array contains the following values:

The name of the level 2 header of the new entry. You rarely need to change this, the default should be correct.
The contents of the "Pronunciation" section, if any. Empty by default.
The name of the level 3 part-of-speech header for the new entry. This does not usually need to be changed, as it automatically matches the part of speech of the main entry. But you can change it if, for example, you are generating a participle entry and you want to show "Participle" instead of "Verb".
The headword template code and all its parameters. By default, it uses {{head|(lang)|(pos) form}}, with head= and tr= as necessary. You need to override this if you need something else.
The definition line, without the initial # . You must override this, as there is no default and the script will fail.
The contents of the "Declension" section, if any. Empty by default. This can be used if the new entry is a sub-lemma with its own inflection, such as participles or comparative/superlative forms that inflect themselves.
As above, but for "Conjugation".