Utilisateur:WikiLucas00/Bac à sable

fonction pron_reg(frame) du Module:prononciation modifier

function export.pron_reg(frame)
  local params = {
    [1] = { default = '<small>(Région à préciser)</small>' },
    [2] = {},
    [3] = { required = true },
    [4] = {},
    ["pron"] = { alias_of = 2 },
    ["lang"] = { alias_of = 3 },
    ["niveau"] = { alias_of = 4 },
    ["audio"] = {},
    ["titre"] = { default = mw.title.getCurrentTitle().text },
  }
  local args = m_params.process(frame:getParent().args, params)
  local country = args[1]
  local pron = args[2]
  local lang_code = args[3]
  local level = args[4]
  local audio_file = args["audio"]
  local title = args["titre"]


  -- Génération du wikicode
  local text = country .. ' : '

  if pron or audio_file then
    if audio_file and audio_file ~= '' then
      text = text .. 'écouter « ' .. title
      if lang_code and mw.title.getCurrentTitle().namespace == 0 then
        local lang_name = m_langues.get_nom(lang_code)
        if lang_name then
          text = text .. '[[Catégorie:Prononciations audio en ' .. lang_name .. ']]'
        else
          text = text .. '[[Catégorie:Prononciations audio sans langue précisée]]'
        end
      end
      text = text .. ' ' .. export.lua_pron(pron, lang_code, level, '[]', true)
      text = text .. ' »[[File:' .. audio_file .. ']]'
    else
      text = text .. export.lua_pron(pron, lang_code, level, '[]', true)
    end
  else
    text = text .. '<small>merci de préciser une prononciation phonétique ou un fichier audio (voir la [[Modèle:écouter|notice]])</small>'
  end

  return text
end