Module:labels: Difference between revisions

No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 55: Line 55:
["月"] = true,
["月"] = true,
}
}
-- Add tracking category for PAGE. The tracking category linked to is [[Wiktionary:Tracking/labels/PAGE]].
-- We also add to [[Wiktionary:Tracking/labels/PAGE/LANGCODE]] and [[Wiktionary:Tracking/labels/PAGE/MODE]] if
-- LANGCODE and/or MODE given.
local function track(page, langcode, mode)
if pages_where_tracking_is_disabled[SUBPAGENAME] then
return true
end
-- avoid including links in pages (may cause error)
page = page:gsub("%[", "("):gsub("%]", ")"):gsub("|", "!")
require("Module:debug/track")("labels/" .. page)
if langcode then
require("Module:debug/track")("labels/" .. page .. "/" .. langcode)
end
if mode then
require("Module:debug/track")("labels/" .. page .. "/" .. mode)
end
-- We don't currently add a tracking label for both langcode and mode to reduce the total number of labels, to
-- save some memory.
return true
end


local function ucfirst(txt)
local function ucfirst(txt)
Line 346: Line 325:
if glossary then
if glossary then
local glossary_entry = type(glossary) == "string" and glossary or label
local glossary_entry = type(glossary) == "string" and glossary or label
formatted_label = "[[Appendix:Glossary#" .. glossary_entry .. "|" .. display .. "]]"
formatted_label = "[[wikt:Appendix:Glossary#" .. glossary_entry .. "|" .. display .. "]]"
elseif Wiktionary then
elseif Wiktionary then
formatted_label = "[[" .. Wiktionary .. "|" .. display .. "]]"
formatted_label = "[[wikt:" .. Wiktionary .. "|" .. display .. "]]"
elseif Wikipedia then
elseif Wikipedia then
local Wikipedia_entry = type(Wikipedia) == "string" and Wikipedia or label
local Wikipedia_entry = type(Wikipedia) == "string" and Wikipedia or label
Line 517: Line 496:
label = resolved_label or label
label = resolved_label or label
break
break
elseif not data.notrack then
-- Track use of a label that fails the lang restriction.
-- [[Special:WhatLinksHere/Wiktionary:Tracking/labels/wrong-lang-label]]
-- [[Special:WhatLinksHere/Wiktionary:Tracking/labels/wrong-lang-label/LANGCODE]]
-- [[Special:WhatLinksHere/Wiktionary:Tracking/labels/wrong-lang-label/LABEL]]
-- [[Special:WhatLinksHere/Wiktionary:Tracking/labels/wrong-lang-label/LABEL/LANGCODE]]
track("wrong-lang-label", data_langcode)
track("wrong-lang-label/" .. label, data_langcode)
if resolved_label then
track("wrong-lang-label/" .. resolved_label, data_langcode)
end
end
end
end
end
Line 547: Line 515:
-- Note that this is an alias and store the canonical version.
-- Note that this is an alias and store the canonical version.
ret.canonical = label
ret.canonical = label
end
if not data.notrack then -- labprop("track") then -- track all labels now
-- Track label (after converting aliases to canonical form; but also track raw label (alias) if different
-- from canonical label).
-- [[Special:WhatLinksHere/Wiktionary:Tracking/labels/label/LABEL]]
-- [[Special:WhatLinksHere/Wiktionary:Tracking/labels/label/LABEL/LANGCODE]]
-- [[Special:WhatLinksHere/Wiktionary:Tracking/labels/label/LABEL/MODE]]
track("label/" .. label, data_langcode, mode)
if label ~= non_canonical then
track("label/" .. non_canonical, data_langcode, mode)
end
end
end