Module:BharatdataIB: Difference between revisions

no edit summary
(Created page with "-- Version: 2023-07-10 -- Module to implement use of a blacklist and whitelist for infobox fields -- Can take a named parameter |qid which is the Wikidata ID for the article -- if not supplied, it will use the Wikidata ID associated with the current page. -- Fields in blacklist are never to be displayed, i.e. module must return nil in all circumstances -- Fields in whitelist return local value if it exists or the Wikidata value otherwise -- The name of the field that thi...")
 
No edit summary
 
Line 1: Line 1:
-- Version: 2023-07-10
-- Version: 2023-07-10
-- Module to implement use of a blacklist and whitelist for infobox fields
-- Module to implement use of a blacklist and whitelist for infobox fields
-- Can take a named parameter |qid which is the Wikidata ID for the article
-- Can take a named parameter |qid which is the Bharatdata ID for the article
-- if not supplied, it will use the Wikidata ID associated with the current page.
-- if not supplied, it will use the Bharatdata ID associated with the current page.
-- Fields in blacklist are never to be displayed, i.e. module must return nil in all circumstances
-- Fields in blacklist are never to be displayed, i.e. module must return nil in all circumstances
-- Fields in whitelist return local value if it exists or the Wikidata value otherwise
-- Fields in whitelist return local value if it exists or the Bharatdata value otherwise
-- The name of the field that this function is called from is passed in named parameter |name
-- The name of the field that this function is called from is passed in named parameter |name
-- The name is compulsory when blacklist or whitelist is used,
-- The name is compulsory when blacklist or whitelist is used,
Line 44: Line 44:
["property-not-found"] = "Property not found.",
["property-not-found"] = "Property not found.",
["No property supplied"] = "No property supplied",
["No property supplied"] = "No property supplied",
["entity-not-found"] = "Wikidata entity not found.",
["entity-not-found"] = "Bharatdata entity not found.",
["unknown-claim-type"] = "Unknown claim type.",
["unknown-claim-type"] = "Unknown claim type.",
["unknown-entity-type"] = "Unknown entity type.",
["unknown-entity-type"] = "Unknown entity type.",
["qualifier-not-found"] = "Qualifier not found.",
["qualifier-not-found"] = "Qualifier not found.",
["site-not-found"] = "Wikimedia project not found.",
["site-not-found"] = "Bharatmedia project not found.",
["labels-not-found"] = "No labels found.",
["labels-not-found"] = "No labels found.",
["descriptions-not-found"] = "No descriptions found.",
["descriptions-not-found"] = "No descriptions found.",
["aliases-not-found"] = "No aliases found.",
["aliases-not-found"] = "No aliases found.",
["unknown-datetime-format"] = "Unknown datetime format.",
["unknown-datetime-format"] = "Unknown datetime format.",
["local-article-not-found"] = "Article is available on Wikidata, but not on Wikipedia",
["local-article-not-found"] = "Article is available on Bharatdata, but not on Bharatpedia",
["dab-page"] = " (dab)",
["dab-page"] = " (dab)",
},
},
Line 75: Line 75:
["NaN"] = "Not a number",
["NaN"] = "Not a number",
-- set the following to the name of a tracking category,
-- set the following to the name of a tracking category,
-- e.g. "[[Category:Articles with missing Wikidata information]]", or "" to disable:
-- e.g. "[[Category:Articles with missing Bharatdata information]]", or "" to disable:
["missinginfocat"] = "[[Category:Articles with missing Wikidata information]]",
["missinginfocat"] = "[[Category:Articles with missing Bharatdata information]]",
["editonwikidata"] = "Edit this on Wikidata",
["editonbharatdata"] = "Edit this on Bharatdata",
["latestdatequalifier"] = function (date) return "before " .. date end,
["latestdatequalifier"] = function (date) return "before " .. date end,
-- some languages, e.g. Bosnian use a period as a suffix after each number in a date
-- some languages, e.g. Bosnian use a period as a suffix after each number in a date
Line 92: Line 92:
-- This allows an internationisation module to override the above table
-- This allows an internationisation module to override the above table
if 'en' ~= mw.getContentLanguage():getCode() then
if 'en' ~= mw.getContentLanguage():getCode() then
require("Module:i18n").loadI18n("Module:WikidataIB/i18n", i18n)
require("Module:i18n").loadI18n("Module:BharatdataIB/i18n", i18n)
end
end


Line 99: Line 99:


-- Some items should not be linked.
-- Some items should not be linked.
-- Each wiki can create a list of those in Module:WikidataIB/nolinks
-- Each wiki can create a list of those in Module:BharatdataIB/nolinks
-- It should return a table called itemsindex, containing true for each item not to be linked
-- It should return a table called itemsindex, containing true for each item not to be linked
local donotlink = {}
local donotlink = {}
local nolinks_exists, nolinks = pcall(mw.loadData, "Module:WikidataIB/nolinks")
local nolinks_exists, nolinks = pcall(mw.loadData, "Module:BharatdataIB/nolinks")
if nolinks_exists then
if nolinks_exists then
donotlink = nolinks.itemsindex
donotlink = nolinks.itemsindex
end
end


-- To satisfy Wikipedia:Manual of Style/Titles, certain types of items are italicised, and others are quoted.
-- To satisfy Bharatpedia:Manual of Style/Titles, certain types of items are italicised, and others are quoted.
-- The submodule [[Module:WikidataIB/titleformats]] lists the entity-ids used in 'instance of' (P31),
-- The submodule [[Module:BharatdataIB/titleformats]] lists the entity-ids used in 'instance of' (P31),
-- which allows this module to identify the values that should be formatted.
-- which allows this module to identify the values that should be formatted.
-- WikidataIB/titleformats exports a table p.formats, which is indexed by entity-id, and contains the value " or ''
-- BharatdataIB/titleformats exports a table p.formats, which is indexed by entity-id, and contains the value " or ''
local formats = {}
local formats = {}
local titleformats_exists, titleformats = pcall(mw.loadData, "Module:WikidataIB/titleformats")
local titleformats_exists, titleformats = pcall(mw.loadData, "Module:BharatdataIB/titleformats")
if titleformats_exists then
if titleformats_exists then
formats = titleformats.formats
formats = titleformats.formats