Mòdul:Location/en
A continuació es mostra la documentació transclosa de la subpàgina /ús. [salta a la caixa de codi]
This is the documentation of Module:Location in English.
This module adds a referent to a location or administrative entity, for example it fetches Berlin (Q64) as "Berlin, Germany".
Syntax
[modifica]- On a sandbox page:
{{#invoke:Location|debug|<Qid>|<Qid2>|lang=<code>}}
- From another module:
require('Module:Location').naming(<label>, _, <lang>, <Qid>, <Qid2>)
- With syntax of Module:Wikidades#Function claim:
case=location
case=locationcontext
Parameters:
- <Qid>, requested, is the Wikidata id of the location. With case=location only this parameter is used considering that the referent is not time-dependent, that the current administrative structure is valid.
- <Qid2>, optional, is the Wikidata id with a context date to be used for avoiding anachronistic references. With case=locationcontext this parameter is fetched from the current page.
- <lang> is the language code, by default the language of local wiki.
- <label>, used from another module, is used to avoid redundant referents.
When used with Module:Wikidades and case parameter, all parameters are obtained by that module.
It is not intented to be used with a template. Comment on the talk page if needed.
Data
[modifica]Data is fetched from Wikidata based on definition of Country (P17). In cases with more detail, it uses Module:Wikidades function getParentValues
with definition of Located in the administrative territorial entity (P131) used recursively. See the documentation Module:Wikidades#Function getParentValues. In you found any supposed inconsistency, check first how these properties are defined on Wikidata.
If the referent is conditioned to a context date, for example in biographical infobox with case=locationcontext, this date is obtained from the current page:
- Properties Date of death (P570), Date of birth (P569) or Work period (start) (P2031).
- Qualifiers Start time (P580) or Point in time (P585) of properties Spouse (P26), Award received (P166), Nominated for (P1411), Position held (P39) or Residence (P551).
The context date is compared with the referent date that indicates from when the referent is valid. The referent date can be defined in the criteria by language, for example the countries of UK are considered from year 1000. Otherwise:
- From table
anachronic_date
with particular cases. - From property Inception (P571).
- By default 1945.
Criteria
[modifica]The general referent is the country. Criteria may change in some cases according to style rules in each language. Currently languages available are: Catalan, English. You can request specific rules for other languages on the talk page.
Rules applied in English are:
- United Kingdom by Constituent country of the United Kingdom (Q3336843) or British overseas territories (Q46395).
- United States by U.S. state (Q35657) or Unincorporated territory of the United States (Q783733).
- Canada by Province of Canada (Q11828004).
- Australia by State of Australia (Q5852411), Mainland territory of Australia (Q14192234) or External territory of Australia (Q11687019).
Otherwise by Country (P17).
There is an exception table for cases where any referent is considered unnecessary as too obvious. Currently if avoids "Washington, D.C., USA".
local p = {}
-- locations where any referent is redundant or innecessary
function p.namingExceptions(id)
local exc_id = {
['Q61'] = true, -- Washington, D.C., USA
}
return exc_id[id]
end
---- Cases by state
-- Australia, by state/territory
local function namingLocationAUS(qid, label, c_date, main)
local adm = main.fetchAdministrativeEntity(qid, 'en')
local adm_entity = main.getAdmByID(adm, 'Q5852411', label) -- state of Australia
if adm_entity == nil then
adm_entity = main.getAdmByID(adm, 'Q14192234', label) -- mainland territory of Australia
if adm_entity == nil then
adm_entity = main.getAdmByID(adm, 'Q11687019', label) -- external territory of Australia
end
end
return main.addReferent(label, adm_entity or 'Australia')
end
-- Canada, by province
local function namingLocationCA(qid, label, c_date, main)
local adm = main.fetchAdministrativeEntity(qid, 'en')
local adm_entity = main.getAdmByID(adm, 'Q11828004', label) -- province of Canada
return main.addReferent(label, adm_entity or 'Canada')
end
-- UK, by country/territory
local function namingLocationUK(qid, label, c_date, main)
if c_date < 1000 then
return label
end
local adm = main.fetchAdministrativeEntity(qid, 'en')
local adm_entity = main.getAdmByID(adm, 'Q3336843', label) -- constituent part of the United Kingdom
if adm_entity == nil then
if c_date < 1700 then
return label
else
adm_entity = main.getAdmByID(adm, 'Q46395', label) -- British Overseas Territories
end
end
return main.addReferent(label, adm_entity or 'United Kingdom')
end
-- USA, by state/territory
local function namingLocationUSA(qid, label, c_date, main)
local adm = main.fetchAdministrativeEntity(qid, 'en')
local adm_entity = main.getAdmByID(adm, 'Q35657', label) -- state of the United States
if adm_entity == nil then
adm_entity = main.getAdmByID(adm, 'Q783733', label) -- unincorporated territory
end
return main.addReferent(label, adm_entity or 'USA')
end
function p.namingLocation(state_id, loc_id, loc_label, context_date, main)
if state_id == 'Q16' then -- Canada
return namingLocationCA(loc_id, loc_label, context_date, main)
elseif state_id == 'Q30' then -- USA
return namingLocationUSA(loc_id, loc_label, context_date, main)
elseif state_id == 'Q145' then -- United Kingdom
return namingLocationUK(loc_id, loc_label, context_date, main)
elseif state_id == 'Q408' then -- Australia
return namingLocationAUS(loc_id, loc_label, context_date, main)
end
return
end
return p