Module:etymology: Difference between revisions
No edit summary |
No edit summary |
||
| Line 5: | Line 5: | ||
local function term_error(terminfo) | local function term_error(terminfo) | ||
if terminfo.lang: | if terminfo.lang:hasType("family") then | ||
if terminfo.term and terminfo.term ~= "-" then | |||
require("Module:debug/track")("etymology/family/has-term") | |||
end | |||
terminfo.term = "-" | terminfo.term = "-" | ||
end | end | ||
| Line 12: | Line 16: | ||
local function create_link(terminfo, template_name | local function create_link(terminfo, template_name) | ||
local link = "" | local link = "" | ||
if terminfo.term | if terminfo.term == "-" then | ||
--[=[ | |||
[[Special:WhatLinksHere/Wiktionary:Tracking/cognate/no-term]] | |||
[[Special:WhatLinksHere/Wiktionary:Tracking/derived/no-term]] | |||
[[Special:WhatLinksHere/Wiktionary:Tracking/borrowed/no-term]] | |||
[[Special:WhatLinksHere/Wiktionary:Tracking/calque/no-term]] | |||
]=] | |||
require("Module:debug/track")(template_name .. "/no-term") | |||
else | |||
-- mw.log(terminfo.term) | -- mw.log(terminfo.term) | ||
link = require("Module:links").full_link(terminfo, " | link = require("Module:links").full_link(terminfo, "term") | ||
if (link ~= "") then link = " " .. link end | if (link ~= "") then link = " " .. link end | ||
end | end | ||
| Line 25: | Line 37: | ||
function export.process_and_create_link(terminfo, template_name | function export.process_and_create_link(terminfo, template_name) | ||
terminfo = term_error(terminfo) | terminfo = term_error(terminfo) | ||
return create_link(terminfo, template_name or "derived" | return create_link(terminfo, template_name or "derived") | ||
end | end | ||
| Line 37: | Line 49: | ||
cat_name = "other languages" | cat_name = "other languages" | ||
elseif source:getCode() == "mul" then | elseif source:getCode() == "mul" then | ||
display = "[[w:Translingualism|translingual]]" | display = raw and "translingual" or "[[w:Translingualism|translingual]]" | ||
cat_name = "Translingual" | cat_name = "Translingual" | ||
elseif source:getCode() == "mul-tax" then | elseif source:getCode() == "mul-tax" then | ||
display = "[[w: | display = raw and "taxonomic name" or "[[w:Biological nomenclature|taxonomic name]]" | ||
cat_name = "taxonomic names" | cat_name = "taxonomic names" | ||
else | else | ||
| Line 46: | Line 58: | ||
cat_name = source:getDisplayForm() | cat_name = source:getDisplayForm() | ||
end | end | ||
return display, cat_name | return display, cat_name | ||
end | end | ||
| Line 68: | Line 79: | ||
table.insert(categories, langname .. " terms borrowed back into " .. langname) | table.insert(categories, langname .. " terms borrowed back into " .. langname) | ||
else | else | ||
table.insert(categories, langname .. " | table.insert(categories, langname .. " " .. (data.borrowing_type or "terms derived") .. " from " .. | ||
cat_name) | cat_name) | ||
end | end | ||
| Line 79: | Line 90: | ||
function export.format_source(data) | function export.format_source(data) | ||
local lang, sort_key = data.lang, data.sort_key | local lang, sort_key = data.lang, data.sort_key | ||
-- [[Special:WhatLinksHere/Wiktionary:Tracking/etymology/sortkey]] | |||
if sort_key then | |||
require("Module:debug/track")("etymology/sortkey") | |||
end | |||
local display, categories = export.insert_source_cat_get_display(data) | local display, categories = export.insert_source_cat_get_display(data) | ||
| Line 121: | Line 136: | ||
local function showLanguage(lang) | local function showLanguage(lang) | ||
local retval = ("%s (%s)"):format(lang:makeCategoryLink(), lang:getCode()) | local retval = ("%s (%s)"):format(lang:makeCategoryLink(), lang:getCode()) | ||
if lang: | if lang:hasType("etymology-only") then | ||
retval = retval .. (" (an etymology-only language whose regular parent is %s)"):format( | retval = retval .. (" (an etymology-only language whose regular parent is %s)"):format( | ||
showLanguage(lang:getParent())) | showLanguage(lang:getParent())) | ||
| Line 136: | Line 151: | ||
end | end | ||
local ancestors, postscript = lang:getAncestors() | local ancestors, postscript = lang:getAncestors() | ||
local etymModuleLink = lang: | local etymModuleLink = lang:hasType("etymology-only") and "[[Module:etymology languages/data]] or " or "" | ||
local moduleLink = "[[Module:" | local moduleLink = "[[Module:" | ||
.. require("Module:languages").getDataModuleName(lang:getFullCode()) | .. require("Module:languages").getDataModuleName(lang:getFullCode()) | ||
| Line 189: | Line 204: | ||
-- If both are the same, we want e.g. [[:Category:English terms borrowed back into English]] not | -- If both are the same, we want e.g. [[:Category:English terms borrowed back into English]] not | ||
-- [[:Category:English terms borrowed from English]]; the former is inserted automatically by format_source(). | -- [[:Category:English terms borrowed from English]]; the former is inserted automatically by format_source(). | ||
category = " terms borrowed from " .. | -- The second parameter here doesn't matter as it only affects `display`, which we don't use. | ||
local display, cat_name = export.get_display_and_cat_name(source, "raw") | |||
category = " terms borrowed from " .. cat_name | |||
end | end | ||
if category then | if category then | ||