12,303
edits
TheNightAvl (talk | contribs) mNo edit summary |
TheNightAvl (talk | contribs) No edit summary |
||
(9 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
function export.show(frame) | function export.show(frame) | ||
local function sort_function(a, b) | local function sort_function(a, b) | ||
return a.name < b.name | return a.name < b.name | ||
Line 17: | Line 14: | ||
local language = m_languages.get_by_code(args[1]) | local language = m_languages.get_by_code(args[1]) | ||
local title = args[2] or args["title"] or args["t"] | local title = args[2] or args["title"] or args["t"] | ||
local nocat = args["nocat"] ~= nil or false | |||
if title then title = string.gsub(title, "%s+$", "") end | if title then title = string.gsub(title, "%s+$", "") end | ||
for k, v in pairs(args) do | for k, v in pairs(args) do | ||
if type(k) == "string" and type(v) == "string" then | if type(k) == "string" and k ~= "nocat" and type(v) == "string" then | ||
local tr_language = m_languages.get_by_code(k) | local tr_language = m_languages.get_by_code(k) | ||
local to_process = v | local to_process = v | ||
Line 28: | Line 26: | ||
local pre = mw.ustring.match(to_process, "^([^%*]+)%*") or "" | local pre = mw.ustring.match(to_process, "^([^%*]+)%*") or "" | ||
local translink = mw.ustring.match(to_process, "%*([^%*]+)%*") | local translink = mw.ustring.match(to_process, "%*([^%*]+)%*") | ||
local translink_alt | |||
to_process = mw.ustring.sub(to_process, mw.ustring.len(pre) + mw.ustring.len(translink) + 3) | to_process = mw.ustring.sub(to_process, mw.ustring.len(pre) + mw.ustring.len(translink) + 3) | ||
translink = m_links.full_link{term = translink, language = tr_language, nobold = true} | |||
if mw.ustring.find(translink, "[^%:]+%:[^%:]+") then | |||
translink_alt, translink = mw.ustring.match(translink, "([^%:]+)%:([^%:]+)") | |||
else | |||
translink_alt = nil | |||
end | |||
translink = m_links.full_link{term = translink, alt = translink_alt, language = tr_language, nobold = true} | |||
bytext = bytext .. pre .. translink | bytext = bytext .. pre .. translink | ||
else | else | ||
Line 49: | Line 56: | ||
out = out .. '\n|-' | out = out .. '\n|-' | ||
out = out .. '\n| bgcolor="beige" valign="top" width="48%" |' | out = out .. '\n| bgcolor="beige" valign="top" width="48%" |' | ||
for _, n in ipairs(translations) do out = out .. '\n* ' .. n.display .. "[[Category:" .. language.name .. " terms with " .. n.name .. " translations]]" end | for _, n in ipairs(translations) do out = out .. '\n* ' .. n.display .. "[[Category:" .. language.name .. " terms with " .. n.name .. " translations|" .. mw.title.getCurrentTitle().subpageText .. "]]" end | ||
out = out .. '\n|}' | out = out .. '\n|}' | ||
out = out .. '\n</div></div>[[Category:' .. language.name .. ' terms with translations]]' | out = out .. '\n</div></div>[[Category:' .. language.name .. ' terms with translations|' .. mw.title.getCurrentTitle().subpageText .. ']]' | ||
end | end | ||
for _, lang in ipairs(tag_missing) do | for _, lang in ipairs(tag_missing) do | ||
if lang ~= language.code and args[lang] == nil then | if lang ~= language.code and args[lang] == nil then | ||
out = out .. "[[Category:" .. | out = out .. "[[Category:Terms needing " .. m_languages.get_by_code(lang).name .. " translations|" .. mw.title.getCurrentTitle().subpageText .. "]]" | ||
end | end | ||
end | end | ||
if nocat then out = string.gsub(out, "%[%[Category[^%]]+%]%]", "") end | |||
return out | return out | ||
end | end | ||
return export | return export |