Module:étymologie

Bonjour, vous êtes venu ici pour chercher la signification du mot Module:étymologie. Dans DICTIOUS, vous trouverez non seulement toutes les significations du dictionnaire pour le mot Module:étymologie, mais vous apprendrez également son étymologie, ses caractéristiques et comment dire Module:étymologie au singulier et au pluriel. Tout ce que vous devez savoir sur le mot Module:étymologie est ici. La définition du mot Module:étymologie vous aidera à être plus précis et correct lorsque vous parlerez ou écrirez vos textes. Connaître la définition deModule:étymologie, ainsi que celles d'autres mots, enrichit votre vocabulaire et vous fournit des ressources linguistiques plus nombreuses et de meilleure qualité.

La documentation pour ce module peut être créée à Module:étymologie/Documentation

-- <nowiki>
local m_bases = require('Module:bases')
local m_params = require('Module:paramètres')
local m_langues = require('Module:langues')
local m_table = require('Module:table')
local m_Unicode_data = require('Module:données Unicode')

local checkLang = function(langCode)
  return m_langues.get_nom(langCode) ~= nil
end

local p = {}

--- Function for templates {{sigle}}, {{abréviation}}, {{acronyme}}, etc.
---  frame.args (string) : Etymological process’ name (sigle, verlan, etc.).
---  frame.args (string, optional) : Plural form of previous parameter.
---   If not present, an "s" will be appended to the first parameter.
---  frame.args (string, optional) : Source word.
---  frame.args (string, optional) : Second source word.
---  frame.args (string, optional) : Source word transcription.
---  frame.args (string, optional) : Second source word transcription.
---  frame.args (string, optional) : Source word sense.
---  frame.args (string, optional) : Second source word sense.
---  frame.args (string, optional) : Source word link nature anchor.
---  frame.args (string, optional) : Second source word link nature anchor.
---  frame.args (string, optional) : Text to show in place of source word.
---  frame.args (string, optional) : Text to show in place of second source word.
---  frame.args (string, required if nocat is false) : An adjective to add between words “terme” and “de”.
---  frame.args (string, required if nocat is false) : Language code of target word.
---  frame.args (string, optional) : Language code of source word(s).
---   If not present, lang parameter will be used instead.
---  frame.args (string, optional) : If true, the first word’s initial letter will be in upper case.
---  frame.args (booléen, optional) : If true, no link will be created to the source word(s).
---  frame.args (booléen, optional) : If true, no category will be inserted.
---  frame.args (string, optional) : Sort key for the categories.
---  frame.args (string, optional) : First category name.
---  frame.args (string, optional) : Second category name.
--- @return string Template’s text and relevant categories.
function p.templateEtymologyConstruction(frame)
  local params = {
     = { required = true },
     = {},
     = {},
     = {},
     = {},
     = { alias_of = 'tr' },
     = {},
     = { alias_of = 'tr2' },
     = {},
     = {},
     = {},
     = {},
     = {},
     = {},
     = {},
     = { checker = checkLang },
     = { alias_of = 'lang' },
     = { checker = checkLang },
     = { type = m_params.BOOLEAN, default = false },
     = { type = m_params.BOOLEAN, default = false },
     = { type = m_params.BOOLEAN, default = false },
     = { default = mw.title.getCurrentTitle().text },
     = {},
     = {},
  }
  local args = m_params.process(frame.args, params)
  local term = args
  local termPlural = args or (term .. "s")
  local caps = args
  local from = args
  local from2 = args
  local transcription = args
  local transcription2 = args
  local meaning = args
  local meaning2 = args
  local code = args
  local code2 = args
  local text = args or from
  local text2 = args or from2
  local adj = args
  local noLink = args
  local noCategorization = args
  local lang = args
  local linkLang = args or (lang or "fr")
  local sortingKey = args
  local category = args
  local category2 = args

  local res = mw.ustring.format("]", term, caps and m_bases.ucfirst(term) or term)

  if code then
    linkLang = linkLang .. '-' .. code
  end

  -- TODO call {{lien}} instead of reinventing it
  local format = function(baseWord, replacementText, baseString, additionalText, transcription, meaning)
    if baseWord then
      local word
      if noLink then
        word = baseWord
      else
        word = mw.ustring.format("]", baseWord, linkLang, replacementText)
      end

      baseString = baseString .. mw.ustring.format(additionalText .. " de ''%s''", word)
    end

    if transcription then
      if baseString == '' then
        baseString = mw.ustring.format("''%s''", transcription)
      else
        baseString = mw.ustring.format("%s, ''%s''", baseString, transcription)
      end
    end

    if meaning then
      if baseString == '' then
        baseString = mw.ustring.format('(«&nbsp;%s&nbsp;»)', meaning)
      else
        baseString = mw.ustring.format('%s («&nbsp;%s&nbsp;»)', baseString, meaning)
      end
    end

    return baseString
  end

  local getCategory = function(cat_name)
    return m_bases.ucfirst(cat_name) .. " " ..
        (lang and "en " .. m_langues.get_nom(lang) or "sans langue précisée")
  end

  res = format(from, text, res, adj and (" " .. adj) or "")
  res = format(from2, text2, res, " et", transcription, meaning)

  if noCategorization then
    return res
  else
    local categoryName
    if category then
      categoryName = category
    else
      if lang == nil then
        error("Code de langue manquant")
      end
      categoryName = getCategory(termPlural)
    end
    res = res .. m_bases.fait_categorie_contenu(categoryName, sortingKey)

    if category2 then
      if lang == nil then
        error("Code de langue manquant")
      end
      categoryName = getCategory(category2)
      res = res .. m_bases.fait_categorie_contenu(categoryName, sortingKey)
    end

    return res
  end
end

-- Various latin codes accepted by {{étyl}}.
local LATIN_CODES = {
  'bas latin',
  'gallo-roman',
  'latin archaïque',
  'latin classique',
  'latin contemporain',
  'latin ecclésiastique',
  'latin humaniste',
  'latin impérial',
  'latin médiéval',
  'latin populaire',
  'latin tardif',
  'latin vulgaire',
  'néolatin',
}


local function getLanguageCode(langCode)
  return m_table.contains(LATIN_CODES, langCode) and 'la' or langCode
end

local function checkLangExtended(langCode)
  return checkLang(getLanguageCode(langCode))
end
local function getLanguageName(langCode)
  return m_table.contains(LATIN_CODES, langCode) and langCode or m_langues.get_nom(langCode)
end

local function italicIfLatinScript(text)
  return m_Unicode_data.shouldItalicize(text) and mw.ustring.format("''%s''", text) or text
end

--- Function for template {{étyl}}. If at least one of the two languages is unknown or missing,
--- an error message is displayed in place of the text and the category
--- ] is inserted.
---  frame.args (string) : Source language code.
---  frame.args (string) : Target language code.
---  frame.args (string, optional) : Source word.
---  frame.args (string, optional) : Transcription of source word.
---  frame.args (string, optional) : Meaning of source word.
---  frame.args (string, optional) : Text to show instead of the source word.
---  frame.args (string, optional) : Section code in source word’s page.
---  frame.args (int, optional) : Section number in source word’s page.
---  frame.args (boolean, optional) : If true and no errors are found, no categories will be returned.
---  frame.args (boolean, optinal) : If true, inserts a link to the source language.
--- @return string Template’s text and relevant categories.
function p.templateEtyl(frame)
  local args = m_params.process(frame:getParent().args, {
     = {},
     = {},
     = {},
     = { alias_of = 'mot' },
     = {},
     = { alias_of = 'tr' },
     = { alias_of = 'tr' },
     = {},
     = { alias_of = 'sens' },
     = {},
     = {},
     = { type = m_params.INT, checker = function(n)
      return n > 0
    end },
     = { type = m_params.BOOLEAN, default = false },
     = { type = m_params.BOOLEAN, default = false },
  })

  local originLang = args
  local destLang = args
  local word = args
  local transcription = args
  local meaning = args
  local alternativeText = args
  local anchorSection = args
  local anchorNum = args
  local noCat = args
  local linkToLang = args

  if not checkLangExtended(originLang) or (not noCat and not checkLangExtended(destLang)) then
    return '<span style="color:red">Erreur modèle étyl&nbsp;: langue inconnue ou absente</span>' ..
        m_bases.fait_categorie_contenu('Wiktionnaire:Modèle étyl sans langue précisée')
  end

  local categories = ''
  local content = ''
  local anchor = ''
  local originLangName = getLanguageName(originLang)
  local destLangName = getLanguageName(destLang)
  local displayedLang = linkToLang and m_bases.lien_modele(originLangName, 'fr') or originLangName

  content = ''
  if word then
    if anchorSection then
      anchor = anchorSection
    end
    if anchorNum then
      anchor = anchor .. '-' .. tostring(anchorNum)
    end

    content = italicIfLatinScript(m_bases.lien_modele(word, getLanguageCode(originLang), anchor, alternativeText, true))
  end

  if transcription then
    if content == '' then
      content = mw.ustring.format("''%s''", transcription)
    else
      content = mw.ustring.format("%s, ''%s''", content, transcription)
    end
  end
  if meaning then
    if content == '' then
      content = mw.ustring.format('(«&nbsp;%s&nbsp;»)', meaning)
    else
      content = mw.ustring.format('%s («&nbsp;%s&nbsp;»)', content, meaning)
    end
  end

  if content == '' then
    content = displayedLang
  else
    content = mw.ustring.format('%s %s', displayedLang, content)
  end

  if not noCat then
    if originLang == destLang then
      categories = categories .. m_bases.fait_categorie_contenu('Appels de modèles incorrects:étyl')
    elseif originLang == 'onom' then
      categories = categories .. m_bases.fait_categorie_contenu(mw.ustring.format(
          'Mots en %s issus d’une onomatopée',
          destLangName
      ))
    else
      categories = categories .. m_bases.fait_categorie_contenu(mw.ustring.format(
          'Mots en %s issus d’un mot en %s',
          destLangName,
          originLangName
      ))
    end
  end

  return content .. categories
end

--- Function for template {{lien-ancre-étym}}.
---  frame.args (string) : Language code.
---  frame.args (string) : Section ID.
---  frame.args (int, optional) : Section’s number.
---  frame.args (int, optional) : Whether the target section is a locution. Changes the displayed text.
--- @return string Template’s text.
function p.templateLienAncreEtym(frame)
  local wordTypes = mw.loadData("Module:types de mots/data")
  local args = m_params.process(frame:getParent().args, {
     = { required = true, checker = checkLang },
     = { required = true, checker = function(v)
      return wordTypes ~= nil or wordTypes ~= nil
    end },
     = { type = m_params.INT, checker = function(v)
      return v > 0
    end },
     = { type = m_params.BOOLEAN, default = false },
  })
  local langCode = args
  local wordTypeData = wordTypes] or args]
  local locution = args and wordTypeData ~= nil
  local text = wordTypeData
  local number = args
  local anchor = langCode .. "-" .. wordTypeData .. (number ~= nil and ("-" .. tostring(number)) or "")
  text = m_bases.ucfirst(text)
  if number ~= nil then
    text = text .. " " .. tostring(number)
  end

  return mw.ustring.format("''(])''", anchor, text)
end

return p
-- </nowiki>