Module:User:Jberkel/headword/documentation

This module is used to show headword lines, along with any annotations like genders, transliterations and inflections. It's used by the template, via the submodule Module:headword/templates.

full_headword
This is the primary external entry point. '''NOTE: The values passed in below will be destructively modified. You are warned.'''

This is used to display an entire headword line, such as will be displayed by or various language-specific headword templates (e.g.  for Russian adjectives,  for German nouns, etc.). Arguments are as follows (WARNING: they will be destructively modified):


 * is required and is a language object corresponding to a given language. Use e.g.  to retrieve the object corresponding to Russian.
 * is a script object corresponding to a given script. Most of the time you can pass in.
 * is a table listing the heads of the headword, each of which is a string. An empty string means to use a default head based on the page name. It is also possible to pass in a single string for a single headword, or, which is equivalent to passing in a single empty string (i.e. only one head, based on the page name).
 * is a table listing the transliterations corresponding to each headword in . The Nth numbered entry should be either a string specifying the transliteration of headword N, or   for no transliteration (for some languages, this means to generate an automatic transliteration, and "-" will have to be passed in to suppress the transliteration entirely). It is also possible to pass in a single string (equivalent to a one-element list) or   (equivalent to a no-element list). Note that, if there are multiple headwords, the table in   might have entries in the middle of the list that are  . A list of this sort cannot be created with , as attempting to insert   this way does nothing. Instead, the correct numbered entries will have to be directly assigned to.
 * is a table listing the gender/number strings for the headwords. This can be  for no genders/numbers. The individual gender/number strings are as in Module:gender and number. See   below for an example of this argument (it has the same format as the   argument to that function).
 * is a table listing the inflections to be displayed in the headword entry. The format of this table is somewhat complex and is described below under  (it has the same format as the   argument to that function).
 * is a table listing the categories to which the page containing the headword belongs. The first category should be a part-of-speech category (e.g. ).
 * is a string specifying a sort key for the categories listed in, or   to use a default sort key based on the page name. This is used to ensure that the page is listed in the correct order in the categories to which it belongs. See   in Module:utilities for more information.

A simple example
might give (depending on the page it's run on): book &amp;lrm;(plural books)

which displays as:
 * book &lrm;(plural books)

A fuller example
might give (depending on the page it's run on): Hund &amp;nbsp; m &amp;lrm;(genitive Hundes or Hunds, plural Hunde or (nonstandard) Hünde, diminutive Hündchen&amp;nbsp; <abbr title="neuter gender">n or <b class="Latn" lang="de">Hündlein</b>&amp;nbsp; <abbr title="neuter gender">n )

which displays as:
 * <strong class="Latn headword" lang="de">Hund <abbr title="masculine gender">m &lrm;(genitive <b class="Latn" lang="de">Hundes</b> or <b class="Latn" lang="de">Hunds</b>, plural <b class="Latn" lang="de">Hunde </b>or (nonstandard) Hünde, diminutive <b class="Latn" lang="de">Hündchen</b> <abbr title="neuter gender">n or <b class="Latn" lang="de">Hündlein</b> <abbr title="neuter gender">n )

An example in a non-Latin script
This example is in Russian, which has automatic transliteration:

might give (depending on the page it's run on): <strong class="Cyrl headword" lang="ru">кни́га • &amp;lrm;( kníga  )&amp;nbsp; <abbr title="feminine gender">f &amp;nbsp; inan &amp;lrm;(genitive <b class="Cyrl" lang="ru">кни́ги</b>, nominative plural <b class="Cyrl" lang="ru">кни́ги</b>, genitive plural <b class="Cyrl" lang="ru">книг</b>)

which displays as
 * <strong class="Cyrl headword" lang="ru">кни́га • &lrm;( kníga  ) <abbr title="feminine gender">f inan &lrm;(genitive <b class="Cyrl" lang="ru">кни́ги</b>, nominative plural <b class="Cyrl" lang="ru">кни́ги</b>, genitive plural <b class="Cyrl" lang="ru">книг</b>)

A fuller example in a non-Latin script
This example is in Russian, with two headwords, each of which requires manual transliteration:

might give (depending on the page it's run on): <strong class="Cyrl headword" lang="ru">интервьюе́р or <strong class="Cyrl headword" lang="ru">интервью́ер • &amp;lrm;( intɛrvʹjuér or intɛrvʹjújer  )&amp;nbsp; <abbr title="masculine gender">m &amp;nbsp; anim &amp;lrm;(genitive <b class="Cyrl" lang="ru">интервьюе́ра</b> or <b class="Cyrl" lang="ru">интервью́ера</b>, nominative plural <b class="Cyrl" lang="ru">интервьюе́ры</b> or <b class="Cyrl" lang="ru">интервью́еры</b>, genitive plural <b class="Cyrl" lang="ru">интервьюе́ров</b> or <b class="Cyrl" lang="ru">интервью́еров</b>)

which displays as
 * <strong class="Cyrl headword" lang="ru">интервьюе́р or <strong class="Cyrl headword" lang="ru">интервью́ер • &lrm;( intɛrvʹjuér or intɛrvʹjújer  ) <abbr title="masculine gender">m anim &lrm;(genitive <b class="Cyrl" lang="ru">интервьюе́ра</b> or <b class="Cyrl" lang="ru">интервью́ера</b>, nominative plural <b class="Cyrl" lang="ru">интервьюе́ры</b> or <b class="Cyrl" lang="ru">интервью́еры</b>, genitive plural <b class="Cyrl" lang="ru">интервьюе́ров</b> or <b class="Cyrl" lang="ru">интервью́еров</b>)

Another fuller example in a non-Latin script
This example is in Arabic, with embedded links in the headword and manual transliteration in an inflection (note that Arabic also has automatic transliteration, and is one of the languages that will display automatic transliterations of inflections in the headword, unlike e.g. Russian):

might give (depending on the page it's run on): <strong class="Arab headword" lang="ar">غُدّة بَصَلِيّة إحْلِيلِيّة • &amp;lrm;( ḡudda baṣaliyya ʾiḥlīliyya  )&amp;nbsp; <abbr title="feminine gender">f &amp;lrm;(plural <b class="Arab" lang="ar">غُدَد بَصَلِيَّة إِحْلِيلِيَة</b> &amp;lrm;( ḡudad baṣaliyya ʾiḥlīliyya ))

which displays as
 * <strong class="Arab headword" lang="ar">غُدّة بَصَلِيّة إحْلِيلِيّة • &lrm;( ḡudda baṣaliyya ʾiḥlīliyya  ) <abbr title="feminine gender">f &lrm;(plural <b class="Arab" lang="ar">غُدَد بَصَلِيَّة إِحْلِيلِيَة</b> &lrm;( ḡudad baṣaliyya ʾiḥlīliyya ))

format_headword
Formats a headword, using the format appropriate for the given language object and script (see ).

The  parameter can either be a single string or a table of strings. If it's a table, then each string in the table is shown as a headword, separated by "or". This allows you to show multiple alternative headwords, such as when the same written form can be accented in different ways.

It has special behaviour in certain cases as well:
 * If an item in the  parameter contains wikilinks, they are converted into language-section links for the given language (using , which is also used by ). For example, giving   if the language provided is English will produce:  . If string is prefixed with * or if any of the links are, then they are interpreted as reconstructed terms and it will create links to the appendix namespace as appropriate.
 * If  is empty (  or the empty table), it will default to   (equivalent to   in templates).
 * If the page name contains spaces, it is split and each individual word is automatically wikilinked as above.
 * If the current page is in the appendix namespace, and the language's type (in Module:languages) is not, then a * will be prepended to the headword to indicate that it is a reconstructed term.

format_transliteration
If the transliteration is specified and non-empty, adds some stuff before and after it. For example, if the transliteration is <tt>'foo'</tt> and the language is Hebrew, produces • ( foo ) which looks like “• ( foo )”.

(Note: the bullet/link is only added if the linked-to page actually exists.)

format_genders
NOTE: This documentation is up-to-date. Keep in mind, however, that this function is not currently exported, and the contents of the argument  will be overwritten.

Format gender specifications using Module:gender and number. For example: gives: &amp;nbsp; <abbr title="masculine gender">m &amp;nbsp; inan, <abbr title="masculine gender">m &amp;nbsp; anim &amp;nbsp;<abbr title="plural number">pl displays as:
 * <abbr title="masculine gender">m inan, <abbr title="masculine gender">m anim <abbr title="plural number">pl

The argument is a table, consisting of elements  and. NOTE: The table will be overwritten!!!

The value of  is a list of gender/number strings, in the form required by Module:gender and number.

format_inflections
NOTE: This documentation is up-to-date. Keep in mind, however, that this function is not currently exported, and the contents of the argument  will be overwritten.

Format a list (table) of inflections, which are then concatenated together with commas and surrounded by parentheses. For example: gives: &amp;lrm;(diminutive <b class="Latn" lang="de">Hündchen</b>) displays as:
 * &lrm;(diminutive <b class="Latn" lang="de">Hündchen</b>)

The argument is a table, consisting of elements,  , and optionally. NOTE: The table will be overwritten!!!

The value of  is a list of labeled inflections, each of which is a table:
 * The table must have a  value which contains the label. It is displayed in italics and not linked.
 * The table may optionally have a  value. This value is used to support accelerated entry creation using WT:ACCEL. The "form-of" and "lang-(code)" classes are added automatically, so only the "(form)-form-of" class needs to be given, along with any other classes that may be needed.
 * Numbered values in the table are the actual forms. They are normally formatted in bold text and converted to a link to the term (but see below). If a term already contains a link, it is converted into a section link using, just like in.
 * Forms are optional. If the table contains only the, then just the label is shown with no forms. If there is more than one form, they are shown with "or" between them.

For example:

gives: &amp;lrm;(present <b class="Latn" lang="sv">krama</b>, past <b class="Latn" lang="sv">kramade</b>, past participle <b class="Latn" lang="sv">kramat</b>) &amp;lrm;(plural <b class="Latn" lang="nl">voorbeelden</b> ) displays as:
 * &lrm;(present <b class="Latn" lang="sv">krama</b>, past <b class="Latn" lang="sv">kramade</b>, past participle <b class="Latn" lang="sv">kramat</b>)
 * &lrm;(plural <b class="Latn" lang="nl">voorbeelden</b> )

It is also possible, but optional, to supply a table instead of a term. This table can contain the keys  (the actual term),   (alternative display form),   (script),   (sense id),   (list of genders),   (if true, the function will not link to the term, but only display it boldfaced),   (if true, the function will not link to the term, but display it italicized and preceded by a *),   (same as   in the outer table but applies only to the given term; if both accelerators are specified, both will appear as CSS classes). Most of these are used the same way as for  in Module:links, and are passed directly to it.

Example:

gives: &amp;lrm;(diminutive <b class="Latn" lang="de">Hündchen</b>&amp;nbsp; <abbr title="neuter gender">n or <b class="Latn" lang="de">Hündlein</b>&amp;nbsp; <abbr title="neuter gender">n ) displays as:
 * &lrm;(diminutive <b class="Latn" lang="de">Hündchen</b> <abbr title="neuter gender">n or <b class="Latn" lang="de">Hündlein</b> <abbr title="neuter gender">n )

Proposed/planned changes

 * Checking for invalid genders, given a list of genders that are valid for a particular language.