Va ô cuntinutu

Mòdulu:asempi

Da Wikizziunariu, lu dizziunariu a cuntinutu lìbbiru.

La ducumintazzioni di stu mòdulu si pò criari nta Mòdulu:asempi/doc

local m_params = require("Mòdulu:paràmitri")
local m_basi = require("Mòdulu:basi")
local m_langs = require("Mòdulu:lingui")
local m_unicode = require("Mòdulu:dati Unicode")
local p = {}
local function _formatExample(text, transcription, meaning, source, link, heading, lang, scriptLang, disableTranslation, frame)
  if not text then
    return mw.ustring.format(
        [=[<span class="example">''[[Aiutu:Asempi|Asempiu d’usu]] mancanti.'' <span class="plainlinks stubedit">([Agghiunciri])</span><!--
        --><bdi lang="%s" style="display: none"><!-- Etichetta pû [[MediaWiki:Gadget-wikt.add-examples]], nun livari! --></bdi></span>]=],
        mw.title.getCurrentTitle():fullUrl({ action = "edit" }), lang
    ) .. m_basi.fa_catiguria_cuntinutu(mw.ustring.format("Wiktionnaire:Asempi mancanti n %s", m_langs.get_nomu(lang)))
  end
  local italics = m_unicode.shouldItalicize(text) and "''" or ""
  local quoteTagOpen = link and mw.ustring.format('<q cite="%s">', mw.ustring.gsub(link, '"', '%%22')) or '<q>'
  text = m_unicode.setWritingDirection(text)
  if italics then
    if mw.ustring.sub(text, 1, 1) == "'" then
      text = " " .. text
    end
    if mw.ustring.sub(text, -1) == "'" then
      text = text .. " "
    end
  end
  local wikicode = quoteTagOpen .. m_basi.etichetta_lingua(italics .. text .. italics, scriptLang) .. '</q>'
  if source then
    wikicode = wikicode .. " " .. frame:expandTemplate { title = "source", args = { source, lien = link } }
  end
  wikicode = mw.ustring.format('<span class="example">%s</span>', wikicode)
  if transcription then
    wikicode = wikicode .. "<br>" .. m_basi.etichetta_lingua("''" .. transcription .. "''", scriptLang .. "-Latn")
  end
  if disableTranslation then
    wikicode = wikicode .. m_basi.fa_catiguria_cuntinutu(
        mw.ustring.format("Asempi n %s cu traduzzioni disattivata", m_langs.get_nomu(lang)))
  else
    local translation
    if meaning then
      translation = meaning
    elseif lang ~= "scn" then
      translation = "''La traduzzioni n sicilianu di l’[[Aiutu:Asempi|asempiu]] nun c'è.'' "
      translation = translation .. mw.ustring.format("<span class=\"plainlinks stubedit\">([%s%s Agghiùnciri])</span>", mw.site.server, mw.title.getCurrentTitle():localUrl("action=edit"))
      translation = translation .. mw.ustring.format("[[Catigurìa:Asempi n %s a tradùciri]]", m_langs.get_nomu(lang))
    end
    if translation then
      wikicode = wikicode .. mw.ustring.format("\n%s: ", heading) .. translation
    end
  end
  return wikicode .. m_basi.fa_catiguria_cuntinutu("Asempi n " .. m_langs.get_nomu(lang))
end
function p.formatExample(frame)
  local parentFrame = frame:getParent()
  local args, success = m_params.process(parentFrame.args, {
    [1] = {},
    ["sensu"] = {},
    [2] = { alias_of = "sensu" },
    ["tr"] = {},
    [3] = { alias_of = "tr" },
    ["funti"] = {},
    ["liami"] = {},
    ["testa"] = { default = "#*" },
    ["lingua"] = { required = true, checker = function(lang)
      return m_langs.specialCodes[lang] ~= nil or m_langs.get_nomu(lang) ~= nil
    end },
    ["nun-trad"] = { type = m_params.BOOLEAN, default = false }
  }, true)
  if success then
    local scriptLang = args["lang"]
    local lang = m_langs.specialCodes[args["lang"]] or args["lang"]
    return _formatExample(args[1], args["tr"], args["sensu"], args["funti"], args["liami"], args["testa"], lang, scriptLang, args["nun-trad"], parentFrame)
  else
    if (args[2] == m_params.MISSING_PARAM or args[2] == m_params.EMPTY_PARAM) and args[1] == "lang" then
      return "<span style='color: red; font-weight: bold;'>Lingua di l'asempiu mancannti!</span>[[Catigurìa:Chiamati ô template asempiu senza lingua nziruta]]"
    end
    error(args[3])
  end
end
return p