Modulo:Fumetto e animazione/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
riscrivo
Omega Bot (discussione | contributi)
m Bot: rimuovo no globals obsoleto
 
(54 versioni intermedie di un altro utente non mostrate)
Riga 3:
le funzioni di categorizzazione automatica
]]
 
local p = {}
require('strict')
 
local cfg = mw.loadData("Modulo:Fumetto e animazione/Configurazione/sandbox")
local getArgs = require('Module:Arguments').getArgs
local mDelink = require('Modulo:Delink')
local error_category = 'Errori di compilazione del template Fumetto e animazione'
 
-- =============================================================================
local function build_reverse_alias(table_name)
-- Funzioni di utilità
local reverse_alias = {}
-- =============================================================================
for alias, name in pairs(cfg['alias_' .. table_name]) do
 
if not reverse_alias[name] then reverse_alias[name] = {} end
-- Converte la lettera iniziale di una stringa in maiuscola
table.insert(reverse_alias[name], alias)
local function ucfirst(str)
end
return reverse_aliasstr:gsub('^%l', string.upper)
end
 
-- Restituisce un valore senza eventuale wikilink a inizio stringa
-- ========================================================================
local function delink(value)
-- Sostituisce name con il suo alias se presente nella tabella alias
if not value then return end
-- quindi ritorna il valore corrispondente dalla tabella values
local pattern
-- ========================================================================
if value:find('|') then
local function get_category(name, table_name, delink)
pattern = "^'*%[%[ *([^%|%[%]]-) *%|.-%]%]"
if name and delink then
else
-- Rimuove i wikilink e restituisce la parte a sinistra della barra in caso di pipe trick
namepattern = name:match("^'^*%[%[(.-)|.+%]%]') or name:match*('[^%[%[(.]]-) *%]%]') or name"
end
return ucfirst(value:match(pattern) or value)
name = cfg['alias_' .. table_name][name] or name
return cfg[table_name][name]
end
 
-- Restituisce un numero variabile di valori uno alla volta
-- ========================================================================
local function extract_values(args, base_name)
-- Rimpiazza le parentesi quadre nella stringa con i corrispondenti codici
local index = 0
-- ascii
return function()
-- ========================================================================
index = index + 1
local function replace_braces(s)
local value = args[base_name .. ' ' .. tostring(index)]
local new_s = mw.ustring.gsub(s, "%[", "[")
if not value and index == 1 then
new_s = mw.ustring.gsub(new_s, "%]", "]")
value = args[base_name]
new_s = mw.ustring.gsub(new_s, "%(", "(")
end
new_s = mw.ustring.gsub(new_s, "%)", ")")
return value
new_s = mw.ustring.gsub(new_s, " ", " ")
end
return new_s
end
 
-- Restituisce un numero variabile di generi uno alla volta
-- ========================================================================
local function extract_genres(value)
-- Appende una tabella a un'altra tabella
local index = 0
-- ========================================================================
local functionsubstrings append_table= mw.text.split(t1value, ' *, t2*')
return function()
for _,el in ipairs(t2) do
t1[#t1+1] index = elindex + 1
if not substrings[index] then return end
end
local genre
local link, tail = substrings[index]:match('^(%[%[.-%]%]%a*)(.*)$')
if link then
genre = link:gsub('^%[%[', ''):gsub('^[^%[%]%|]+%|', ''):gsub('%]%]', '')
else
genre, tail = substrings[index]:match('^([%w%(%) ]+[%w%(%)])( *.*)$')
end
if genre then
genre = mw.text.trim(genre:lower())
end
return cfg.alias_genere[genre] or genre, tail, substrings[index]
end
end
 
-- Parsifica i parametri rimuovendo le stringhe vuote
-- ========================================================================
local function parse_args(args)
-- Restituisce l'aggettivo plurale maschile o femminile del Paese
local ret = {}
-- specificato usando il template AggNaz
for key, value in pairs(args) do
-- ========================================================================
value = mw.text.trim(value)
local function get_adj(paese, genere)
if value ~= '' then
local adj
ret[key] = value
local title = mw.title.new('Template:AggNaz/' .. paese)
end
adj = (title and title.exists) and
end
mw.getCurrentFrame():expandTemplate {
return ret
title = title.text,
args = { genere }
} or nil
return adj
end
 
-- =============================================================================
-- classe Media
-- Restituisce il tipo di opera se riconosciuto nella configurazione
-- =============================================================================
 
local function get_media(args, alias)
local Media = {}
local key_tipo = alias and 'prefisso_tipo' or 'tipo'
 
local key_sottotipo = alias and 'prefisso_sottotipo' or 'sottotipo'
-- Costruttore della classe Media
local ret = cfg[key_sottotipo][args.tipo] and
function Media:new(args)
cfg[key_sottotipo][args.tipo][args.sottotipo] or
local self = {}
cfg[key_tipo][args.tipo]
setmetatable(self, { __index = Media })
return ret and ret:lower() or nil
 
self.args = args
self.tipo = self:_getType()
self.sottotipo = self:_getSubtype()
self.name = self:_getName()
self.alias = self:_getAlias()
 
return self
end
 
-- Verifica se il medium corrisponde a uno di quelli indicati
-- ========================================================================
function Media:inArray(...)
-- Restituisce true se l'opera corrisponde a uno dei media indicati
for _, value in ipairs({ ... }) do
-- ========================================================================
if self.tipo == value or self.sottotipo == value or self.name == value then
local function media_in_array(args, ...)
for _, media in ipairs({ ... }) do
media = media:gsub('^%l', string.upper)
if cfg.tipo[args.tipo] == media or
cfg.sottotipo[args.tipo] == media or
cfg.sottotipo[args.tipo][args.sottotipo] == media then
return true
end
Riga 96 ⟶ 106:
end
 
-- Ottiene l'alias più generico del medium per le categorie
-- ========================================================================
function Media:_getAlias()
-- Individua e restituisce un anno, se presente nella stringa indicata
return self:_getValue('alias_tipo', 'alias_sottotipo')
-- ========================================================================
end
local function get_year(str)
 
if str then
-- Ottiene il nome più preciso del medium per le categorie
return str:match('%d%d%d%d')
function Media:_getName()
return self:_getValue('tipo', 'sottotipo')
end
 
-- Verifica che il sottotipo di medium sia riconosciuto
function Media:_getSubtype()
if cfg.sottotipo[self.tipo] and cfg.sottotipo[self.tipo][self.args.sottotipo] then
return self.args.sottotipo
end
end
 
-- Verifica che il tipo di medium sia riconosciuto
-- ========================================================================
function Media:_getType()
-- Ritorna una lista di categorie per la sequenza di parametri con
if cfg.tipo[self.args.tipo] or cfg.sottotipo[self.args.tipo] then
-- nome base 'base_name' consultando la tabella 'table'.
return self.args.tipo
-- 'alias_table' è una tabella di nomi alternativi per i valori dei
-- parametri, 'max_index' il numero massimo dell'indice del parametro
-- da controllare
-- ========================================================================
local function get_categories(args, table_name, lowercase)
local categories = {}
local base_name = table_name:match('[^_]')
local anno = get_year(args['data inizio']) or get_year(args['data fine'])
local index = 1
while true do
local adj
local name_value = args[base_name .. ' ' .. tostring(index)] or index == 1 and args[base_name]
if not name_value then break end
name_value = mDelink._main({ name_value })
if lowercase then name_value = mw.ustring.lower(name_value) end
if table_name == 'paese_TV' then
adj = get_adj(name_value, 'fp')
if adj and (adj ~= 'giapponesi' or args[base_name .. ' 2']) then
categories[#categories+1] = 'Serie televisive d\'animazione ' .. adj
end
elseif table_name == 'paese_film_DTV' then
adj = get_adj(name_value, 'mp')
if adj then
categories[#categories+1] = 'Film d\'animazione ' .. adj
if anno then
categories[#categories+1] = 'Film ' .. adj .. ' del ' .. anno
end
end
elseif table_name == 'paese_webserie' then
adj = get_adj(name_value, 'fp')
if adj then
categories[#categories+1] = 'Webserie ' .. adj
end
elseif table_name == 'paese_film_TV' then
adj = get_adj(name_value, 'mp')
if adj then
categories[#categories+1] = 'Film d\'animazione ' .. adj .. ' per la televisione'
end
elseif table_name == 'paese_fumetto' then
if name_value == 'Belgio' or name_value == 'Francia' then
categories[#categories+1] = 'Fumetti franco-belgi'
else
adj = get_adj(name_value, 'mp')
if adj and adj ~= 'giapponesi' and
adj ~= 'cinesi' and adj ~= 'coreani' then
categories[#categories+1] = 'Fumetti ' .. adj
end
end
elseif table_name == 'etichetta_sottotipo' or table_name == 'editore_sottotipo' then
categories[#categories+1] = get_category(args.sottotipo .. ' ' .. name_value, table_name)
else
local category = get_category(name_value, table_name)
if category then
categories[#categories+1] = category
end
end
index = index + 1
end
return categories
end
 
-- Cerca il nome o l'alias del medium nella configurazione
----------------------------------------------------------------------------------
function Media:_getValue(type_table_name, subtype_table_name)
-- Categorizza tranne che per genere
return cfg[subtype_table_name][self.tipo] and
----------------------------------------------------------------------------------
cfg[subtype_table_name][self.tipo][self.sottotipo] or
function p.categorie(frame)
cfg[type_table_name][self.tipo]
local args = getArgs(frame, {parentOnly = true})
end
local media = get_media(args)
 
local isMainspace = mw.title.getCurrentTitle().namespace == 0
-- =============================================================================
local catEnabled = args.categorie ~= 'no'
-- classe CategoryManager
if not (media and isMainspace and catEnabled) then return end
-- =============================================================================
local categories = {}
 
local year = get_year(args['data inizio']) or get_year(args['data fine'])
local CategoryManager = {}
-- Categoria di errore quando data inizio/data fine sono compilati
 
-- ma non si rilevano le quattro cifre dell'anno in entrambi
-- Costruttore della classe CategoryManager
if (args['data inizio'] or args['data fine']) and not year then
function CategoryManager:new(args)
categories[#categories+1] = error_category
local self = {}
setmetatable(self, { __index = CategoryManager })
 
self.args = args
self.media = Media:new(args)
self.error_category = false
self.year = self:_getYear()
self.genre_table_name = self:_getGenreTableName()
self.categories = {}
self.tables_matched = {}
 
self:_addCategories()
 
return self
end
 
-- Restituisce l'elenco di categorie
function CategoryManager:listCategories()
return table.concat(self.categories)
end
 
-- Avvia la categorizzazione automatica dell'opera
function CategoryManager:_addCategories()
if self.genre_table_name then
self:_addCategoriesBy('genere')
end
 
-- Categorizzazioni specifiche
if self.media.name == "serie televisive d'animazione" then
self
append_table(categories, get_categories(args, 'studio_cartoneTV'))
:_addCategoriesBy('studio_cartoneTV')
if counter == #categories then
:_addCategoriesBy('paese', 'fp', self._categorizeTVSeriesByCountry)
append_table(categories, get_categories(args, 'paese_TV'))
elseif self.media.name == "film d'animazione direct-to-video" then
append_table(categories, get_categories(args, 'studio'))
self:_addCategoriesBy('paese', 'mp', self._categorizeDTVFilmByCountry)
elseif self.media.name == "webserie d'animazione" then
self:_addCategoriesBy('paese', 'fp', self._categorizeWebseriesByCountry)
elseif self.media.name == "film d'animazione per la televisione" then
self:_addCategoriesBy('paese', 'mp', self._categorizeTVFilmByCountry)
elseif self.media.tipo == 'manga' then
self
:_addCategoriesBy('editore_manga')
:_addCategoriesBy('editore')
:_addCategoriesBy('target')
elseif self.media:inArray('manhua', 'manhwa') then
self:_addCategoriesBy('editore')
elseif self.media.tipo == 'light novel' then
self
:_addCategory(self.media.tipo)
:_addCategory('Romanzi in giapponese')
:_addCategoriesBy('etichetta')
:_addCategoriesBy('editore')
elseif self.media.tipo == 'fumetto' and self.media.sottotipo then
self
:_addCategoriesBy('etichetta_sottotipo', nil, self._substituteParameter)
:_addCategoriesBy('etichetta')
:_addCategoriesBy('editore_sottotipo', nil, self._substituteParameter)
:_addCategoriesBy('editore')
:_addCategoriesBy('paese', 'mp', self._categorizeComicByCountry)
if not self.tables_matched['etichetta_sottotipo'] and
not self.tables_matched['editore_sottotipo'] then
self:_addCategory(self.media.name)
end
elseif media_in_array(args,self.media.tipo 'anime',== 'cartonefumetto') then
self
if media == "film d'animazione direct-to-video" then
:_addCategoriesBy('etichetta')
categories[#categories+1] = tipo
:_addCategoriesBy('editore')
append_table(categories, get_categories(args, 'paese_film_DTV'))
:_addCategoriesBy('paese', 'mp', self._categorizeComicByCountry)
elseif media == "webserie d'animazione" then
end
append_table(categories, get_categories(args, 'paese_webserie'))
 
elseif media == "film d'animazione per la televisione" then
if self.media:inArray('anime', 'cartone') then
append_table(categories, get_categories(args, 'paese_film_TV'))
self:_addCategoriesBy('studio')
local broadcaster
local network = self.args['rete 1'] or self.args.rete
if self.media:inArray('film TV', 'serie TV') then
broadcaster = self:_getCategory(network, 'rete')
elseif network and self.media:inArray('ONA', 'webserie') then
self.error_category = true
end
if not network and self.media:inArray('film TV', 'ONA', 'serie TV', 'webserie') then
append_table(categories, get_categories(args, 'studio'))
local platform = self.args['streaming 1'] or self.args.streaming
elseif args.tipo == 'manga' then
broadcaster = self:_getCategory(platform, 'streaming')
counter = #categories
append_table(categories, get_categories(args, 'editore_manga'))
if counter == #categories then
append_table(categories, get_categories(args, 'editore'))
end
if broadcaster then
elseif media_in_array(args, 'manhwa', 'manhua') then
self:_addCategory(mw.message.newRawMessage(broadcaster, self.media.alias):plain())
append_table(categories, get_categories(args, 'editore'))
elseif args.tipo == 'light novel' then
categories[#categories+1] = tipo
if (args['lingua originale'] or ''):match('giapponese') then
categories[#categories+1] = 'Romanzi in giapponese'
end
end
counter = #categories
 
append_table(categories, get_categories(args, 'etichetta'))
-- categorizzazione per tipo delle opere non suddivise per anno
if counter == #categories then
if self.media:inArray('film direct-to-video', 'manhua', 'manhwa', 'ONA', 'webserie') then
append_table(categories, get_categories(args, 'editore'))
self:_addCategory(self.media.name)
end
-- categorizzazione delle opere suddivise per anno
elseif args.tipo == 'fumetto' then
elseif self.media.name and self.year then
counter = #categories
iflocal argsmedia = self.media.sottotipo then~= 'serie TV' and
self.media.alias or self.media.name
append_table(categories, get_categories(args, 'etichetta_sottotipo'))
self:_addCategory(string.format('%s del %s', media, self.year))
end
end
if counter == #categories then
 
local etichetta = {}
if self.error_category == true then
etichetta = get_category(mDelink._main({ args.etichetta }), 'etichetta')
self:_addCategory(error_category)
if etichetta then
end
append_table(categories, get_categories(args, 'etichetta'))
end
 
counter = #categories
-- Aggiunge categorie per una lista di valori
if args.sottotipo then
function CategoryManager:_addCategoriesBy(table_name, gender, callback)
append_table(categories, get_categories(args, 'editore_sottotipo'))
local base_name = table_name:match('[^_]+')
end
for value in extract_values(self.args, base_name) do
if counter == #categories then
if args.sottotipotable_name == 'genere' then
self:_addCategoryByGenre(value)
categories[#categories+1] = tipo
elseif table_name == 'paese' then
end
self:_addCategoryByCountry(value, gender, callback)
if etichetta == nil then
elseif self:_isCategoryRedundant(table_name) == false then
counter = #categories
local category = self:_getCategory(value, table_name)
append_table(categories, get_categories(args, 'editore'))
if counter == #categoriescategory then
if callback then
append_table(categories, get_categories(args, 'paese_fumetto'))
category = callback(self, category)
end
end
self.tables_matched[table_name] = true
self:_addCategory(category)
end
end
end
return self
local emittente = get_category(args.streaming, 'streaming', true) or
end
args.streaming == nil and get_category(args.rete, 'rete', true)
 
if emittente and media_in_array('anime', 'cartone') then
-- Formatta e aggiunge una categoria
local pre_emittente = get_media(args, true)
function CategoryManager:_addCategory(category)
if pre_emittente then
if self.args.categorie ~= 'no' or category == error_category then
if pre_emittente:find('^Webserie') and not args.streaming then
table.insert(self.categories, string.format('[[Categoria:%s]]', category))
categories[#categories+1] = error_category
end
else
return self
categories[#categories+1] = pre_emittente .. emittente
end
 
-- Aggiunge la categoria per Paese dopo aver individuato l'aggettivo
-- maschile o femminile, singolare o plurale adeguato
function CategoryManager:_addCategoryByCountry(country, gender, callback)
local frame = mw.getCurrentFrame()
local success, adj = pcall(frame.expandTemplate, frame, {
title = 'Template:AggNaz/' .. delink(country),
args = { gender }
})
if not success then
self.error_category = true
elseif self:_isCategoryRedundant('paese') == false then
callback(self, adj)
end
end
 
-- Aggiunge una o più categorie per genere dell'opera
function CategoryManager:_addCategoryByGenre(value)
for genre in extract_genres(value) do
if cfg.genere_wikilink[genre] then
local categories = cfg[self.genre_table_name][genre]
if categories then
for _, category in ipairs(categories) do
self:_addCategory(category)
end
end
else
self.error_category = true
end
end
end
if media_in_array(args, 'manga', 'manhwa') then
 
append_table(categories, get_categories(args, 'target', true))
-- Categorizza un fumetto per Paese
function CategoryManager:_categorizeComicByCountry(adj)
if adj == 'giapponesi' or adj == 'cinesi' or adj == 'coreani' then
return
elseif adj == 'belgi' or adj == 'francesi' then
adj = 'franco-belgi'
end
self:_addCategory('Fumetti ' .. adj)
-- Categorizzazione per tipo delle opere non suddivise per anno
end
if media_in_array(args, 'manhua', 'manhwa', 'original net anime', "webserie d'animazione") then
 
categories[#categories+1] = media
-- Categorizza una serie direct-to-video per Paese
-- Categorizzazione per anno delle opere previste
function CategoryManager:_categorizeDTVFilmByCountry(adj)
elseif year and args.sottotipo ~= 'film direct-to-video' then
self:_addCategory("Film d'animazione " .. adj)
categories[#categories+1] = string.format('%s del %s', get_media(args, true) or media, year)
if self.year then
self:_addCategory(string.format('Film %s del %s', adj, self.year))
end
end
for index, cat in ipairs(categories) do
 
categories[index] = '[[Categoria:' .. cat .. ']]'
-- Categorizza un film televisivo per Paese
function CategoryManager:_categorizeTVFilmByCountry(adj)
self:_addCategory(string.format("Film d'animazione %s per la televisione", adj))
end
 
-- Categorizza una serie TV per Paese
function CategoryManager:_categorizeTVSeriesByCountry(adj)
if adj ~= 'giapponesi' or self.args['paese 2'] then
self:_addCategory("Serie televisive d'animazione " .. adj)
end
return table.concat(categories)
end
 
-- Categorizza una webserie per Paese
----------------------------------------------------------------------------------
function CategoryManager:_categorizeWebseriesByCountry(adj)
-- Gestisce categorie e wikilink dei generi
self:_addCategory('Webserie ' .. adj)
----------------------------------------------------------------------------------
end
function p.generi(frame)
 
local args = getArgs(frame, {parentOnly = not frame.args[1]})
-- Cerca il nome di una categoria nella configurazione
local genre = frame.args[1]
function CategoryManager:_getCategory(key, table_name)
if genre == '' then return end
key = delink(key)
local current_page = mw.title.getCurrentTitle()
key = cfg['alias_' .. table_name] and cfg['alias_' .. table_name][key] or key
local current_namespace = current_page.namespace
return cfg[table_name][key]
local category
end
local result = {}
 
for name, alias_name in pairs(cfg['alias_genere']) do
-- Individua la tabella dei generi idonei al tipo di opera nella configurazione
local piped = mw.ustring.match(genre, '%[%[[^%[]*|%s*' .. name .. '%s*%]%]')
function CategoryManager:_getGenreTableName()
local pattern = (piped and '%[%[[^%[]*|%s*' or '%[%[%s*') .. name .. '%s*%]%]%a*'
local table_name
genre = mw.ustring.gsub( genre, pattern, '[[' .. alias_name .. ']]' )
if self.media:inArray('anime', 'manga') then
table_name = 'genere_animanga'
elseif self.media.tipo == 'light novel' then
table_name = 'genere_light_novel'
elseif self.media:inArray('fumetto', 'manhua', 'manhwa') then
table_name = 'genere_fumetto'
end
return table_name
for name, correct_name in pairs(cfg['genere']) do
end
if current_namespace == 0 and args.categorie ~= 'no' then
 
local tipo = {
-- Ricava l'anno dell'opera dalle date di inizio e fine
['anime'] = correct_name[1],
function CategoryManager:_getYear()
['fumetto'] = correct_name[2],
if not (self.args['data inizio'] or self.args['data fine']) then return end
['light novel'] = correct_name[3],
local start_date = self.args['data inizio'] or ''
['manga'] = correct_name[1],
local end_date = self.args['data fine'] or ''
['manhua'] = correct_name[2],
local year = (start_date .. ' ' .. end_date):match('%f[%w]%d%d%d%d%f[%W]')
['manhwa'] = correct_name[2]
if year then
}
return year
tipo = tipo[args.tipo]
else
tipo = tipo and tipo[1] and tipo[1] .. ']][[Categoria:' .. tipo[2] or tipo
self.error_category = true
category = tipo and tipo ~= '' and '[[Categoria:' .. tipo .. ']]'
end
end
local piped = mw.ustring.match(genre, '%[%[[^%[]*|%s*' .. name .. '%s*%]%]')
 
local pattern = (piped and '%[%[[^%[]*|%s*' or '%[%[%s*') .. name .. '%s*%]%]%a*'
-- Verifica che non sia già stata aggiunta una sottocategoria
genre = mw.ustring.gsub( genre, pattern, correct_name[4] .. (category or '') )
function CategoryManager:_isCategoryRedundant(table_name)
-- Categoria d'errore in caso di genere senza corrispondenza
if cfg.sottocategorie[table_name] then
local list = mw.text.split( genre, ',' )
for i_, =value 1,in #listipairs(cfg.sottocategorie[table_name]) do
if self.tables_matched[value] then
local s = replace_braces(list[i])
return true
local p = replace_braces(correct_name[4])
if mw.ustring.match( s, p ) then
result[i] = ''
elseif result[i] == nil and current_namespace == 0 then
result[i] = '[[Categoria:' .. error_category .. ']]'
end
end
end
return false
genre = genre .. table.concat(result)
return genre
end
 
----------------------------------------------------------------------------------
-- Popola l'argomento numerato in una stringa col tipo dell'opera
-- Ritorna la configurazione della tabella per aziende e target
function CategoryManager:_substituteParameter(msg)
----------------------------------------------------------------------------------
return mw.message.newRawMessage(msg, self.media.name):plain()
end
 
-- =============================================================================
-- Funzioni esportate
-- =============================================================================
 
local p = {}
 
-- Funzione per il template FeA, categorizza la voce
function p.categorie(frame)
if mw.title.getCurrentTitle().namespace ~= 0 then return end
local args = parse_args(frame:getParent().args)
return CategoryManager:new(args):listCategories()
end
 
-- Funzione per il template FeA, elabora i wikilink dei generi
function p.generi(frame)
local ret = {}
local args = parse_args(frame.args)
for genre, tail, default in extract_genres(args[1]) do
local wikilink = cfg.genere_wikilink[genre]
table.insert(ret, wikilink and (wikilink .. tail) or default)
end
return table.concat(ret, ', ')
end
 
-- Funzione per il manuale, mostra l'elenco di valori e rispettivi alias per
-- una data tabella nella configurazione
function p.tabella_configurazione(frame)
local argstable_name = getArgsparse_args(frame.args)[1]
if not cfg[table_name] then return end
local table_name = args[1]
if not(table_name) then return '' end
local reverse_alias = build_reverse_alias(table_name)
local root = mw.html.create('table')
root
:addClass('wikitable mw-collapsible mw-collapsed sortable')
:tag('tr')
:tag('th'):wikitext(table_name'Valore'):done()
:tag('th'):wikitext('Alias'):done()
:tag('th'):wikitext('CategoriaRisultato'):done()
local keys, reverse_alias = {}, {}
for name, cat_name in pairs(cfg[table_name]) do
local name_codealias_table_name = table_name:find('genere') ==and 'genere' andor table_name
for alias, name in pairs(cfg['alias_' .. alias_table_name] or {}) do
replace_braces(cat_name[4]) or
if not reverse_alias[name] then reverse_alias[name] = {} end
'[[' .. name .. ']]'
table.insert(reverse_alias[name], alias)
local cat_code = {}
end
if cat_name[1] then
for key in pairs(cfg[table_name]) do table.insert(keys, key) end
for i, cat in ipairs(cat_name) do
table.sort(keys)
if i > 3 then break end
local pre_table_name
cat = cat[1] and
if table_name == 'editore_sottotipo' or table_name == 'etichetta_sottotipo' then
cat[1] .. ']]<br />[[:Categoria:' .. cat[2] or cat
pre_table_name = cfg.sottotipo.fumetto
if cat ~= '' then
elseif table_name == 'rete' or table_name == 'streaming' then
cat_code[#cat_code+1] = '[[:Categoria:' .. cat .. ']]'
pre_table_name = cfg.alias_sottotipo.cartone
end
end
for _, key in ipairs(keys) do
local result, values = {}, {}
reverse_alias[key] = reverse_alias[key] or {}
if pre_table_name then
for _, subtype in pairs(pre_table_name) do
local msg = cfg[table_name][key]
subtype = ucfirst(subtype)
table.insert(values, mw.message.newRawMessage(msg, subtype):plain())
end
elseif type(cfg[table_name][key]) == 'string' then
cat_code = table.concat(cat_code, '<br />')
values = { cfg[table_name][key] }
else
values = cfg[table_name][key]
cat_code = '[[:Categoria:' .. cat_name .. ']]'
end
for _, str in ipairs(values) do
local alias_code = '&nbsp;'
if reverse_alias[name]table_name ~= 'genere_wikilink' then
str = string.format('[[:Categoria:%s]]', str)
for i,alias in ipairs(reverse_alias[name]) do
reverse_alias[name][i] = '&#91;&#91;' .. alias .. '&#93;&#93;'
end
alias_code = table.concatinsert(reverse_alias[name]result, '<br />'str)
end
table.sort(result)
result = table.concat(result, '<br />')
table.sort(reverse_alias[key])
reverse_alias[key] = table.concat(reverse_alias[key], '<br />')
root:tag('tr')
:tag('td'):wikitext(name_codekey):done()
:tag('td'):wikitext(alias_codereverse_alias[key]):done()
:tag('td'):wikitext(cat_coderesult):done()
end
return tostring(root)
end
 
return p