Modulo:Software: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Ovviamente si considera la presenza di linguaggi se il template ha il parametro compilato
disattivo categorie al di fuori del NS0
 
(76 versioni intermedie di 8 utenti non mostrate)
Riga 1:
local mWikidata = require('Modulo:Wikidata')
local getArgs = require('ModuleModulo:Arguments').getArgs
local conf = mw.loadData('Modulo:Software/Configurazione')
 
local p = {}
 
--------------------------------------------------------------------------------
function p._isFreeSoftwareByTemplate(frame)
 
local is = nil
local UNKNOWN = -1 -- Non è possibile identificare la licenza
local args = frame and getArgs(frame)
local FREE = 1 -- È una licenza di software libero
local v = args['SoftwareLibero']
local PROPRIETARY = 2 -- È una licenza di software proprietario
if v then
 
local yep = {['sì'] = true, ['si'] = true, ['no'] = false}
local MAX_RECURSION = 4 -- [[Modulo:Software/man#Considerazioni implementative]]
v = yep[ mw.ustring.lower(v) ]
 
local UNKNOWN_WD_LANGUAGE = "[[Categoria:Linguaggio di programmazione da Wikidata non previsto]]"
local UNKNOWN_WD_LICENSE = ""
local UNKNOWN_WD_TOOLKIT = "[[Categoria:Toolkit o framework dell'interfaccia grafica non previsto]]"
local FREE_WITHOUT_LANGUAGE = '[[Categoria:Software libero senza linguaggio]]'
 
local TEMPLATE_UNKNOWN_ARG_WARN = "&nbsp;<span style=\"font-size:75%\">(non&nbsp;in&nbsp;[[Template:Software#Linguaggi|lista]])</span>"
local TEMPLATE_UNKNOWN_ARG_CAT = "[[Categoria:Software in linguaggio non riconosciuto]]"
 
local LICENSE_CAT = "Software con licenza %s"
-- "Software con licenza GNU GPL"
 
local LICENSE_CAT_SHORTER = "Software %s"
-- "Software freeware"
 
local YEAR_CAT = 'Software del %d'
 
-------------------------------- Sgabuzzino ------------------------------------
 
--[[
* Get the ID from a statement (claim) of type wikibase-id
*
* @param table Wikibase claim
* @return string|nil
]]
local function statementQID( claim )
return claim.mainsnak.datavalue and claim.mainsnak.datavalue.value.id
end
 
--[[
* @param string Wikidata element
* @TODO ora prende il primo, a prescindere dalla lingua (credo).
* @return string
]]
local function shortWikidataLabel(from)
local s = ''
local label = mw.wikibase.label(from)
local sitelink = mw.wikibase.sitelink(from) or label
if string.len(label) > 10 then
label = mWikidata._getProperty( { 'P1813', n = 1, from = from } ) or label
end
return "[[" .. sitelink .. "|" .. label .. "]]"
return v
end
 
 
function p._isFreeSoftwareByWikidata()
--[[
return mWikidata._instanceOf({'Q341', 'Q1130645'})
* @param v bool
* @return string
]]
local function yesNo(v)
return v and 'sì' or 'no'
end
 
--[[
function p._isProprietarySoftwareByWikidata()
* @param v bool
return mWikidata._instanceOf({'Q218616'})
* @return string|nil
]]
local function yesNoNil(v)
if v == nil then
return nil
end
return yesNo(v)
end
 
 
--[[
* Poi non ditemi che PHP fa schifo. asd.
* Sembra che l'operatore "#" ogni tanto non vada col Modulo:Wikidata.
* 00:28, 28 feb 2017 Valerio Bozzolan
]]
local function count(t)
local i = 0
for _,_ in pairs(t) do
i = i + 1
end
return i
end
 
--[[
* Restituisce una tabella completa di proprietà non formattate.
* @return {}|nil
* ]]
local function rawProperties(from, property)
return mWikidata._getProperty({property, from = from, formatting = 'raw'}, true)
end
 
local function onlySoftwareArguments(frame)
return getArgs(frame, {wrappers = 'Template:Software'} )
end
 
--[[
* Restituisce SOLO l'argomento `from` da dare in pasto a varie funzioni del Modulo:Wikidata
* @param frame table
* @return string|nil
]]
local function fromItem(frame)
return getArgs(frame).from
end
 
--[[
* Analogo a fromItem() ma viene recuperato da Property:P301 (category's main topic).
*
* @return string|nil
]]
local function fromItemMainTopic()
local from = mWikidata._getClaims('P301')
from = from and from[1]
if not from then
error("Questa non è una categoria, o è assente la proprietà Wikidata P301")
end
return statementQID(from)
end
 
--[[
* Formatta una categoria.
*
* @param category string Primo argomento per sprinf
* @param part string Placeholder per sprintf
* @param man boolean Mostrare solo la categoria invece che categorizzare?
* @return string
]]
local function formatCategory(category, part, man)
local colon = man and ':' or ''
return "[[" .. colon .. "Categoria:" .. string.format(category, part) .. "]]"
end
 
------------------------------- Frontend ---------------------------------------
 
function p.shouldHaveALanguage(frame)
return yesNo( p._shouldHaveALanguage( onlySoftwareArguments(frame) ) )
end
 
function p.specifiesALanguage(frame)
return yesNo( p._specifiesALanguage( onlySoftwareArguments(frame) ) )
end
 
function p.specifiesAToolkit(frame)
return yesNo( mWikidata._getClaims('P277') )
end
 
function p.isFreeSoftware(frame)
return yesNoNil( p._isFreeSoftware( onlySoftwareArguments(frame) ) )
end
 
function p.hasAFreeLicense(frame)
return yesNoNil( p._hasAFreeLicense( fromItem(frame) ) )
end
 
function p.hasAProprietaryLicense(frame)
return yesNoNil( p._hasAProprietaryLicense( fromItem(frame) ) )
end
 
function p.languageCategories( frame )
return p._languageCategories( fromItem( frame ) )
end
 
--[[
* Categorizza una voce.
* @return string|nil
]]
function p.categories(frame)
if p._categorize( onlySoftwareArguments(frame) ) then
return p.licenseCategories(frame) .. p.toolkitCategories(frame) .. p.yearsCategories(frame)
end
return nil
end
 
function p.wikidataCategoriesFromMainTopic(frame)
local s = p._wikidataCategories( fromItemMainTopic() )
return s .. string.format('[[Categoria:P301 %s Wikidata]]', s and 'letta da' or 'assente su')
end
 
--[[
* Categorizza una pagina qualsiasi.
* @return string|nil
]]
function p.wikidataCategories(frame)
return p._wikidataCategories( fromItem(frame) ) or nil
end
 
--[[
* Tutte le categorie applicabili da Wikidata.
*
* Per ora ci sono solo le licenze, ma qui ci devono andare anche i linguaggi.
*
* @param from string|nil Wikidata Item
* @return string
]]
function p._wikidataCategories(from)
return p._licenseCategories(from) .. p._languageCategories(from) .. p._toolkitCategories(from) .. p._yearsCategories(from)
end
 
--[[
* Categorie legate alle licenze.
* @return string
]]
function p.licenseCategories(frame)
return p._licenseCategories( fromItem(frame) )
end
 
--[[
* Categorie legate al toolkit.
* @return string
]]
function p.toolkitCategories(frame)
return p._toolkitCategories( fromItem(frame) )
end
 
--[[
* Categoria legato all'anno di fondazione.
* @return string
]]
function p.yearsCategories(frame)
return p._yearsCategories( fromItem(frame), onlySoftwareArguments(frame).DataPrimaVersione )
end
 
--[[
* Linguaggi di programmazione.
*
* @return string
]]
function p.languages(frame)
local s = ''
 
local args = frame and onlySoftwareArguments(frame)
local categorize = p._categorize(args)
local is_free = p._isFreeSoftware(args)
local tl_has = p._templateHasLanguages(args) and true or false --exclude nil
local tl_languages = p._getTemplateLanguages(args)
local wd_languages = mWikidata._getClaims('P277')
 
-- È il namespace principale?
local nszero = mw.title.getCurrentTitle().namespace == 0
 
-- Il template si è arricchito grazie a Wikidata?
local improved = false
 
-- Tutti i linguaggi sono identificati da Wikidata e dal template?
local tl_allFound = true
local wd_allFound = true
 
-- Il template non mostra alcun linguaggio?
local noLanguages = not tl_has and not wd_languages
 
local outputLanguages = {} -- {key = {label1, category1}, key = {label2, category2}}
local outputLanguage = function(label, category, note)
return {label = label, category = category, note = note or '' }
end
 
if wd_languages then
for i, language in pairs(wd_languages) do
local languageId = statementQID(language)
if languageId then
language = conf.language[languageId]
outputLanguages[languageId] = outputLanguage(
shortWikidataLabel(languageId),
language and p._languageCategory(language, is_free)
)
improved = true
end
end
 
if nszero then
if improved then
if tl_has then
-- Wikidata ha migliorato il template e il template aveva già altri valori
s = s .. '[[Categoria:P277 differente su Wikidata]]'
else
-- Wikidata ha migliorato il template che era vuoto
s = s .. '[[Categoria:P277 letta da Wikidata]]'
end
else
if p._templateHasExtraInformations(args) or count(tl_languages) > count(wd_languages) then
-- Nel template c'è qualcosa in più rispetto a Wikidata
s = s .. '[[Categoria:P277 differente su Wikidata]]'
elseif count(wd_languages) ~= 0 then
-- Non ha migliorato niente perchè sono gli stessi valori
s = s .. '[[Categoria:P277 uguale su Wikidata]]'
end
end
end
else
if tl_has and nszero then
-- solo se il template specifica linguaggi ma Wikidata no
s = s .. '[[Categoria:P277 assente su Wikidata]]'
end
end
 
if tl_languages then
for languageSlug, note in pairs(tl_languages) do
if languageSlug == 'sconosciuto' then
outputLanguages[languageSlug] = outputLanguage(
"Sconosciuto",
TEMPLATE_UNKNOWN_ARG_CAT,
note
)
else
local languageId = conf.languageSlugToWikidata[languageSlug]
local language = conf.language[languageId]
if language then
outputLanguages[languageId] = outputLanguage(
shortWikidataLabel(languageId),
p._languageCategory(language, is_free),
note
)
else
-- Mostrala comunque, a caso, così, tanto per
outputLanguages[languageSlug] = outputLanguage(
languageSlug,
p._languageCategory(languageSlug, is_free),
note
)
tl_allFound = false
end
end
end
end
 
local i = 0
for id, language in pairs(outputLanguages) do
local glue = i > 0 and '<br />' or ''
s = s .. glue .. language.label .. language.note .. (categorize and language.category or '')
i = i + 1
end
 
if args['LinguaggioAltri'] then
local glue = i > 0 and '<br />' or ''
s = s .. glue .. args['LinguaggioAltri']
end
 
if nszero then
if not tl_allFound then
s = s .. TEMPLATE_UNKNOWN_ARG_WARN .. TEMPLATE_UNKNOWN_ARG_CAT
end
if not wd_allFound then
s = s .. UNKNOWN_WD_LANGUAGE
end
if noLanguages and is_free then
s = s .. FREE_WITHOUT_LANGUAGE
end
end
 
return s
end
 
function p.manLanguages(frame)
local s = '<table class="wikitable"><tr><th>Parametro</th><th>Risultato</th><th>Categoria automatica</th></tr>'
local TD = '<td>%s</td>'
for id, language in pairs( conf.language ) do
s = s .. '<tr>'
local slugs, i = '', 0
for slug, sub_id in pairs( conf.languageSlugToWikidata ) do
if sub_id == id then
local glue = i > 0 and '<br />' or ''
slug = "<code>" .. slug .. "</code>"
slugs = slugs .. glue .. slug
i = i + 1
end
end
s = s .. string.format(TD, slugs)
s = s .. string.format(TD, shortWikidataLabel(id) )
s = s .. string.format(TD, p._languageCategory(language, nil, true, '//') )
s = s .. '</tr>'
end
return s .. '</table>'
end
 
-------------------------------- Backend ---------------------------------------
 
--[[
* Categorizzare?
*
* @return true|false
]]
function p._categorize(args)
local ns = mw.title.getCurrentTitle().namespace
local v = args['Categorie']
return ns == 0 and (v == nil or mw.ustring.lower(v) ~= 'no')
end
 
--[[
* Riassumendo. La voce è software libero?
*
* @return true|false|nil
]]
function p._isFreeSoftware(frameargs)
local is_wd = p._isFreeSoftwareByWikidata()
local isnt_wd = p._isProprietarySoftwareByWikidata()
local is_tp = p._isFreeSoftwareByTemplate(frameargs)
 
local is = nil
if is_wd then
Riga 62 ⟶ 430:
end
 
--[[
function p.isFreeSoftware(frame)
* Spesso la voce è definita in Wikidata come istanza di software libero.
local is = p._isFreeSoftware(frame)
* Per quanto riguarda Wikipedia è comodo.
if is == nil then
* Per quanto riguarda Wikidata è ridondante col campo licenza P275.
return nil
*
end
* @param string from Wikidata item
return is and 'sì' or 'no'
* @return true|false
]]
function p._isFreeSoftwareByWikidata(from)
-- Q341 free software
-- Q1130645 open-source software
return mWikidata._instanceOf({'Q341', 'Q1130645', from = from}) or p._hasAFreeLicense(from)
end
 
--[[
* Spesso la voce è definita in Wikidata come istanza di software proprietario.
* Il template ha linguaggi?
* Per quanto riguarda Wikipedia è comodo.
* Per quanto riguarda Wikidata è ridondante col campo licenza P275.
*
* @param from string Wikidata item
* @return truly|nil
* @return true|false
]]
function p._templateHasLanguages_isProprietarySoftwareByWikidata(framefrom)
-- Q218616 proprietary software
local args = frame and getArgs(frame)
-- Q178285 freeware TODO: impropria, subclass of precedente
return args['Linguaggio'] or args['NotaLinguaggio'] or args['LinguaggioAltri']
return mWikidata._instanceOf({'Q218616', 'Q178285', from = from}) or p._hasAProprietaryLicense(from)
end
 
--[[
* Banale lettura di `SoftwareLibero = sì/no` nel template {{Software}}
* La voce specifica un linguaggio di programmazione?
*
* @return nil|true|false
--]]
function p._isFreeSoftwareByTemplate(args)
local is = nil
local v = args['SoftwareLibero']
if v then
local yep = {['sì'] = true, ['si'] = true, ['no'] = false}
v = yep[ mw.ustring.lower(v) ]
end
return v
end
 
--[[
* Riassumendo. La voce dovrebbe specificare un linguaggio?
*
* @return true|nil
]]
function p._specifiesALanguage_shouldHaveALanguage(frameargs)
return p._isFreeSoftware(args) or p._specifiesALanguage(args)
local args = frame and getArgs(frame)
return p._templateHasLanguages(frame) or mWikidata._getClaims('P277')
end
 
--[[
function p.specifiesALanguage(frame)
* C'è un linguaggio?
return p._specifiesALanguage(frame) and 'sì' or 'no'
*
* @return truly|nil
]]
function p._specifiesALanguage(args)
return p._templateHasLanguages(args) or mWikidata._N({ 'P277' }) > 0
end
 
--[[
* Il template ha il campo "Linguaggio"?
* La voce dovrebbe specificare un linguaggio?
*
* @return truetruly|nil
]]
function p._shouldHaveALanguage_templateHasLanguages(frameargs)
return args['Linguaggio'] or args['NotaLinguaggio'] or args['LinguaggioAltri']
return p._isFreeSoftware(frame) or p._specifiesALanguage(frame)
end
 
--[[
function p.shouldHaveALanguage(frame)
* Il template ha valori non unibili a Wikidata?
return p._shouldHaveALanguage(frame) and 'sì' or 'no'
*
* @return truly|nil
]]
function p._templateHasExtraInformations(args)
return args['LinguaggioAltri'] or args['NotaLinguaggio'] or args['NotaLinguaggio2'] or args['NotaLinguaggio3']
end
 
--[[
* Per mantenere retrocompatibilità con la possibilità di avere più codici.
*
* Esempio:
* 'cpp' → 'c++'
* 'c++' → 'c++'
*
* @param string
* @see Template:Software/Linguaggio
* @return string
]]
function p._preferredLanguageSlug(slug)
Riga 119 ⟶ 528:
 
--[[
* I codici dei linguaggi del template {{Software}}.
* Reverse tree di Modulo:Software/Configurazione
*
* 'cpp' → 'Q2407'
]]
local _languageSlugToWikidata = {}
function p._languageSlugToWikidata(slug)
if next(_languageSlugToWikidata) == nil then
for q,l in pairs(conf.wikidataToLanguageSlug) do
_languageSlugToWikidata[l] = q
end
end
return _languageSlugToWikidata[ p._preferredLanguageSlug(slug) ]
end
 
function p.languageSlugToWikidata(frame)
return p._languageSlugToWikidata( getArgs(frame)[1] )
end
 
--[[
* @return string[] = 'c' => 'nota linguaggio c', 'c++' = '', ..
]]
function p._getTemplateLanguages(frameargs)
local languages = {}
for i=0,3 do
local args = frame and getArgs(frame)
local vj = args[i == 0 and 'Linguaggio'] or i
local v = args['Linguaggio' .. j]
if v then
languages[ p._preferredLanguageSlug(v) ] = args['NotaLinguaggio'] or ''
end
for i=1,3 do
v = args['Linguaggio' .. i]
if v then
languages[v = p._preferredLanguageSlug(v)
languages[ v ] = args['NotaLinguaggio' .. ij] or ''
end
end
Riga 156 ⟶ 545:
end
 
--[[
function p.languages(frame)
* Questa licenza è direttamente identificabile?
local s = ''
*
* @TODO: Rewrite in qualche modo più umano.
*
* @param license string Wikidata item
* @return FREE|PROPRIETARY|UNKNOWN
]]
function p._singleLicenseType(license)
-- Q1156659 OSI-approved license
-- Q5975031 free software copyleft license
-- Q3943414 free software license
-- Q31202214 proprietary software license
-- Q218616 proprietary software
-- Q3238057 proprietary license!
 
--[[
* Approfonditi studi da punti di vista non neutrali hanno evidenziato come
* Argomenti ereditati dal Template:Software e da Wikidata
* le prossime tre righe riassumino l'*unica* parte piacevole del Lua.
]]
return (license == 'Q3943414' or license == 'Q5975031' or license == 'Q1156659') and FREE
local args = frame and getArgs(frame)
or (license == 'Q31202214' or license == 'Q218616' or license == 'Q3238057') and PROPRIETARY
local categorizza = args['Categorie']
or UNKNOWN
local libero = p.isFreeSoftware(frame)
end
 
--[[
* Fra queste licenze c'è una classe radice identificabile?
* Linguaggi dal Template:Software e da Wikidata
*
]]
* @param license string Wikidata item
local tl_has = p._templateHasLanguages(frame) and true or false
* @return FREE|PROPRIETARY|UNKNOWN
local tl_languages = p._getTemplateLanguages(frame)
* ]]
local wd_languages = mWikidata._getClaims('P277')
function p._findLicenseType(licenses)
local altri = args['LinguaggioAltri']
local type = UNKNOWN
for _, license in pairs(licenses) do
type = p._singleLicenseType(license)
if type ~= UNKNOWN then
break
end
end
return type
end
 
--[[
-- È il namespace principale?
* Ottiene la tipologia di una qualsiasi licenza software.
local nszero = mw.title.getCurrentTitle().namespace == 0
*
* Una licenza è identificabile grazie a Wikidata scorrendo ricorsivamente
* l'albero di licenze madri fino ad arrivare ad una classe radice identificabile.
*
* Questo può sembrare spaventoso, in verità sembra piuttosto efficiente,
* portando l'utilizzo medio di funzioni parser dispendiose a +2/+3.
*
* In ogni caso il limite delle funzioni parser dispendiose è 500,
* mentre si ipotizza che questa funzione possa provocarne al massimo +5/+6
* per casi peggiori.
*
* @param license string Wikidata item
* @param i int|nil Livello di
* @see Modulo:Software/man#Considerazioni implementative
* @return UNKNOWN|FREE|PROPRIETARY
]]
local _licenseType_ = {} --cache
function p._licenseType(license, i)
i = i or 0
 
if _licenseType_[license] == nil then
-- Tutti i linguaggi sono identificati?
local allFound = true
 
-- È una licenza radice?
-- Il template si è arricchito grazie a Wikidata?
local type = p._singleLicenseType(license)
local improved = false
 
local license_instances = {}
-- Il template non mostra alcun linguaggio?
if type == UNKNOWN then
local noLanguages = not tl_has
-- In `istance of` c'è una licenza radice?
license_instances = rawProperties(license, 'P31')
if license_instances then
type = p._findLicenseType(license_instances)
end
end
 
local license_classes = {}
if wd_languages then
if type == UNKNOWN then
for i, language in pairs(wd_languages) do
-- In `subclass of` c'è una licenza radice?
local wikidataID = mWikidata._formatStatement(language, {formatting = 'raw'})
license_classes = rawProperties(license, 'P279')
language = conf.wikidataToLanguageSlug[wikidataID]
if languagelicense_classes then
type = p._findLicenseType(license_classes)
if tl_languages[language] == nil then
-- 'c' = 'nota linguaggio c'
tl_languages[language] = ''
noLanguages = false
improved = true
end
else
allFound = false
end
end
 
if nszeroi <= MAX_RECURSION then
 
if improved then
-- Risali `istance of`
if tl_has then
if type == UNKNOWN then
-- Wikidata ha migliorato il template e il template aveva già altri valori
if license_instances then
s = s .. '[[Categoria:Linguaggio di programmazione differente da Wikidata]]'
for _, license_instance in pairs(license_instances) do
else
type = p._licenseType(license_instance, i + 1)
-- Wikidata ha migliorato il template che era vuoto
if type ~= UNKNOWN then
s = s .. '[[Categoria:Linguaggio di programmazione letto da Wikidata]]'
break
end
end
end
elseend
 
if #tl_languages > #wd_languages or altri then
-- Risali `subclass of`
-- Nel template c'è qualcosa in più rispetto a Wikidata
if type == UNKNOWN then
s = s .. '[[Categoria:Linguaggio di programmazione differente da Wikidata]]'
if type == UNKNOWN and license_classes then
else
for _, license_class in pairs(license_classes) do
-- Non ha migliorato niente perchè sono gli stessi valori
type = p._licenseType(license_class, i + 1)
s = s .. '[[Categoria:Linguaggio di programmazione uguale a Wikidata]]'
if type ~= UNKNOWN then
break
end
end
end
end
 
-- Non si ha altro su cui aggrapparsi
 
end
 
else
_licenseType_[license] = type
if tl_has and nszero then
end
-- solo se il template specifica linguaggi ma Wikidata no
 
s = s .. '[[Categoria:Linguaggio di programmazione assente su Wikidata]]'
return _licenseType_[license]
end
 
--[[
* Licenze da Wikidata.
*
* @param from string|nil Wikidata item
* @return table|nil
]]
local _licenses_cache = false
function p._licenses(from)
if _licenses_cache == false then
_licenses_cache = mWikidata._getClaims('P275', {from = from}) or {}
end
return _licenses_cache
end
 
--[[
* Ha un certo tipo di licenza?
*
* Per motivi di performance dal 29 luglio 2017 si cerca solo fino alla prima licenza identificabile.
*
* @param type FREE|PROPRIETARY|UNKNOWN
* @param from string|nil Wikidata item
* @return true|false
]]
function p._hasALicenseOfType(type, from)
for _, l in pairs( p._licenses(from) ) do
l = statementQID(l)
if l then
local retrievedType = p._licenseType(l)
if type ~= UNKNOWN then
return type == retrievedType
end
end
end
return false
end
 
--[[
if noLanguages and nszero then
* La voce è sotto licenza di software libero in Wikidata?
if p._isFreeSoftware(frame) then
*
s = s .. '[[Categoria:Software libero senza linguaggio]]'
* @param from string|nil Wikidata item
* @return true|false
]]
function p._hasAFreeLicense(from)
return p._hasALicenseOfType(FREE, from)
end
 
--[[
* La voce è sotto licenza di software proprietario in Wikidata?
*
* @param from string|nil Wikidata item
* @return true|false
]]
function p._hasAProprietaryLicense(from)
return p._hasALicenseOfType(PROPRIETARY, from)
end
 
--[[
* Categorie legate alle licenze da Wikidata.
*
* @param from string|nil Wikidata Item
* @return string
]]
function p._licenseCategories(from)
local s = ''
for i, l in pairs( p._licenses( from ) ) do
local id = statementQID( l ) -- can be nil but don't care
local name = conf.licenseCategory[ id ]
if name then
local cat = conf.licenseCategoryShorter[id] and LICENSE_CAT_SHORTER or LICENSE_CAT
s = s .. formatCategory(cat, name)
else
s = s .. '[[Categoria:Software senza linguaggio]]'UNKNOWN_WD_LICENSE
end
end
return s
end
 
--[[
if not allFound and nszero then
* Categorie legate ai linguaggi da Wikidata.
s = s .. '[[Categoria:Linguaggio di programmazione da Wikidata non previsto]]'
*
* @param from string|nil Wikidata Item
* @return string
]]
function p._languageCategories(from)
local s = ''
local languages = mWikidata._getClaims('P277', {from = from} ) -- Property:programming language
local free = p._isFreeSoftwareByWikidata(from)
local missing = false
if languages then
for _, l in pairs( languages ) do
l = conf.language[ statementQID(l) ]
if l then
s = s .. p._languageCategory(l, free)
else
missing = true
end
end
elseif free then
s = FREE_WITHOUT_LANGUAGE
end
if missing then
s = s .. UNKNOWN_WD_LANGUAGE
end
return s
end
 
--[[
local i = 0
* Categorie legate ai toolkit o framework dell'interfaccia grafica da Wikidata.
for language, note in pairs(tl_languages) do
*
local glue = i > 0 and '<br />' or ''
* @param from string|nil Wikidata Item
s = s .. glue .. frame:expandTemplate{
* @return string
title = 'Software/Linguaggio',
]]
args = {language, categorizza, libero}
function p._toolkitCategories(from)
} .. note
local s = ''
i = i + 1
local toolkits = mWikidata._getClaims('P1414', {from = from} ) -- Property:GUI toolkit or framework
local free = p._isFreeSoftwareByWikidata(from)
local missing = false
if toolkits then
for _, t in pairs( toolkits ) do
t = conf.language[ statementQID( t ) ] -- the ID can be nil but don't care
if t then
s = s .. p._languageCategory(t, free)
else
missing = true
end
end
end
if missing then
s = s .. UNKNOWN_WD_TOOLKIT
end
return s
end
 
--[[
if altri then
* La categoria di uno specifico linguaggio di programmazione.
s = s .. altri
* In realtà questa categorizzazione è analoga anche per i toolkit.
*
* @param language table
* @param free boolean|nil È software libero?
* @param man boolean|nil È a fini di documentazione?
* @param deefault string|nil Valore di default nel caso mancasse
* @see Modulo:Software/Configurazione
* @return string
]]
function p._languageCategory(lang, free, man, default)
local s
if lang.cat then
s = free and lang.free and "Software libero in %s" --free = true
or free == false and lang.nonfree and "Software proprietario in %s" --free = false
or "Software in %s" --free = nil
s = formatCategory(s, lang.cat, man)
end
return s or default or ''
end
 
--[[
return s
* Categoria legata alla data di fondazione.
* @todo Capire quale deve prevalere fra data di pubblicazione e data di creazione
* @param from string|nil Wikidata Item
* @param value string|nil Local value
* @return string
]]
function p._yearsCategories(from, value)
local mCategoryByYear = require('Modulo:Categoria per anno')._main
local creation = mCategoryByYear( { YEAR_CAT, from = from, value = value, raw = true } )
if '' == creation then
return mCategoryByYear( { YEAR_CAT, from = from, value = value, prop = 'P577', checkCat = 'Data di pubblicazione', checkGenre = 'fs' } )
end
return mCategoryByYear( { YEAR_CAT, from = from, value = value } )
end