「モジュール:Wd」の版間の差分

en:Module:Wd 2017年12月25日 (月) 17:06(UTC)より
template>K-iczn
(en:Module:Wd 2017年12月4日 (月) 19:19(UTC)より)
template>K-iczn
(en:Module:Wd 2017年12月25日 (月) 17:06(UTC)より)
3行目: 3行目:
local p = {}
local p = {}
local arg = ...
local arg = ...
 
local i18n
-- submodules to be loaded;
-- 'true' means: expose through table "p"
local submodules = {
i18n     = false,  -- internationalization
aliasesP = true    -- aliases for P-identifiers
}
 
-- non-exposed submodules will be stored in table "s"
local s = {}


function loadSubmodules(frame)
function loadSubmodules(frame)
25行目: 16行目:
end
end
for i, v in pairs(submodules) do
i18n = i18n or require(title .. "/i18n")
if v then
p.aliasesP = p.aliasesP or mw.loadData(title .. "/aliasesP")
if not p[i] then
p[i] = require(title.."/"..i)
end
else
if not s[i] then
s[i] = require(title.."/"..i)
end
end
end
end
end


216行目: 198行目:


function errorText(code, param)  
function errorText(code, param)  
local text = s.i18n["errors"][code]
local text = i18n["errors"][code]
if param then text = mw.ustring.gsub(text, "$1", param) end
if param then text = mw.ustring.gsub(text, "$1", param) end
return text
return text
226行目: 208行目:


function replaceDecimalMark(num)
function replaceDecimalMark(num)
return mw.ustring.gsub(num, "[.]", s.i18n['numeric']['decimal-mark'], 1)
return mw.ustring.gsub(num, "[.]", i18n['numeric']['decimal-mark'], 1)
end
end


698行目: 680行目:
end
end
value = "[[File:Blue pencil.svg|frameless|text-top|10px|alt=" .. s.i18n['info']['edit-on-wikidata'] .. "|link=https://www.wikidata.org/wiki/" .. prefix .. self.entityID .. "?uselang=" .. self.langCode
value = "[[File:Blue pencil.svg|frameless|text-top|10px|alt=" .. i18n['info']['edit-on-wikidata'] .. "|link=https://www.wikidata.org/wiki/" .. prefix .. self.entityID .. "?uselang=" .. self.langCode
if self.propertyID then
if self.propertyID then
706行目: 688行目:
end
end
value = value .. "|" .. s.i18n['info']['edit-on-wikidata'] .. "]]"
value = value .. "|" .. i18n['info']['edit-on-wikidata'] .. "]]"
return front .. value .. back
return front .. value .. back
734行目: 716行目:
if not skip then
if not skip then
-- add <ref> tag with the reference's hash as its name (to deduplicate references)
-- add <ref> tag with the reference's hash as its name (to deduplicate references)
outString = outString .. mw.getCurrentFrame():extensionTag("ref", valuesArray[i][1], {name = "wikidata-" .. valuesArray[i].refHash .. "-v" .. s.i18n['cite']['version']})
outString = outString .. mw.getCurrentFrame():extensionTag("ref", valuesArray[i][1], {name = "wikidata-" .. valuesArray[i].refHash .. "-v" .. i18n['cite']['version']})
end
end
else
else
836行目: 818行目:
-- add delimiters for readability
-- add delimiters for readability
value = s.i18n.addDelimiters(value)
value = i18n.addDelimiters(value)
end
end
886行目: 868行目:
if not raw then
if not raw then
if precision == 6 then
if precision == 6 then
suffix = s.i18n['datetime']['suffixes']['millennium']
suffix = i18n['datetime']['suffixes']['millennium']
else
else
suffix = s.i18n['datetime']['suffixes']['century']
suffix = i18n['datetime']['suffixes']['century']
end
end
suffix = s.i18n.getOrdinalSuffix(yRound) .. suffix
suffix = i18n.getOrdinalSuffix(yRound) .. suffix
else
else
-- if not verbose, take the first year of the century/millennium
-- if not verbose, take the first year of the century/millennium
903行目: 885行目:
if not raw then
if not raw then
prefix = s.i18n['datetime']['prefixes']['decade-period']
prefix = i18n['datetime']['prefixes']['decade-period']
suffix = s.i18n['datetime']['suffixes']['decade-period']
suffix = i18n['datetime']['suffixes']['decade-period']
end
end
end
end
970行目: 952行目:
if not raw then
if not raw then
if precision == 3 then
if precision == 3 then
suffix = s.i18n['datetime']['suffixes']['million-years']
suffix = i18n['datetime']['suffixes']['million-years']
elseif precision == 0 then
elseif precision == 0 then
suffix = s.i18n['datetime']['suffixes']['billion-years']
suffix = i18n['datetime']['suffixes']['billion-years']
else
else
yRound = yRound * yFactor
yRound = yRound * yFactor
if yRound == 1 then
if yRound == 1 then
suffix = s.i18n['datetime']['suffixes']['year']
suffix = i18n['datetime']['suffixes']['year']
else
else
suffix = s.i18n['datetime']['suffixes']['years']
suffix = i18n['datetime']['suffixes']['years']
end
end
end
end
996行目: 978行目:
if not raw then
if not raw then
if link then
if link then
calendar = " ("..buildWikilink(s.i18n['datetime']['julian-calendar'], s.i18n['datetime']['julian'])..")"
calendar = " ("..buildWikilink(i18n['datetime']['julian-calendar'], i18n['datetime']['julian'])..")"
else
else
calendar = " ("..s.i18n['datetime']['julian']..")"
calendar = " ("..i18n['datetime']['julian']..")"
end
end
else
else
calendar = "/"..s.i18n['datetime']['julian']
calendar = "/"..i18n['datetime']['julian']
end
end
end
end
1,010行目: 992行目:
if sign < 0 then
if sign < 0 then
ce = s.i18n['datetime']['BCE']
ce = i18n['datetime']['BCE']
elseif precision <= 5 then
elseif precision <= 5 then
ce = s.i18n['datetime']['CE']
ce = i18n['datetime']['CE']
end
end
if ce then
if ce then
if link then
if link then
ce = buildWikilink(s.i18n['datetime']['common-era'], ce)
ce = buildWikilink(i18n['datetime']['common-era'], ce)
end
end
suffix = suffix .. " " .. ce
suffix = suffix .. " " .. ce
1,069行目: 1,051行目:
if not raw then
if not raw then
latDirectionN = s.i18n['coord']['latitude-north']
latDirectionN = i18n['coord']['latitude-north']
latDirectionS = s.i18n['coord']['latitude-south']
latDirectionS = i18n['coord']['latitude-south']
lonDirectionE = s.i18n['coord']['longitude-east']
lonDirectionE = i18n['coord']['longitude-east']
lonDirectionW = s.i18n['coord']['longitude-west']
lonDirectionW = i18n['coord']['longitude-west']
degSymbol = s.i18n['coord']['degrees']
degSymbol = i18n['coord']['degrees']
minSymbol = s.i18n['coord']['minutes']
minSymbol = i18n['coord']['minutes']
secSymbol = s.i18n['coord']['seconds']
secSymbol = i18n['coord']['seconds']
separator = s.i18n['coord']['separator']
separator = i18n['coord']['separator']
else
else
latDirectionN = latDirectionEN_N
latDirectionN = latDirectionEN_N
1,206行目: 1,188行目:
return " "  -- single space represents 'somevalue'
return " "  -- single space represents 'somevalue'
else
else
return s.i18n['values']['unknown']
return i18n['values']['unknown']
end
end
elseif snak.snaktype == 'novalue' and not noSpecial then
elseif snak.snaktype == 'novalue' and not noSpecial then
1,212行目: 1,194行目:
return ""  -- empty string represents 'novalue'
return ""  -- empty string represents 'novalue'
else
else
return s.i18n['values']['none']
return i18n['values']['none']
end
end
else
else
1,734行目: 1,716行目:
if not citeMismatch[j] then
if not citeMismatch[j] then
-- check if this parameter is not mismatching itself
-- check if this parameter is not mismatching itself
if s.i18n['cite'][j][key] then
if i18n['cite'][j][key] then
-- continue if an option is available in the corresponding cite template
-- continue if an option is available in the corresponding cite template
if s.i18n['cite'][j][key] ~= "" then
if i18n['cite'][j][key] ~= "" then
citeParams[j][s.i18n['cite'][j][key]] = label .. params[i][1]
citeParams[j][i18n['cite'][j][key]] = label .. params[i][1]
-- if there are multiple parameter values (authors), add those too
-- if there are multiple parameter values (authors), add those too
for k=2, #params[i] do
for k=2, #params[i] do
citeParams[j][s.i18n['cite'][j][key]..k] = label .. params[i][k]
citeParams[j][i18n['cite'][j][key]..k] = label .. params[i][k]
end
end
end
end
1,759行目: 1,741行目:
-- (1) use the general template for citing web references if there is a match and if at least both "reference URL" and "title" are present
-- (1) use the general template for citing web references if there is a match and if at least both "reference URL" and "title" are present
if citeWeb and not citeMismatch['web'] and citeParams['web'][s.i18n['cite']['web'][p.aliasesP.referenceURL]] and citeParams['web'][s.i18n['cite']['web'][p.aliasesP.title]] then
if citeWeb and not citeMismatch['web'] and citeParams['web'][i18n['cite']['web'][p.aliasesP.referenceURL]] and citeParams['web'][i18n['cite']['web'][p.aliasesP.title]] then
useCite = citeWeb
useCite = citeWeb
useParams = citeParams['web']
useParams = citeParams['web']
-- (2) use the template that expands stated-in references into citations if there is a match and if at least "stated in" is present
-- (2) use the template that expands stated-in references into citations if there is a match and if at least "stated in" is present
elseif citeQ and not citeMismatch['q'] and citeParams['q'][s.i18n['cite']['q'][p.aliasesP.statedIn]] then
elseif citeQ and not citeMismatch['q'] and citeParams['q'][i18n['cite']['q'][p.aliasesP.statedIn]] then
-- we need the raw "stated in" Q-identifier for the this template
-- we need the raw "stated in" Q-identifier for the this template
citeParams['q'][s.i18n['cite']['q'][p.aliasesP.statedIn]] = self:getReferenceDetail(statement.snaks, p.aliasesP.statedIn, true)  -- raw = true
citeParams['q'][i18n['cite']['q'][p.aliasesP.statedIn]] = self:getReferenceDetail(statement.snaks, p.aliasesP.statedIn, true)  -- raw = true
useCite = citeQ
useCite = citeQ
匿名利用者