45,647
edits
No edit summary |
Tag: Undo |
||
Line 1: | Line 1: | ||
local m_labeldata = mw.loadData("Module:labels/data") | local m_labeldata = mw.loadData("Module:labels/data") | ||
local m_utilities = require("Module:utilities") | |||
local m_links = require("Module:links") | |||
local | |||
local export = {} | local export = {} | ||
Line 55: | Line 54: | ||
end | end | ||
return | return m_utilities.format_categories(categories, lang, sort_key, nil, force_cat) .. | ||
m_utilities.format_categories(categories2, lang, sort_key2, nil, force_cat) | |||
end | end | ||
Line 64: | Line 63: | ||
local categories = "" | local categories = "" | ||
local alias | local alias | ||
if m_labeldata.deprecated[label] then | |||
deprecated = true | deprecated = true | ||
end | end | ||
if | if m_labeldata.aliases[label] then | ||
alias = label | alias = label | ||
label = | label = m_labeldata.aliases[label] | ||
end | end | ||
if | if m_labeldata.deprecated[label] then | ||
deprecated = true | deprecated = true | ||
end | |||
local data = m_labeldata.labels[label] or {} | |||
--[=[ | |||
Do not use the data in the table if the current language | |||
is not in the "languages" list. | |||
If the original label was an alias, and was redirected to a label | |||
with a data file, go back to the original label. | |||
For example, suppose the label "Rome" is used with the language code "en" (English). | |||
"Rome" redirects to "Romanesco" in [[Module:labels/data/regional]]. | |||
The only language in the "languages" list is "it" (Italian). | |||
Because the language code provided to the template was not "it", | |||
the label's data file will not be used, | |||
and the label will display as "Rome". | |||
tracking: [[Special:WhatLinksHere/Template:tracking/labels/incorrect-language]] | |||
[[Special:WhatLinksHere/Template:tracking/labels/redirect-undone]] | |||
]=] | |||
if data.languages then | |||
local lang_code = lang:getCode() | |||
if not data.languages[lang_code] then | |||
mw.log("incorrect language in label template " .. lang_code .. ":" .. label) | |||
if alias and label ~= alias then | |||
mw.log("redirect undone in label template " .. lang_code .. ":" .. label .. " > " .. alias) | |||
label = alias | |||
end | |||
data = {} | |||
end | |||
end | end | ||
Line 119: | Line 133: | ||
if data.glossary then | if data.glossary then | ||
local glossary_entry = type(data.glossary) == "string" and data.glossary or label | local glossary_entry = type(data.glossary) == "string" and data.glossary or label | ||
label = "[[Appendix:Glossary#" .. glossary_entry .. "|" .. ( data.display or label ) .. "]]" | label = "[[wikt:Appendix:Glossary#" .. glossary_entry .. "|" .. ( data.display or label ) .. "]]" | ||
elseif data.Wikipedia then | elseif data.Wikipedia then | ||
Wikipedia_entry = type(data.Wikipedia) == "string" and data.Wikipedia or label | Wikipedia_entry = type(data.Wikipedia) == "string" and data.Wikipedia or label | ||
Line 131: | Line 145: | ||
label = '<span class="deprecated-label">' .. label .. '</span>' | label = '<span class="deprecated-label">' .. label .. '</span>' | ||
if not nocat then | if not nocat then | ||
categories = categories .. | categories = categories .. m_utilities.format_categories({ "Entries with deprecated labels" }, lang, sort_key, nil, force_cat) | ||
end | end | ||
end | end | ||
Line 199: | Line 213: | ||
label = "" | label = "" | ||
else | else | ||
label = (omit_comma and "" or '<span class="ib-comma">,</span>') .. | label = (omit_comma and "" or '<span class="ib-comma" style="font-style: normal;">,</span>') .. | ||
(omit_space and "" or " ") .. | (omit_space and "" or " ") .. | ||
ret.label | ret.label | ||
Line 207: | Line 221: | ||
return | return | ||
"<span class=\"ib-brac\">(</span><span class=\"ib-content\">" .. | "<span class=\"ib-brac\">(</span><span class=\"ib-content\" style=\"font-style: italic;\">" .. | ||
table.concat(labels, "") .. | table.concat(labels, "") .. | ||
"</span><span class=\"ib-brac\">)</span>" | "</span><span class=\"ib-brac\">)</span>" |