Module:descendants tree: Difference between revisions

Jump to navigation Jump to search
no edit summary
(Created page with "local export = {} local function preview_error(what, entry_name, language_name, reason) mw.log("Could not retrieve " .. what .. " for " .. language_name .. " in the entry [[" .. entry_name .. "]]: " .. reason .. ".") end local function get_content_after_senseid(content, entry_name, lang, id) local m_templateparser = require("Module:templateparser") local code = lang:getNonEtymologicalCode() local t_start = nil local t_end = nil for name, args, _, index in m_te...")
 
No edit summary
 
Line 8: Line 8:
local function get_content_after_senseid(content, entry_name, lang, id)
local function get_content_after_senseid(content, entry_name, lang, id)
local m_templateparser = require("Module:templateparser")
local m_templateparser = require("Module:templateparser")
local code = lang:getNonEtymologicalCode()
local code = lang:getCode()
local t_start = nil
local t_start = nil
local t_end = nil
local t_end = nil
Line 52: Line 52:


local function alt_form_error(reason)
local function alt_form_error(reason)
preview_error("alternative forms", entry_name, lang:getNonEtymologicalName(), reason)
preview_error("alternative forms", entry_name, lang:getCanonicalName(), reason)
end
end
Line 62: Line 62:
local _, index = string.find(content,
local _, index = string.find(content,
"==[ \t]*" .. require("Module:string").pattern_escape(lang:getNonEtymologicalName()) .. "[ \t]*==")
"==[ \t]*" .. require("Module:string").pattern_escape(lang:getCanonicalName()) .. "[ \t]*==")
if not index then
if not index then
Line 84: Line 84:
end
end


local langCodeRegex = require("Module:string").pattern_escape(lang:getNonEtymologicalCode())
local langCodeRegex = require("Module:string").pattern_escape(lang:getCode())
index = string.find(content, "{{alte?r?|" .. langCodeRegex .. "|[^|}]+", index)
index = string.find(content, "{{alte?r?|" .. langCodeRegex .. "|[^|}]+", index)
if (not index) or (next_lang and next_lang < index) then
if (not index) or (next_lang and next_lang < index) then
Line 101: Line 101:


for name, args, _, index in require("Module:templateparser").findTemplates(alternative_forms_section) do
for name, args, _, index in require("Module:templateparser").findTemplates(alternative_forms_section) do
if (name == "alt" or name == "alter") and args[1] == lang:getNonEtymologicalCode() then
if (name == "alt" or name == "alter") and args[1] == lang:getCode() then
saw_alter = true
saw_alter = true
local formatted_altforms = altforms.display_alternative_forms(args, entry_name, false, "allow self link")
local formatted_altforms = altforms.display_alternative_forms(args, entry_name, false, "allow self link")
Line 125: Line 125:


local function desc_error(reason)
local function desc_error(reason)
preview_error("descendants", entry_name, lang:getNonEtymologicalName(), reason)
preview_error("descendants", entry_name, lang:getCanonicalName(), reason)
end
end


Line 149: Line 149:
local _, index = string.find(content,
local _, index = string.find(content,
"%f[^\n%z]==[ \t]*" .. lang:getNonEtymologicalName() .. "[ \t]*==", nil, true)
"%f[^\n%z]==[ \t]*" .. lang:getCanonicalName() .. "[ \t]*==", nil, true)
if not index then
if not index then
_, index = string.find(content, "%f[^\n%z]==[ \t]*"
_, index = string.find(content, "%f[^\n%z]==[ \t]*"
.. require("Module:utilities").pattern_escape(lang:getNonEtymologicalName())
.. require("Module:utilities").pattern_escape(lang:getCanonicalName())
.. "[ \t]*==", nil, false)
.. "[ \t]*==", nil, false)
end
end
Line 172: Line 172:
"Please either change this template to {{desc}} " ..
"Please either change this template to {{desc}} " ..
"or insert a ====Descendants==== section in [[" ..
"or insert a ====Descendants==== section in [[" ..
entry_name .. "#" .. lang:getNonEtymologicalName() .. "]])</small>" ..
entry_name .. "#" .. lang:getCanonicalName() .. "]])</small>" ..
"[[Category:" .. lang:getNonEtymologicalName() .. " descendants to be fixed in desctree]]"
"[[Category:" .. lang:getCanonicalName() .. " descendants to be fixed in desctree]]"
else
else
error("No Descendants section was found in the entry [[" .. entry_name .. "]].")
error("No Descendants section was found in the entry [[" .. entry_name .. "]].")
Line 182: Line 182:
"Please either change this template to {{desc}} " ..
"Please either change this template to {{desc}} " ..
"or insert a ====Descendants==== section in [[" ..
"or insert a ====Descendants==== section in [[" ..
entry_name .. "#" .. lang:getNonEtymologicalName() .. "]])</small>" ..
entry_name .. "#" .. lang:getCanonicalName() .. "]])</small>" ..
"[[Category:" .. lang:getNonEtymologicalName() .. " descendants to be fixed in desctree]]"
"[[Category:" .. lang:getCanonicalName() .. " descendants to be fixed in desctree]]"
else
else
error("No Descendants section was found in the entry [[" .. entry_name
error("No Descendants section was found in the entry [[" .. entry_name
.. "]] under the header for " .. lang:getNonEtymologicalName() .. ".")
.. "]] under the header for " .. lang:getCanonicalName() .. ".")
end
end
end
end

Navigation menu