La documentation pour ce module peut être créée à Module:catégorie langue/Documentation
b = require('Module:bases')
l = require('Module:langues')
local p = {}
function p.categorie_langue(frame)
local args = frame:getParent().args
local cat = args or mw.title.getCurrentTitle().text
local nom_affiche = args or cat
-- number of pages in a category. Expensive function call
local pages_in_cat = mw.site.stats.pagesInCategory( cat, 'pages' )
-- objet Language utilisé pour convertir au pluriel
local fr = mw.language.new( 'fr' )
local categories = {} -- table qui contient toutes les catégories
local texte = '[[:Catégorie:' .. cat .. '|' .. fr:formatNum( pages_in_cat )
.. ' ' .. fr:convertPlural( pages_in_cat, 'entrée', 'entrées' )
.. ' en ' .. nom_affiche .. ']]'
.. ' dans le Wiktionnaire ]'
-- nocat ?
local nocat = args
if nocat then return texte end
-- ajout cat générale "Langues en <lang>"
local lang = args or 'fr'
local nom_lang = l.getName(lang)
-- ajout cats spécifiques si paramètres spéc1, ..., spéc10
local spec = args or args or args
local specNo = 1
if not spec then
local categorie = b.fait_categorie_contenu( 'Langues en ' .. nom_lang)
table.insert( categories, categorie )
else
while spec do
cat_name = 'Langues ' .. spec .. ' en ' .. nom_lang
local categorie = b.fait_categorie_contenu( cat_name )
table.insert( categories, categorie )
specNo = specNo + 1
spec = args
end
end
local texte_categories = table.concat(categories)
return texte .. texte_categories
end
return p