MediaWiki:Gadget-AcceleratedFormCreation.js/documentation

Definition from Wiktionary, the free dictionary
Jump to: navigation, search
Edit-copy green.svg Documentation for MediaWiki:Gadget-AcceleratedFormCreation.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 gadget allows you to automatically generate entries for inflected forms of words.

Enabling accelerated links

To enable the gadget, enable it in the Gadgets tab of your preferences: item "Add accelerated creation links for common inflections of some words.". If you do not have an account, you can enable it in your per-browser preferences instead.

Creating new entries

Many existing pages and templates already support the acceleration gadget. If a link allows you to generate a new entry automatically, it will appear bright green. To start creating an entry, simply click the link, which will take you to edit it. The edit window will automatically have the new entry added to it. You can then save the page like you would any other page.

It is important that you check the new entry to make sure that everything is correct! Although editors should take great care to make sure that the gadget does not generate bad entries, it is your own responsibility to make sure you don't inadvertently add incorrect or badly formatted content to Wiktionary. If the gadget is generating wrong entries, you should report this to the Grease pit.

Making a template use the script

Adjusting a template or module to use the script is relatively easy. Whenever your template/module shows a link to an inflected form, you need to provide it with some extra information. This extra information consists of "tags" that tell the script how to process your link, so that the right entry is generated.

The following is a list of tags that you can add. Italics indicate something you need to fill in yourself. When you need to include multiple tags, separate them with a space. If the values have spaces in them, replace the spaces with an underscore (_).

form-form-of
Which particular form the link is for. It can be just about anything, and is often language-specific. It is generally used to generate the definition line of the new entry. This is the only tag that is mandatory.
gender-gender
The gender code that should be added to the headword line, using the same format that {{head}} uses. This should only be needed in rare occasions. If the definition already mentions the gender, like "feminine form of" for example, then this is redundant and you should not add it.
transliteration-translit
The transliteration that should appear on the headword line. For many languages, the headword-line template can generates its own transliterations, so you only need to provide this tag when this is not possible, or when the automatically-generated translation would be wrong.
origin-pagename
The lemma, the term that the new entry should be considered an inflected form of. The definition will contain a link that links back to this page. The script will automatically figure this out based on the page the link is in, so it's not usually needed. However, if the link should show a different term, for example with additional diacritics that are not present in the page name, then you should provide this tag.
origin_transliteration-translit
The transliteration of the lemma, which is shown in the definition line after the link to the lemma. Again, the definition-line template can usually generate its own transliterations, so you only need to provide it when it can't or if the automatically-generated transliteration would be wrong.

There are various ways to add accelerated creation to links, both in templates/wikicode and in modules/Lua. Acceleration tags should not be added directly to entries, there should always be a template that wraps around it.

Links that are created with the standard linking templates {{l}}, {{l-self}} and such have an accel= parameter. You can provide the acceleration tags with this parameter, e.g.

{{l-self|en|foos|accel=plural-form-of}}

If you are working in a module using the full_link function of Module:links, the accel= parameter can be provided as one of the values in the first parameter, e.g.

full_link({lang = lang, term = "foos", accel = "plural-form-of"})

When working on a headword template, you'll typically be using {{head}}, and providing it with one or more inflected forms to show on the headword line. To provide acceleration tags for the inflected forms, you provide the fNaccel= parameter, followed by the tags you want, where N stands for the number of the form. For example:

{{head|en|noun|plural|foos|f1accel=plural-form-of|diminutive|bar|f2accel=diminutive-form-of}}

In a module using the full_headword function of Module:headword, you provide the accel= parameter on the list of inflections of a particular label, e.g.

full_headword({lang = lang, inflections = { {label = "plural", accel = "plural-form-of", "foos"}, {label = "diminutive", accel = "diminutive-form-of", "bar"} }

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.

Requesting new rules

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

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:

lang
The language code. This is whatever was given in the span as the language, but with the lang- at the beginning removed.
pos
The part of speech that the new entry is created for. This is taken from whatever header precedes the template.
form
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.
gender
The gender, or null. Whatever was given in the span as the gender, but with the gender- at the beginning removed.
transliteration
The transliteration, or null. Whatever was given in the span as the transliteration, but with the transliteration- at the beginning removed.
origin
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.
origin_pagename
The page name of the lemma.
origin_transliteration
The origin_transliteration, or null. Whatever was given in the span as the origin_transliteration, but with the origin_transliteration- at the beginning removed.
target
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.
target_pagename
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:

lang_header
The name of the level 2 header of the new entry. You rarely need to change this, the default should be correct.
pronunc
The contents of the "Pronunciation" section, if any. Empty by default.
pos_header
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".
head
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.
def
The definition line, without the initial # . You must override this, as there is no default and the script will fail.
declension
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.
conjugation
As above, but for "Conjugation".

Subpages