Module:oyen-contionary-utils

From Linguifex
Revision as of 23:00, 26 November 2024 by Oyen (talk | contribs)
Jump to navigation Jump to search

Documentation for this module may be created at Module:oyen-contionary-utils/doc

local m_args = require("Module:Arguments")
local m_languages = require("Module:languages")

local m = {}

local function repl(param)
  if param == "info" then
    return mw.getContentLanguage():ucfirst("")
  end

  return "—"
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

return m