Module:families/doc
This is the documentation page for Module:families
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.
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
[jhyuk]The module exports a number of functions that are used to find families.
getByCode
[jhyuk]getByCode(code)
Finds the family whose code matches the one provided. If it exists, it returns a Family
object representing the family. Otherwise, it returns nil
.
getByCanonicalName
[jhyuk]getByCanonicalName(name)
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 Family
object representing the family. Otherwise, it returns nil
. 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
[jhyuk]A Family
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 :
syntax. For example:
local m_families = require("Module:families")
local fam = m_families.getByCode("ine")
local name = fam:getCanonicalName()
-- "name" will now be "Indo-European"
Family:getCode
[jhyuk]:getCode()
Returns the family code of the family. Example: "ine"
for the Indo-European languages.
Family:getCanonicalName
[jhyuk]:getCanonicalName()
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: "Indo-European"
for the Indo-European languages.
Family:getDisplayForm
[jhyuk]:getDisplayForm()
Returns the display form of the family. For families, this is the same as the value returned by :getCategoryName("nocap")
, i.e. it reads "NAME languages" (e.g. "Indo-Iranian languages"
). For regular and etymology languages, this is the same as the canonical name, and for scripts, it reads "NAME script" (e.g. "Arabic script"
). The displayed text used in :makeCategoryLink
is always the same as the display form.
Family:getAllNames
[jhyuk]:getAllNames()
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: {"Slavic", "Slavonic"}
for the Slavic languages.
Family:getFamily
[jhyuk]:getFamily()
Returns a Family
object for the parent family that the family is a part of.
Family:getProtoLanguage
[jhyuk]:getProtoLanguage()
Returns a Language
object (see Module:languages) for the proto-language of this family, if one exists.
Family:getCategoryName
[jhyuk]:getCategoryName(nocap)
Returns the name of the main category of that family. Example: "Germanic languages"
for the Germanic languages, whose category is at Category:Germanic languages.
Unless optional argument nocap
is given, the family name at the beginning of the returned value will be capitalized. This capitalization is correct for category names, but not if the family name is lowercase and the returned value of this function is used in the middle of a sentence. (For example, the pseudo-family with the code qfa-mix
has the name "mixed"
, which should remain lowercase when used as part of the category name Category:Terms derived from mixed languages but should be capitalized in Category:Mixed languages.) If you are considering using getCategoryName("nocap")
, use getDisplayForm()
instead.
Family:getWikidataItem
[jhyuk]:getWikidataItem()
Returns the Wikidata item of that family.
Family:getWikipediaArticle
[jhyuk]:getWikipediaArticle()
Returns the Wikipedia article of that family, usually derived from :getWikidataItem()
.