La documentation pour ce module peut être créée à Module:régions/Documentation
m_bases = require('Module:bases')
m_lang = require('Module:langues')
m_table = require('Module:table')
local tree = mw.loadData('Module:régions/data')
local p = {}
function p.categorisation_region_interlangue(frame)
local region = string.match(tostring(mw.title.getCurrentTitle()), "Catégorie:(.+)")
local region_data = tree
if region_data ~= nil then
local cs = region_data .. "\n"
if region_data ~= nil then
cs = cs .. ") .. "]]"
end
return cs
else
return "]"
end
end
function p.categorisation_region(frame)
local args = frame:getParent().args
local lang_code = args or nil
local title = string.match(tostring(mw.title.getCurrentTitle()), "Catégorie:(.+)")
local region, lang = string.match(title, "(.+) en (.+)")
if c1 ~= nil and c2 ~= nil and lang ~= nil and m_lang.code_de_langue({args={lang}}) ~= '' and subject ~= nil then
local cs = ""
if tree ~= nil then
local det = nil
if tree == 'du ' then
det = 'le '
elseif tree == 'de la ' then
det = 'la '
elseif tree == 'des ' then
det = 'les '
elseif tree == 'de l’' then
det = 'l’'
end
cs = "Cette page liste les mots en ] en rapport avec " .. det .. "].\n\n" .. tree .. "\n\n"
if tree ~= nil then
local lang_code = m_cdl.code_de_langue({args={lang}})
local template = tree
local template_link = template .. "|" .. template .. "]]|" .. lang_code
cs = cs .. "Pour ajouter une entrée à cette catégorie, utilisez le modèle <code>{{[[Modèle:" .. template_link .. "}}</code>.\n"
end
if tree ~= nil then
for k, v in pairs(tree) do
if tree ~= nil then
cs = cs .. " .. v .. "|".. subject .."]]"
else
cs = cs .. "]"
end
end
end
else
cs = "]"
end
return cs .. "]]"
else
return "]"
end
end
function p.lexique_nocat(frame)
return p.lexique(frame, true)
end
function p.lexique(frame, nocat)
nocat = nocat or false
-- Analyse des arguments
local args = frame:getParent().args
local tableLen = m_table.length(args)
if nocat then
if tableLen < 1 then
return ]
end
else
if tableLen < 2 then
return ]
end
end
local lexicons = {}
local last = nil
for i, arg in ipairs(args) do
if last ~= nil then
table.insert(lexicons, last)
end
last = arg
end
local lang_code = nil
local lang = nil
if nocat then
table.insert(lexicons, last)
else
lang_code = last
lang = m_lang.get_nom(lang_code)
end
local text = ""
local cs = ""
if not nocat and lang == nil then
return ] .. lang_code .. ] .. "]"
end
local filtered_lexicons = {}
for i, lexicon in ipairs(lexicons) do
if tree ~= nil then
table.insert(filtered_lexicons, ] .. tree .. ] .. (not nocat and m_bases.ucfirst(lexicon) or lexicon) .. ])
if tree ~= nil then
if not nocat then
cs = cs .. " .. lexicon .. "]]"
end
else
cs = cs .. "]"
end
else
table.insert(filtered_lexicons, ] .. lexicon .. ])
cs = cs .. "]"
end
end
if next(filtered_lexicons) ~= nil then
text ="(" .. table.concat(filtered_lexicons, ", ") .. ")"
end
return text .. cs
end
return p