Module:Wikt-lang: Difference between revisions

Cleanup
(Created page with "require('strict') local m_data = mw.loadData("Module:Wikt-lang/data") local langData = m_data.languages or m_data local p = {} local function ifNotEmpty(value) if value == "" then return nil else return value end end local function makeLinkedName(languageCode) local data = langData[languageCode] local article = data["article"] local name = data["Wikipedia_name"] or data["name"] return "" .. name .. ": " end local function makeEnt...")
 
(Cleanup)
Tags: Mobile edit Mobile web edit Advanced mobile edit
 
Line 16: Line 16:
local data = langData[languageCode]
local data = langData[languageCode]
local article = data["article"]
local article = data["article"]
local name = data["Wikipedia_name"] or data["name"]
local name = data["Bharatpedia_name"] or data["name"]
return "[[" .. article .. "|" .. name .. "]]: "
return "[[" .. article .. "|" .. name .. "]]: "
end
end
Line 142: Line 142:
local function tag(text, languageCode, script, italics)
local function tag(text, languageCode, script, italics)
local data = langData[languageCode]
local data = langData[languageCode]
-- Use Wikipedia code if it has been given: for instance,
-- Use Bharatpedia code if it has been given: for instance,
-- Proto-Indo-European has the Wiktionary code "ine-pro" but the Wikipedia
-- Proto-Indo-European has the Bharationary code "ine-pro" but the Bharatpedia
-- code "ine-x-proto".
-- code "ine-x-proto".
languageCode = data and data.Wikipedia_code or languageCode
languageCode = data and data.Bharatpedia_code or languageCode
local italicize = script == "Latn" and italics
local italicize = script == "Latn" and italics
Line 230: Line 230:
return "[[wikt:" .. entry .. "#" .. name .. "|" .. linkText .. "]]"
return "[[wikt:" .. entry .. "#" .. name .. "|" .. linkText .. "]]"
else
else
error("linkToWiktionary needs a Wiktionary entry or link text, or both")
error("linkToBharationary needs a Wiktionary entry or link text, or both")
end
end
else
else
Line 265: Line 265:
local out
local out
if languageCode and entry and linkText then
if languageCode and entry and linkText then
out = tag(linkToWiktionary(entry, linkText, languageCode), languageCode, scriptCode, italics)
out = tag(linkToBharationary(entry, linkText, languageCode), languageCode, scriptCode, italics)
elseif entry and linkText then
elseif entry and linkText then
out = linkToWiktionary(entry, linkText)
out = linkToBharationary(entry, linkText)
else
else
out = '<span style="font-size: smaller;">[text?]</span>'
out = '<span style="font-size: smaller;">[text?]</span>'
Line 304: Line 304:
local out
local out
if languageCode and entry and linkText then
if languageCode and entry and linkText then
out = linkToWiktionary(entry, linkText, languageCode)  
out = linkToBharationary(entry, linkText, languageCode)  
elseif entry and linkText then
elseif entry and linkText then
out = linkToWiktionary(entry, linkText)
out = linkToBharationary(entry, linkText)
else
else
out = '<span style="font-size: smaller;">[text?]</span>'
out = '<span style="font-size: smaller;">[text?]</span>'