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 | |||
local | |||
function loadSubmodules(frame) | function loadSubmodules(frame) | ||
25行目: | 16行目: | ||
end | end | ||
i18n = i18n or require(title .. "/i18n") | |||
p.aliasesP = p.aliasesP or mw.loadData(title .. "/aliasesP") | |||
end | end | ||
216行目: | 198行目: | ||
function errorText(code, param) | function errorText(code, param) | ||
local text = | 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, "[.]", | 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=" . | 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 .. "|" . | 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" . | 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 = | 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 = | suffix = i18n['datetime']['suffixes']['millennium'] | ||
else | else | ||
suffix = | suffix = i18n['datetime']['suffixes']['century'] | ||
end | end | ||
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 = | prefix = i18n['datetime']['prefixes']['decade-period'] | ||
suffix = | 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 = | suffix = i18n['datetime']['suffixes']['million-years'] | ||
elseif precision == 0 then | elseif precision == 0 then | ||
suffix = | suffix = i18n['datetime']['suffixes']['billion-years'] | ||
else | else | ||
yRound = yRound * yFactor | yRound = yRound * yFactor | ||
if yRound == 1 then | if yRound == 1 then | ||
suffix = | suffix = i18n['datetime']['suffixes']['year'] | ||
else | else | ||
suffix = | 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( | calendar = " ("..buildWikilink(i18n['datetime']['julian-calendar'], i18n['datetime']['julian'])..")" | ||
else | else | ||
calendar = " (". | calendar = " ("..i18n['datetime']['julian']..")" | ||
end | end | ||
else | else | ||
calendar = "/". | calendar = "/"..i18n['datetime']['julian'] | ||
end | end | ||
end | end | ||
1,010行目: | 992行目: | ||
if sign < 0 then | if sign < 0 then | ||
ce = | ce = i18n['datetime']['BCE'] | ||
elseif precision <= 5 then | elseif precision <= 5 then | ||
ce = | ce = i18n['datetime']['CE'] | ||
end | end | ||
if ce then | if ce then | ||
if link then | if link then | ||
ce = buildWikilink( | 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 = | latDirectionN = i18n['coord']['latitude-north'] | ||
latDirectionS = | latDirectionS = i18n['coord']['latitude-south'] | ||
lonDirectionE = | lonDirectionE = i18n['coord']['longitude-east'] | ||
lonDirectionW = | lonDirectionW = i18n['coord']['longitude-west'] | ||
degSymbol = | degSymbol = i18n['coord']['degrees'] | ||
minSymbol = | minSymbol = i18n['coord']['minutes'] | ||
secSymbol = | secSymbol = i18n['coord']['seconds'] | ||
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 | 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 | 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 | 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 | if i18n['cite'][j][key] ~= "" then | ||
citeParams[j][ | 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][ | 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'][ | 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'][ | 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'][ | citeParams['q'][i18n['cite']['q'][p.aliasesP.statedIn]] = self:getReferenceDetail(statement.snaks, p.aliasesP.statedIn, true) -- raw = true | ||
useCite = citeQ | useCite = citeQ |