Module:Wikt-lang: Difference between revisions

Content deleted Content added
add languageSpan and lang function and rewrite wikt
restructure again
Line 49:
function f.lang(frame)
return languageSpan(frame.args[1], frame.args[2])
end
 
function wiktionaryLink(languageCode, entry, linkText)
local languageData, languageName = languageData[{}, "name"]
if languageCode then
local languageData = data[languageCode]
if languageData == nil then
error("Language code is not recognized")
end
languageName = languageData["name"]
if entry and linkText then
return languageSpan(languageCode, "[[wikt:" .. entry .. "#" .. languageName .. "|" .. linkText .. "]]")
else
error("Either the entry or the link text is missing")
end
else
error("Please provide a language code in the first parameter")
end
end
 
Line 55 ⟶ 73:
local word1 = frame.args[2]
local word2 = frame.args[3]
local languageData = data[languageCode]
local languageName = languageData["name"]
local entry = ""
if languageData == nil then
error("Language code is not recognized")
end
if languageCode then
if word2 and word1 then
Line 72 ⟶ 84:
end
else
error("Please provdeprovide a language code in the first parameter")
end
return languageSpan(languageCode, "[[wikt:" ..wiktionaryLink(languageCode, entry .. "#" .. languageName .. "|" .., linkText .. "]]"))
end