Module:oyen-contionary-utils: Difference between revisions
Jump to navigation
Jump to search
m (debugging #2) |
No edit summary |
||
(26 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
--Broken as templates don't invoke from lua module | |||
local m_args = require("Module:Arguments") | local m_args = require("Module:Arguments") | ||
local m_languages = require("Module:languages") | local m_languages = require("Module:languages") | ||
Line 4: | Line 6: | ||
local m = {} | local m = {} | ||
function m. | function m.latin(frame) | ||
local args = m_args.getArgs(frame) | |||
local v,c = args[1]:gsub("[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZḿńŕĺĹ]+", "") | |||
return v | |||
end | |||
function m.setup_entry(frame) | |||
local args = m_args.getArgs(frame) | |||
local lang_code = args[1] | |||
local lang = m_languages.getByCode(lang_code, nil, false, false) | |||
if not lang then | if not lang then | ||
error(string.format("Invalid language code ' | error(string.format("Invalid language code '%s'"), lang_code) | ||
end | end | ||
Line 17: | Line 29: | ||
local mw_src = "" | local mw_src = "" | ||
mw_src = mw_src | mw_src = mw_src .. string.format("<h2>%s</h2>", lang:getCanonicalName()) | ||
if reconstructed then | if reconstructed then | ||
mw_src = mw_src | mw_src = mw_src .. "{{Reconstructed}}" | ||
end | end | ||
return mw_src | return mw_src | ||
end | end | ||
function m.entry(frame) | |||
local | local args = m_args.getArgs(frame) | ||
local word_type = args[1] | |||
local mw_src = "" | |||
mw_src = mw_src .. string.format("<h3>%s</h3>", word_type) | |||
mw_src = mw_src .. "<b>{{PAGENAME}}</b><br>" | |||
return mw_src | return mw_src | ||
end | end | ||
function m. | function m.descendant(frame) | ||
local args = m_args.getArgs(frame) | |||
local lang_code = args[1] | |||
local word = args[2] | |||
local lang = m_languages.getByCode(lang_code, nil, false, false) | |||
if not lang then | |||
error(string.format("Invalid language code '%s'"), lang_code) | |||
end | |||
local canon_lang_name = lang:getCanonicalName() | |||
return '<span class="desc-arr" title="borrowed">→</span> ' .. canon_lang_name .. ": " .. '<span class="Latn" lang="lthm-pro">[[Contionary:' .. word .. "#" .. canon_lang_name .. "|*" .. word .. "]]</span>" | |||
end | end | ||
return m | return m |
Latest revision as of 18:20, 8 December 2024
Documentation for this module may be created at Module:oyen-contionary-utils/doc
--Broken as templates don't invoke from lua module
local m_args = require("Module:Arguments")
local m_languages = require("Module:languages")
local m = {}
function m.latin(frame)
local args = m_args.getArgs(frame)
local v,c = args[1]:gsub("[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZḿńŕĺĹ]+", "")
return v
end
function m.setup_entry(frame)
local args = m_args.getArgs(frame)
local lang_code = args[1]
local lang = m_languages.getByCode(lang_code, nil, false, false)
if not lang then
error(string.format("Invalid language code '%s'"), lang_code)
end
local reconstructed = lang:getTypes()["reconstructed"]
local mw_src = ""
mw_src = mw_src .. string.format("<h2>%s</h2>", lang:getCanonicalName())
if reconstructed then
mw_src = mw_src .. "{{Reconstructed}}"
end
return mw_src
end
function m.entry(frame)
local args = m_args.getArgs(frame)
local word_type = args[1]
local mw_src = ""
mw_src = mw_src .. string.format("<h3>%s</h3>", word_type)
mw_src = mw_src .. "<b>{{PAGENAME}}</b><br>"
return mw_src
end
function m.descendant(frame)
local args = m_args.getArgs(frame)
local lang_code = args[1]
local word = args[2]
local lang = m_languages.getByCode(lang_code, nil, false, false)
if not lang then
error(string.format("Invalid language code '%s'"), lang_code)
end
local canon_lang_name = lang:getCanonicalName()
return '<span class="desc-arr" title="borrowed">→</span> ' .. canon_lang_name .. ": " .. '<span class="Latn" lang="lthm-pro">[[Contionary:' .. word .. "#" .. canon_lang_name .. "|*" .. word .. "]]</span>"
end
return m