This module provides access to Module:families from templates, so that they can make use of the information stored there.
{{#invoke:families/templates|exists|(family code)}}
Check whether a family code exists and is valid. It will return "1" if the family code exists, and the empty string "" if it does not.
This is rarely needed, because a script error will result when someone uses a code that is not valid, so you do not need this just to check for errors. However, in case you need to decide different actions based on whether a certain parameter is a family code or something else, this function can be useful.
{{#invoke:families/templates|getByCode|(family code)|(item to look up)|(index)}}
Queries information about a family code.
getCanonicalName
or getFamily
. If no item has been provided, the result will be a script error. However, if the name of a nonexistent item is given, the result will be an empty string. This allows you to check for the presence or absence of an item without triggering errors.getOtherNames
. It selects which item in the list to return. On items that are single strings, like getFamily
, it has no effect. If no index is given, the default will be 1 (the first subitem). If an index is given that is higher than the number of items in the list, the result will be an empty string.For example, to request the default (canonical) name of the family whose code is sla
:
{{#invoke:families/templates|getByCode|sla|getCanonicalName}}
Slavic
To request its second name, if any:
{{#invoke:families/templates|getByCode|sla|getOtherNames|1}}
Slavonic
To request its family:
{{#invoke:families/templates|getByCode|sla|getFamily}}
ine-bsl
local export = {}
function export.exists(frame)
return require("Module:families").getByCode(
require("Module:parameters").process(frame.args, {
= {required = true}
})
) and "1" or ""
end
function export.getByCode(frame)
return require("Module:language-like").templateGetByCode(
require("Module:parameters").process(frame.args, {
= {required = true, type = "family"},
= {required = true},
= {}
})
)
end
function export.getByCanonicalName(frame)
local fam = require("Module:families").getByCanonicalName(
require("Module:parameters").process(frame.args, {
= {required = true}
})
)
return fam and fam:getCode() or ""
end
return export