Jump to content

සැකිල්ල:ගැජට්/MediaWiki:Gadget-AcceleratedFormCreation.js/documentation

Wiktionary වෙතින්
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 Module:accel.

This gadget allows you to automatically generate entries for inflected forms of words.

[සංස්කරණය]

To enable the gadget, enable it in the Gadgets tab of your preferences: item "⧼gadget-AcceleratedFormCreation⧽". 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. The order in which the definitions appear is determined by the order in which they appear in the lemma entry, but can be modified; see below under #Inflection tables organised by column.

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, or fix it yourself if you are able.

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.

Module:accel will generate a default entry based on the tags you provide (the specific details are explained in its documentation). If this is not sufficient, i.e. if the entries need to be formatted in a language-specific way, you can create your own submodule of Module:accel and write your own rules. If you don't know how, ask in WT:GP for help.

Acceleration tags

[සංස්කරණය]

The following is a list of tags that you can add to links to enable accelerated forms to be created. Each tag is associated with either (a) a template parameter to provide it when used with link templates such as {{l}} or {{l-self}}; (b) a key in the table passed as the accel key in the data parameter to the full_link() function in Module:links, when called from a module.

form= (in modules) or |accel-form= (in templates)

Which particular form the link is for. It should use the inflection codes used in {{inflection of}}, with pipe symbols (vertical bars) separating the inflection codes. When called from a module, use the pipe symbols directly, e.g. form="nom|m|p" for nominative masculine plural. When used in template code, you will need to encode the pipe symbols using {{!}}, e.g. |accel-form=nom{{!}}m{{!}}p. You can also specify arbitrary text such as comparative-of, but this must be interpreted by a language-specific module (such as Module:accel/ru for Russian) and converted into the appropriate definition. This is the only tag that is mandatory.

gender= (in modules) or |accel-gender= (in templates)

The gender code that should be added to the headword line, using the same format that {{head}} uses, e.g. m-p for masculine plural. 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.

translit= (in modules) or |accel-translit= (in templates)

The transliteration that should appear on the headword line. The value of this parameter goes into param |tr= of the call to {{head}} in the accelerated entry. You only need to specify this for languages that use a non-Latin script, and only when the auto-generated transliteration is insufficient, incorrect or nonexistent.

lemma= (in modules) or |accel-lemma= (in templates)

The lemma to be included in the call to {{inflection of}} on the definition line. The value of this parameter goes into param |2= of the call to {{inflection of}}. It defaults to the name of the current page, and only needs to be specified when the lemma contains additional diacritics that are stripped in order to generate the pagename (as in Latin, Russian, Ancient Greek, Old English, etc.).

lemma_translit= (in modules) or |accel-lemma-translit= (in templates)

The manual transliteration of the lemma to be included in the call to {{inflection of}} on the definition line. The value of this parameter goes into param |tr= of the call to {{inflection of}}. You only need to specify this for languages that use a non-Latin script, and only when the auto-generated transliteration is insufficient, incorrect or nonexistent.

nostore=true (in modules) or |accel-nostore=true (in templates)

Normally, the forms on a page are processed in reading order (left to right, top to bottom), and the entries/definitions will be added to the page in that order. This tag is used when the same form appears multiple times in a page/inflection table, and causes a particular link to be ignored for the ordering. This is useful when an inflection table shows some forms in its collapsed state, like for example {{se-infl-adj-even}} or {{nl-conj-wk}}. By placing this tag on the links that appear in the collapsed state, their forms will not be shown before the forms in the rest of the table.

Adding the tags to a template

[සංස්කරණය]

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 parameters for each of the tag types listed above, with the name prefixed with accel-. Thus, for the form tag, you use the accel-form= parameter, e.g.

{{l-self|en|foos|accel-form=p}}

If you are working in a module using the full_link function of Module:links, the accel key can be provided as one of the values in the table that's passed as the first parameter. The value should be a table containing the acceleration tags as keys, e.g.

full_link({lang = lang, term = "foos", accel = {form = "p"}})

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, the tag name is prefixed with fNaccel- N stands for the number of the form, e.g.

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

In a module using the full_headword function of Module:headword, you provide the accel key in the list of inflections of a particular label. Its value is a table of tags, like as with Module:links, e.g.

full_headword({lang = lang, inflections = { {label = "plural", accel = {form = "p"}, "foos"}, {label = "diminutive", accel = {form = "diminutive"}, "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.

Inflection tables organised by column

[සංස්කරණය]

The order in which definitions appear in combined entries is determined by the order in which the links appear in the page/HTML code. This order is always in reading order: left to right, top to bottom. Many inflection tables are organised by column, and often you want the forms in one column to take priority over forms in another column. For example, it's generally desirable to have the definitions of singular forms appear before the definitions of plural forms. For this, there is the data-accel-col= attribute.

The data-accel-col= attribute is placed on the table cell which contains the accelerated inflection links, and is given a column number as a value. For example:

|-
! Locative
| data-accel-col="1" | {{l-self|se|soddjilis|accel-form=loc{{!}}s}}
| data-accel-col="2" | {{l-self|se|soddjiliin|accel-form=loc{{!}}p}}
|-
! Comitative
| data-accel-col="1" | {{l-self|se|soddjiliin|accel-form=com{{!}}s}}
| data-accel-col="2" | {{l-self|se|soddjiliiguin|accel-form=com{{!}}p}}

Columns with the same number are processed as a single unit, so all forms with column number 1 are processed before all forms with column number 2. Consequently, definitions for forms in column 1 will always appear in an entry before definitions for forms in column 2. If the inflection table contains another set of columns below the first set, the count continues, so that the columns are numbered 1, 2, 3, 4 and so on.

Column numbers are applied on a per-table basis. This means that if the same column number appears in multiple tables in the same language section, they will not interfere with each other; each new table "resets" the columns. Any table cell (but not a header cell with !) that does not have the data-accel-col= attribute will also cause a column reset. This means that you can have two different columns numbered 1, as long as there is a table cell without a column number in between them. Once a cell lacking a column number is encountered in the reading order, processing of the forms will continue in reading order as usual.

Rules for generating entries

[සංස්කරණය]

The new entries themselves are not generated by this script, but by Module:accel and its language-specific submodules. If you want to add or edit rules for your language, look on the module's page for information and instructions.