10,731
edits
No edit summary |
TheNightAvl (talk | contribs) mNo edit summary |
||
Line 2: | Line 2: | ||
local m_languages = require("Module:languages") | local m_languages = require("Module:languages") | ||
local m_links = require("Module:links") | |||
function export.show(frame) | function export.show(frame) | ||
Line 13: | Line 14: | ||
if k == 1 then | if k == 1 then | ||
title = string.gsub(v, "%s+$", "") | title = string.gsub(v, "%s+$", "") | ||
elseif type(k) == "string" then | elseif type(k) == "string" and type(v) == "string" then | ||
local language = m_languages.get_by_code(k) | local language = m_languages.get_by_code(k) | ||
table.insert(translations, {name = language.name, display = language.name .. ": " .. | -- m_links.full_link{term = word, language = m_languages.get_by_code("rad")} -- | ||
-- divide v into pieces in order to be linked -- | |||
local to_process = v | |||
local bytext = "" | |||
while #to_process > 0 do | |||
if mw.ustring.match(to_process, "%*[^%*]+%*") then | |||
local pre = mw.ustring.gmatch(to_process, "^([^%*]+)%*") | |||
local link = mw.ustring.gmatch(to_process, "%*([^%*]+)%*") | |||
bytext = bytext .. pre .. m_links.full_link{term = link, language = language} | |||
to_process = mw.ustring.sub(to_process, mw.ustring.len(pre) + mw.ustring.len(link) + 2) | |||
else | |||
bytext = bytext .. to_process | |||
to_process = "" | |||
end | |||
end | |||
table.insert(translations, {name = language.name, display = language.name .. ": " .. bytext}) | |||
end | end | ||
end | end |