Module:Families/doc: Difference between revisions

From Linguifex
Jump to navigation Jump to search
(Created page with "This module is used to retrieve and manage Wiktionary's various language families and the information associated with them. See Wiktionary:Families for more information....")
 
m (clean up)
Tag: Replaced
Line 1: Line 1:
This module is used to retrieve and manage Wiktionary's various language families and the information associated with them. See [[Wiktionary:Families]] for more information.


This module provides access to other modules. To access the information from within a template, see [[Module:families/templates]].
[[Category:Modules]]{{module documentation}}{{documentation subpage}}
 
The information itself is stored in [[Module:families/data]]. This module should '''not''' be used directly by any other module, the data should only be accessed through the functions provided by Module:families.
 
==Finding and retrieving families==
 
The module exports a number of functions that are used to find families.
 
===getByCode===
<code>getByCode(code)</code>
 
Finds the family whose code matches the one provided. If it exists, it returns a <code>Family</code> object representing the family. Otherwise, it returns <code>nil</code>.
 
===getByCanonicalName===
<code>getByCanonicalName(name)</code>
 
Looks for the family whose canonical name (the name used to represent that language on Wiktionary) matches the one provided. If it exists, it returns a <code>Family</code> object representing the family. Otherwise, it returns <code>nil</code>. The canonical name of families should always be unique (it is an error for two families on Wiktionary to share the same canonical name), so this is guaranteed to give at most one result.
 
==Family objects==
 
A <code>Family</code> object is returned from one of the functions above. It is a Lua representation of a family and the data associated with it. It has a number of methods that can be called on it, using the <code>:</code> syntax. For example:
 
<source lang="lua">
local m_families = require("Module:families")
local fam = m_families.getByCode("ine")
local name = fam:getCanonicalName()
-- "name" will now be "Indo-European"
</source>
 
===Family:getCode===
<code>:getCode()</code>
 
Returns the family code of the family. Example: <code>"ine"</code> for the Indo-European languages.
 
===Family:getCanonicalName===
<code>:getCanonicalName()</code>
 
Returns the canonical name of the family. This is the name used to represent that language family on Wiktionary, and is guaranteed to be unique to that family alone. Example: <code>"Indo-European"</code> for the Indo-European languages.
 
===Family:getAllNames===
<code>:getAllNames()</code>
 
Returns a table of all names that the family is known by, including the canonical name. The names are not guaranteed to be unique, sometimes more than one family is known by the same name. Example: <code>{"Slavic", "Slavonic"}</code> for the Slavic languages.
 
===Family:getFamily===
<code>:getFamily()</code>
 
Returns a <code>Family</code> object for the parent family that the family is a part of.
 
===Family:getProtoLanguage===
<code>:getProtoLanguage()</code>
 
Returns a <code>Language</code> object (see [[Module:languages]]) for the proto-language of this family, if one exists.
 
===Family:getCategoryName===
<code>:getCategoryName()</code>
 
Returns the name of the main category of that family. Example: <code>"Germanic languages"</code> for the Germanic languages, whose category is at [[:Category:Germanic languages]].
 
===Family:getWikidataItem===
<code>:getWikidataItem()</code>
 
Returns the Wikidata item of that family.
 
===Family:getWikipediaArticle===
<code>:getWikipediaArticle()</code>
 
Returns the Wikipedia article of that family, usually derived from <code>:getWikidataItem()</code>.
 
<includeonly>
[[Category:Modules dealing with languages and scripts]]
</includeonly>

Revision as of 21:54, 19 March 2021