ವಿಕಿಸೋರ್ಸ್
knwikisource
https://kn.wikisource.org/wiki/%E0%B2%AE%E0%B3%81%E0%B2%96%E0%B3%8D%E0%B2%AF_%E0%B2%AA%E0%B3%81%E0%B2%9F
MediaWiki 1.47.0-wmf.16
first-letter
ಮೀಡಿಯ
ವಿಶೇಷ
ಚರ್ಚೆಪುಟ
ಸದಸ್ಯ
ಸದಸ್ಯರ ಚರ್ಚೆಪುಟ
ವಿಕಿಸೋರ್ಸ್
ವಿಕಿಸೋರ್ಸ್ ಚರ್ಚೆ
ಚಿತ್ರ
ಚಿತ್ರ ಚರ್ಚೆಪುಟ
ಮೀಡಿಯವಿಕಿ
ಮೀಡಿಯವಿಕಿ ಚರ್ಚೆಪುಟ
ಟೆಂಪ್ಲೇಟು
ಟೆಂಪ್ಲೇಟು ಚರ್ಚೆಪುಟ
ಸಹಾಯ
ಸಹಾಯ ಚರ್ಚೆಪುಟ
ವರ್ಗ
ವರ್ಗ ಚರ್ಚೆಪುಟ
ಸಂಪುಟ
ಸಂಪುಟ ಚರ್ಚೆ
ಕರ್ತೃ
ಕರ್ತೃ ಚರ್ಚೆ
ಪುಟ
ಪುಟ ಚರ್ಚೆ
ಪರಿವಿಡಿ
ಪರಿವಿಡಿ ಚರ್ಚೆ
ಅನುವಾದ
ಅನುವಾದ ಚರ್ಚೆ
TimedText
TimedText talk
ಮಾಡ್ಯೂಲ್
ಮಾಡ್ಯೂಲ್ ಚರ್ಚೆಪುಟ
Event
Event talk
ಟೆಂಪ್ಲೇಟು:Documentation subpage
10
2219
325317
290789
2026-07-28T15:58:21Z
w>A826
0
೧ revisions imported from [[:en:Template:Documentation_subpage]]
325317
wikitext
text/x-wiki
<includeonly><!--
-->{{#ifeq:{{lc:{{SUBPAGENAME}}}} |{{{override|doc}}}
| <!--(this template has been transcluded on a /doc or /{{{override}}} page)-->
</includeonly><!--
-->{{#ifeq:{{{doc-notice|show}}} |show
| {{Mbox
| type = notice
| style = margin-bottom:1.0em;
| image = [[File:Edit-copy green.svg|40px|alt=icon]]
| text =
{{strong|This is a [[Wikipedia:Template documentation|documentation subpage]]}} for {{terminate sentence|{{{1|[[:{{SUBJECTSPACE}}:{{BASEPAGENAME}}]]}}}}}<br />It may contain usage information, [[Wikipedia:Categorization|categories]] and other content that is not part of the original {{#if:{{{text2|}}} |{{{text2}}} |{{#if:{{{text1|}}} |{{{text1}}} |{{#ifeq:{{SUBJECTSPACE}} |{{ns:User}} |{{lc:{{SUBJECTSPACE}}}} template page |{{#if:{{SUBJECTSPACE}} |{{lc:{{SUBJECTSPACE}}}} page|article}}}}}}}}.
}}
}}<!--
-->{{DEFAULTSORT:{{{defaultsort|{{PAGENAME}}}}}}}<!--
--><includeonly>__EXPECTED_UNCONNECTED_PAGE__</includeonly><!--
-->{{#if:{{{nocat|}}}{{{inhibit|}}}|<!--(don't categorize)-->
|<includeonly><!--
-->{{#ifexist:{{NAMESPACE}}:{{BASEPAGENAME}}
| [[Category:{{#switch:{{SUBJECTSPACE}} |Template=Template |Module=Module |User=User |#default=Wikipedia}} documentation pages]]
| [[Category:Documentation subpages without corresponding pages]]
}}<!--
--></includeonly>
}}<!--
(completing initial #ifeq: at start of template:)
--><includeonly>
| <!--(this template has not been transcluded on a /doc or /{{{override}}} page)-->
}}<!--
--></includeonly><noinclude>{{Documentation}}</noinclude>
iwz7dreef73y68fx96yxyj3ry6l1x58
325318
325317
2026-08-22T10:31:20Z
A826
6806
೧ revisions imported from [[:w:ಟೆಂಪ್ಲೇಟು:Documentation_subpage]]
325317
wikitext
text/x-wiki
<includeonly><!--
-->{{#ifeq:{{lc:{{SUBPAGENAME}}}} |{{{override|doc}}}
| <!--(this template has been transcluded on a /doc or /{{{override}}} page)-->
</includeonly><!--
-->{{#ifeq:{{{doc-notice|show}}} |show
| {{Mbox
| type = notice
| style = margin-bottom:1.0em;
| image = [[File:Edit-copy green.svg|40px|alt=icon]]
| text =
{{strong|This is a [[Wikipedia:Template documentation|documentation subpage]]}} for {{terminate sentence|{{{1|[[:{{SUBJECTSPACE}}:{{BASEPAGENAME}}]]}}}}}<br />It may contain usage information, [[Wikipedia:Categorization|categories]] and other content that is not part of the original {{#if:{{{text2|}}} |{{{text2}}} |{{#if:{{{text1|}}} |{{{text1}}} |{{#ifeq:{{SUBJECTSPACE}} |{{ns:User}} |{{lc:{{SUBJECTSPACE}}}} template page |{{#if:{{SUBJECTSPACE}} |{{lc:{{SUBJECTSPACE}}}} page|article}}}}}}}}.
}}
}}<!--
-->{{DEFAULTSORT:{{{defaultsort|{{PAGENAME}}}}}}}<!--
--><includeonly>__EXPECTED_UNCONNECTED_PAGE__</includeonly><!--
-->{{#if:{{{nocat|}}}{{{inhibit|}}}|<!--(don't categorize)-->
|<includeonly><!--
-->{{#ifexist:{{NAMESPACE}}:{{BASEPAGENAME}}
| [[Category:{{#switch:{{SUBJECTSPACE}} |Template=Template |Module=Module |User=User |#default=Wikipedia}} documentation pages]]
| [[Category:Documentation subpages without corresponding pages]]
}}<!--
--></includeonly>
}}<!--
(completing initial #ifeq: at start of template:)
--><includeonly>
| <!--(this template has not been transcluded on a /doc or /{{{override}}} page)-->
}}<!--
--></includeonly><noinclude>{{Documentation}}</noinclude>
iwz7dreef73y68fx96yxyj3ry6l1x58
ಟೆಂಪ್ಲೇಟು:P
10
11201
325337
23626
2025-12-22T09:33:53Z
w>EmausBot
0
Fixing double redirect from [[ಟೆಂಪ್ಲೇಟು:Property]] to [[ಟೆಂಪ್ಲೇಟು:Wikidata property link]]
325337
wikitext
text/x-wiki
#REDIRECT [[ಟೆಂಪ್ಲೇಟು:Wikidata property link]]
s6yd2baloozn6tr4ok47lpuxmhei3tl
325338
325337
2026-08-22T10:31:22Z
A826
6806
೧ revisions imported from [[:w:ಟೆಂಪ್ಲೇಟು:P]]
325337
wikitext
text/x-wiki
#REDIRECT [[ಟೆಂಪ್ಲೇಟು:Wikidata property link]]
s6yd2baloozn6tr4ok47lpuxmhei3tl
ಮಾಡ್ಯೂಲ್:Fallback
828
78906
325329
188545
2023-10-10T12:40:12Z
w>A826
0
೧ revision imported from [[:d:Module:Fallback]]
325329
Scribunto
text/plain
local p = {}
-- List the full fallback chain from a language to default (usually English)
function p.fblist(lang)
local fbtable = mw.language.getFallbacksFor(lang)
table.insert(fbtable, 1, lang)
--[[
Take a translation from "Mediawiki:<Message-ID>/<language-code>" namespace
or from a loaded i18 resource bundle in MediaWiki for its UI messages (also
used by the "{{Int:<Message-ID>}}" parser function), before using the
provided default value. Requires args.message = 'Message-ID', instead of
args.message = 'actual translated message'.
--]]
table.insert(fbtable, 'message')
table.insert(fbtable, 'default')
return fbtable
end
--[==[
Return an error if there is not default and no English version, otherwise
return the message in the most appropriate, plus the lang code as a second value.
--]==]
function p._langSwitch(args, lang)
-- args: table of translations
if not args.en and not args.default and not args.message and args.nocat ~= '1' then
return error("langSwitch error: no default")
end
-- Get language (either stated one or user's default language).
if not lang then
return '<strong class="error">LangSwitch Error: no lang</strong>' -- must become proper error
end
-- Get the list of acceptable language (lang + those in lang's fallback chain) and check their content.
for _, code in ipairs(p.fblist(lang)) do
local msg = args[code]
if msg then
-- Trim the assigned message value before testing it.
msg = mw.text.trim(msg)
if msg ~= '' then
if code == 'message' then
-- If this is an UI message. See [[mw:Manual:Messages API]].
msg = mw.message.new(args.message):inLanguage(lang)
--[==[ If this message name does not exist, converting it to
a string would not return an actual message, but this name
within curved angle brackets U+29FC/U+29FD '⧼/⧽',
part of mathematical symbols). The UI message may also be
disabled administratively if it causes problems.
--]==]
if msg:exists() and not msg:isDisabled() then
--[==[FIXME: In which language is this message?
This may be in some fallback language and not lang.
Note that some UI messages may have placeholders like '%s'
but there's no way to replace them here by actual values.
--]==]
return tostring(msg), lang
end
elseif msg == '~' then
return nil, code
else
return msg, code
end
end
end
end
return nil
end
--[==[
Version to be used from wikitext.
--]==]
function p.langSwitch(frame)
local args = frame.args
-- If no expected args provided than check parent template/module args.
if not args.en and not args.default and not args.nocat then
args = frame:getParent().args
end
local lang
if args.lang and args.lang ~= '' then
lang = args.lang
args.lang = nil
else -- Get user's chosen language.
lang = frame:preprocess("{{Int:Lang}}")
end
--[==[
if args.zh ~= '' and args['zh-hans'] == '' and args['zh-hant'] == '' then
else
end
--]==]
local str, language = p._langSwitch(args, lang)
return str -- Get the first value of the langSwitch, (the text) not the second (the language).
end
function p.fallbackpage(base, lang, formatting)
local languages = p.fblist(lang)
for i, lng in ipairs(languages) do
if mw.title.new(base .. '/' .. lng).exists then
if formatting == 'table' then
return {base .. '/' .. lng, lng} -- Returns name of the page + name of the language.
else
return base .. '/' .. lng -- Returns only the page.
end
end
end
return base
end
--[==[
Logic for [[Template:Autotranslate]].
]==]
function p.autotranslate(frame)
local args = frame.args
if not args.lang or args.lang == '' then
args.lang = frame:preprocess("{{Int:Lang}}") -- Get user's chosen language.
end
-- Find base page.
local base = args.base
if not base or base == '' then
return '<strong class="error">Base page not provided for autotranslate</strong>'
end
if string.sub(base, 2, 9) ~= 'emplate:' then
base = 'Template:' .. base -- Base provided without 'Template:' part.
end
-- Find base template language subpage.
local page = p.fallbackpage(base, args.lang) --
if (not page and base ~= args.base) then
-- Try the original args.base string. This case is only needed if base is not in template namespace.
page = p.fallbackpage(args.base, args.lang)
end
if not page then
return string.format('<strong class="error">no fallback page found for autotranslate (base=[[%s]], lang=%s)</strong>', args.base, args.lang)
end
-- Repack args in a standard table.
local newargs = {}
for field, value in pairs(args) do
if field ~= 'base' then
newargs[field] = value
end
end
-- Transclude {{page |....}} with template arguments the same as the ones passed to {{autotranslate}} template.
return frame:expandTemplate{ title = page, args = newargs }
end
--[==[
Translate data stored in a module.
]==]
function p.translate(page, key, lang)
if type(page) == 'string' then -- If the requested translation table is not yet loaded.
page = require('Module:' .. page)
end
local val
if page[key] then
val = page[key]
elseif page.keys and page.keys[key] then -- Key 'keys" is an index of all keys, including redirects, see [[Module:i18n/datatype]].
val = page.keys[key]
end
if not val then
return '<' .. key .. '>'
end
return p._langSwitch(val, lang)
end
function p.translatelua(frame)
local lang = frame.args.lang
local page = require('Module:' .. mw.text.trim(frame.args[1])) -- Page should only contain a simple of translations.
if not lang or mw.text.trim(lang) == '' then
lang = frame:preprocess("{{Int:Lang}}")
end
if frame.args[2] then
page = page[mw.text.trim(frame.args[2])]
end
return p._langSwitch(page, lang)
end
-- This test does not work ('Module:Fallback/tests/fallbacks' is missing)
function p.runTests()
local toFallbackTest = require('Module:Fallback/tests/fallbacks')
local result = true
mw.log('Testing fallback chains')
for i, t in ipairs(toFallbackTest) do
local fbtbl = table.concat(p.fblist(t.initial), ', ')
local expected = table.concat(t.expected, ', ')
local ret = (fbtbl == expected)
mw.log(i, ret and 'passed' or 'FAILED', t.initial, (not ret) and ('FAILED\nis >>' .. fbtbl .. '<<\nbut should be >>' .. expected .. '<<\n') or '')
result = result and ret
end
return result
end
--[==[
List all input arguments of the template that calls "{{#invoke:Fallback|showTemplateArguments}}"
]==]
function p.showTemplateArguments(frame)
local str = ''
for name, value in pairs( frame:getParent().args ) do
if str == '' then
str = string.format('%s=%s', name, value) -- argument #1
else
str = string.format('%s, %s=%s', str, name, value) -- the rest
end
end
return str
end
return p
kq13xuoypsd1pyeoa4kyap1puypg48b
325330
325329
2026-08-22T10:31:21Z
A826
6806
೧ revisions imported from [[:w:ಮಾಡ್ಯೂಲ್:Fallback]]
325329
Scribunto
text/plain
local p = {}
-- List the full fallback chain from a language to default (usually English)
function p.fblist(lang)
local fbtable = mw.language.getFallbacksFor(lang)
table.insert(fbtable, 1, lang)
--[[
Take a translation from "Mediawiki:<Message-ID>/<language-code>" namespace
or from a loaded i18 resource bundle in MediaWiki for its UI messages (also
used by the "{{Int:<Message-ID>}}" parser function), before using the
provided default value. Requires args.message = 'Message-ID', instead of
args.message = 'actual translated message'.
--]]
table.insert(fbtable, 'message')
table.insert(fbtable, 'default')
return fbtable
end
--[==[
Return an error if there is not default and no English version, otherwise
return the message in the most appropriate, plus the lang code as a second value.
--]==]
function p._langSwitch(args, lang)
-- args: table of translations
if not args.en and not args.default and not args.message and args.nocat ~= '1' then
return error("langSwitch error: no default")
end
-- Get language (either stated one or user's default language).
if not lang then
return '<strong class="error">LangSwitch Error: no lang</strong>' -- must become proper error
end
-- Get the list of acceptable language (lang + those in lang's fallback chain) and check their content.
for _, code in ipairs(p.fblist(lang)) do
local msg = args[code]
if msg then
-- Trim the assigned message value before testing it.
msg = mw.text.trim(msg)
if msg ~= '' then
if code == 'message' then
-- If this is an UI message. See [[mw:Manual:Messages API]].
msg = mw.message.new(args.message):inLanguage(lang)
--[==[ If this message name does not exist, converting it to
a string would not return an actual message, but this name
within curved angle brackets U+29FC/U+29FD '⧼/⧽',
part of mathematical symbols). The UI message may also be
disabled administratively if it causes problems.
--]==]
if msg:exists() and not msg:isDisabled() then
--[==[FIXME: In which language is this message?
This may be in some fallback language and not lang.
Note that some UI messages may have placeholders like '%s'
but there's no way to replace them here by actual values.
--]==]
return tostring(msg), lang
end
elseif msg == '~' then
return nil, code
else
return msg, code
end
end
end
end
return nil
end
--[==[
Version to be used from wikitext.
--]==]
function p.langSwitch(frame)
local args = frame.args
-- If no expected args provided than check parent template/module args.
if not args.en and not args.default and not args.nocat then
args = frame:getParent().args
end
local lang
if args.lang and args.lang ~= '' then
lang = args.lang
args.lang = nil
else -- Get user's chosen language.
lang = frame:preprocess("{{Int:Lang}}")
end
--[==[
if args.zh ~= '' and args['zh-hans'] == '' and args['zh-hant'] == '' then
else
end
--]==]
local str, language = p._langSwitch(args, lang)
return str -- Get the first value of the langSwitch, (the text) not the second (the language).
end
function p.fallbackpage(base, lang, formatting)
local languages = p.fblist(lang)
for i, lng in ipairs(languages) do
if mw.title.new(base .. '/' .. lng).exists then
if formatting == 'table' then
return {base .. '/' .. lng, lng} -- Returns name of the page + name of the language.
else
return base .. '/' .. lng -- Returns only the page.
end
end
end
return base
end
--[==[
Logic for [[Template:Autotranslate]].
]==]
function p.autotranslate(frame)
local args = frame.args
if not args.lang or args.lang == '' then
args.lang = frame:preprocess("{{Int:Lang}}") -- Get user's chosen language.
end
-- Find base page.
local base = args.base
if not base or base == '' then
return '<strong class="error">Base page not provided for autotranslate</strong>'
end
if string.sub(base, 2, 9) ~= 'emplate:' then
base = 'Template:' .. base -- Base provided without 'Template:' part.
end
-- Find base template language subpage.
local page = p.fallbackpage(base, args.lang) --
if (not page and base ~= args.base) then
-- Try the original args.base string. This case is only needed if base is not in template namespace.
page = p.fallbackpage(args.base, args.lang)
end
if not page then
return string.format('<strong class="error">no fallback page found for autotranslate (base=[[%s]], lang=%s)</strong>', args.base, args.lang)
end
-- Repack args in a standard table.
local newargs = {}
for field, value in pairs(args) do
if field ~= 'base' then
newargs[field] = value
end
end
-- Transclude {{page |....}} with template arguments the same as the ones passed to {{autotranslate}} template.
return frame:expandTemplate{ title = page, args = newargs }
end
--[==[
Translate data stored in a module.
]==]
function p.translate(page, key, lang)
if type(page) == 'string' then -- If the requested translation table is not yet loaded.
page = require('Module:' .. page)
end
local val
if page[key] then
val = page[key]
elseif page.keys and page.keys[key] then -- Key 'keys" is an index of all keys, including redirects, see [[Module:i18n/datatype]].
val = page.keys[key]
end
if not val then
return '<' .. key .. '>'
end
return p._langSwitch(val, lang)
end
function p.translatelua(frame)
local lang = frame.args.lang
local page = require('Module:' .. mw.text.trim(frame.args[1])) -- Page should only contain a simple of translations.
if not lang or mw.text.trim(lang) == '' then
lang = frame:preprocess("{{Int:Lang}}")
end
if frame.args[2] then
page = page[mw.text.trim(frame.args[2])]
end
return p._langSwitch(page, lang)
end
-- This test does not work ('Module:Fallback/tests/fallbacks' is missing)
function p.runTests()
local toFallbackTest = require('Module:Fallback/tests/fallbacks')
local result = true
mw.log('Testing fallback chains')
for i, t in ipairs(toFallbackTest) do
local fbtbl = table.concat(p.fblist(t.initial), ', ')
local expected = table.concat(t.expected, ', ')
local ret = (fbtbl == expected)
mw.log(i, ret and 'passed' or 'FAILED', t.initial, (not ret) and ('FAILED\nis >>' .. fbtbl .. '<<\nbut should be >>' .. expected .. '<<\n') or '')
result = result and ret
end
return result
end
--[==[
List all input arguments of the template that calls "{{#invoke:Fallback|showTemplateArguments}}"
]==]
function p.showTemplateArguments(frame)
local str = ''
for name, value in pairs( frame:getParent().args ) do
if str == '' then
str = string.format('%s=%s', name, value) -- argument #1
else
str = string.format('%s, %s=%s', str, name, value) -- the rest
end
end
return str
end
return p
kq13xuoypsd1pyeoa4kyap1puypg48b
ಟೆಂಪ್ಲೇಟು:!-
10
86233
325315
258311
2025-12-22T05:44:33Z
w>A826
0
೧ revisions imported from [[:d:Template:!-]]
325315
wikitext
text/x-wiki
|-<noinclude>
{{Documentation|Template:!/doc}}
</noinclude>
n2jk3causxfd8p9d39w24erp2uwvmun
325316
325315
2026-08-22T10:31:20Z
A826
6806
೧ revisions imported from [[:w:ಟೆಂಪ್ಲೇಟು:!-]]
325315
wikitext
text/x-wiki
|-<noinclude>
{{Documentation|Template:!/doc}}
</noinclude>
n2jk3causxfd8p9d39w24erp2uwvmun
ಟೆಂಪ್ಲೇಟು:Str left
10
88964
325313
261261
2025-12-22T05:44:32Z
w>A826
0
೧ revisions imported from [[:d:Template:Str_left]]
325313
wikitext
text/x-wiki
<includeonly>{{safesubst:padleft:|{{{2|1}}}|{{{1}}}}}</includeonly><noinclude>
{{Documentation}}
<!-- Categories go on the /doc subpage. -->
</noinclude>
1b6plvfixcru8aabeofs0uj4t46wwdv
325314
325313
2026-08-22T10:31:20Z
A826
6806
೧ revisions imported from [[:w:ಟೆಂಪ್ಲೇಟು:Str_left]]
325313
wikitext
text/x-wiki
<includeonly>{{safesubst:padleft:|{{{2|1}}}|{{{1}}}}}</includeonly><noinclude>
{{Documentation}}
<!-- Categories go on the /doc subpage. -->
</noinclude>
1b6plvfixcru8aabeofs0uj4t46wwdv
ಮಾಡ್ಯೂಲ್:Wd
828
94731
325309
275870
2025-08-03T13:22:40Z
w>A826
0
೧ revisions imported from [[:en:Module:Wd]]
325309
Scribunto
text/plain
-- Original module located at [[:en:Module:Wd]] and [[:en:Module:Wd/i18n]].
require("strict")
local p = {}
local module_arg = ...
local i18n
local i18nPath
local function loadI18n(aliasesP, frame)
local title
if frame then
-- current module invoked by page/template, get its title from frame
title = frame:getTitle()
else
-- current module included by other module, get its title from ...
title = module_arg
end
if not i18n then
i18nPath = title .. "/i18n"
i18n = require(i18nPath).init(aliasesP)
end
end
p.claimCommands = {
property = "property",
properties = "properties",
qualifier = "qualifier",
qualifiers = "qualifiers",
reference = "reference",
references = "references"
}
p.generalCommands = {
label = "label",
title = "title",
description = "description",
alias = "alias",
aliases = "aliases",
badge = "badge",
badges = "badges"
}
p.flags = {
linked = "linked",
short = "short",
raw = "raw",
multilanguage = "multilanguage",
unit = "unit",
-------------
preferred = "preferred",
normal = "normal",
deprecated = "deprecated",
best = "best",
future = "future",
current = "current",
former = "former",
edit = "edit",
editAtEnd = "edit@end",
mdy = "mdy",
single = "single",
sourced = "sourced"
}
p.args = {
eid = "eid",
page = "page",
date = "date",
globalSiteId = "globalSiteId"
}
local aliasesP = {
coord = "P625",
-----------------------
image = "P18",
author = "P50",
authorNameString = "P2093",
publisher = "P123",
importedFrom = "P143",
wikimediaImportURL = "P4656",
statedIn = "P248",
pages = "P304",
language = "P407",
hasPart = "P527",
publicationDate = "P577",
startTime = "P580",
endTime = "P582",
chapter = "P792",
retrieved = "P813",
referenceURL = "P854",
sectionVerseOrParagraph = "P958",
archiveURL = "P1065",
title = "P1476",
formatterURL = "P1630",
quote = "P1683",
shortName = "P1813",
definingFormula = "P2534",
archiveDate = "P2960",
inferredFrom = "P3452",
typeOfReference = "P3865",
column = "P3903",
subjectNamedAs = "P1810",
wikidataProperty = "P1687",
publishedIn = "P1433",
lastUpdate = "P5017"
}
local aliasesQ = {
percentage = "Q11229",
prolepticJulianCalendar = "Q1985786",
citeWeb = "Q5637226",
citeQ = "Q22321052"
}
local parameters = {
property = "%p",
qualifier = "%q",
reference = "%r",
alias = "%a",
badge = "%b",
separator = "%s",
general = "%x"
}
local formats = {
property = "%p[%s][%r]",
qualifier = "%q[%s][%r]",
reference = "%r",
propertyWithQualifier = "%p[ <span style=\"font-size:85\\%\">(%q)</span>][%s][%r]",
alias = "%a[%s]",
badge = "%b[%s]"
}
local hookNames = { -- {level_1, level_2}
[parameters.property] = {"getProperty"},
[parameters.reference] = {"getReferences", "getReference"},
[parameters.qualifier] = {"getAllQualifiers"},
[parameters.qualifier.."\\d"] = {"getQualifiers", "getQualifier"},
[parameters.alias] = {"getAlias"},
[parameters.badge] = {"getBadge"}
}
-- default value objects, should NOT be mutated but instead copied
local defaultSeparators = {
["sep"] = {" "},
["sep%s"] = {","},
["sep%q"] = {"; "},
["sep%q\\d"] = {", "},
["sep%r"] = nil, -- none
["punc"] = nil -- none
}
local rankTable = {
["preferred"] = 1,
["normal"] = 2,
["deprecated"] = 3
}
local function replaceAlias(id)
if aliasesP[id] then
id = aliasesP[id]
end
return id
end
local function errorText(code, ...)
local text = i18n["errors"][code]
if arg then text = mw.ustring.format(text, unpack(arg)) end
return text
end
local function throwError(errorMessage, ...)
error(errorText(errorMessage, unpack(arg)))
end
local function replaceDecimalMark(num)
return mw.ustring.gsub(num, "[.]", i18n['numeric']['decimal-mark'], 1)
end
local function padZeros(num, numDigits)
local numZeros
local negative = false
if num < 0 then
negative = true
num = num * -1
end
num = tostring(num)
numZeros = numDigits - num:len()
for _ = 1, numZeros do
num = "0"..num
end
if negative then
num = "-"..num
end
return num
end
local function replaceSpecialChar(chr)
if chr == '_' then
-- replace underscores with spaces
return ' '
else
return chr
end
end
local function replaceSpecialChars(str)
local chr
local esc = false
local strOut = ""
for i = 1, #str do
chr = str:sub(i,i)
if not esc then
if chr == '\\' then
esc = true
else
strOut = strOut .. replaceSpecialChar(chr)
end
else
strOut = strOut .. chr
esc = false
end
end
return strOut
end
local function buildWikilink(target, label)
if not label or target == label then
return "[[" .. target .. "]]"
else
return "[[" .. target .. "|" .. label .. "]]"
end
end
-- used to make frame.args mutable, to replace #frame.args (which is always 0)
-- with the actual amount and to simply copy tables
local function copyTable(tIn)
if not tIn then
return nil
end
local tOut = {}
for i, v in pairs(tIn) do
tOut[i] = v
end
return tOut
end
-- used to merge output arrays together;
-- note that it currently mutates the first input array
local function mergeArrays(a1, a2)
for i = 1, #a2 do
a1[#a1 + 1] = a2[i]
end
return a1
end
local function split(str, del)
local out = {}
local i, j = str:find(del)
if i and j then
out[1] = str:sub(1, i - 1)
out[2] = str:sub(j + 1)
else
out[1] = str
end
return out
end
local function parseWikidataURL(url)
local id
if url:match('^http[s]?://') then
id = split(url, "Q")
if id[2] then
return "Q" .. id[2]
end
end
return nil
end
local function parseDate(dateStr, precision)
precision = precision or "d"
local i, j, index, ptr
local parts = {nil, nil, nil}
if dateStr == nil then
return parts[1], parts[2], parts[3] -- year, month, day
end
-- 'T' for snak values, '/' for outputs with '/Julian' attached
i, j = dateStr:find("[T/]")
if i then
dateStr = dateStr:sub(1, i-1)
end
local from = 1
if dateStr:sub(1,1) == "-" then
-- this is a negative number, look further ahead
from = 2
end
index = 1
ptr = 1
i, j = dateStr:find("-", from)
if i then
-- year
parts[index] = tonumber(dateStr:sub(ptr, i-1), 10) -- explicitly give base 10 to prevent error
if parts[index] == -0 then
parts[index] = tonumber("0") -- for some reason, 'parts[index] = 0' may actually store '-0', so parse from string instead
end
if precision == "y" then
-- we're done
return parts[1], parts[2], parts[3] -- year, month, day
end
index = index + 1
ptr = i + 1
i, j = dateStr:find("-", ptr)
if i then
-- month
parts[index] = tonumber(dateStr:sub(ptr, i-1), 10)
if precision == "m" then
-- we're done
return parts[1], parts[2], parts[3] -- year, month, day
end
index = index + 1
ptr = i + 1
end
end
if dateStr:sub(ptr) ~= "" then
-- day if we have month, month if we have year, or year
parts[index] = tonumber(dateStr:sub(ptr), 10)
end
return parts[1], parts[2], parts[3] -- year, month, day
end
local function datePrecedesDate(aY, aM, aD, bY, bM, bD)
if aY == nil or bY == nil then
return nil
end
aM = aM or 1
aD = aD or 1
bM = bM or 1
bD = bD or 1
if aY < bY then
return true
end
if aY > bY then
return false
end
if aM < bM then
return true
end
if aM > bM then
return false
end
if aD < bD then
return true
end
return false
end
local function getHookName(param, index)
if hookNames[param] then
return hookNames[param][index]
elseif param:len() > 2 then
return hookNames[param:sub(1, 2).."\\d"][index]
else
return nil
end
end
local function alwaysTrue()
return true
end
-- The following function parses a format string.
--
-- The example below shows how a parsed string is structured in memory.
-- Variables other than 'str' and 'child' are left out for clarity's sake.
--
-- Example:
-- "A %p B [%s[%q1]] C [%r] D"
--
-- Structure:
-- [
-- {
-- str = "A "
-- },
-- {
-- str = "%p"
-- },
-- {
-- str = " B ",
-- child =
-- [
-- {
-- str = "%s",
-- child =
-- [
-- {
-- str = "%q1"
-- }
-- ]
-- }
-- ]
-- },
-- {
-- str = " C ",
-- child =
-- [
-- {
-- str = "%r"
-- }
-- ]
-- },
-- {
-- str = " D"
-- }
-- ]
--
local function parseFormat(str)
local chr, esc, param, root, cur, prev, new
local params = {}
local function newObject(array)
local obj = {} -- new object
obj.str = ""
array[#array + 1] = obj -- array{object}
obj.parent = array
return obj
end
local function endParam()
if param > 0 then
if cur.str ~= "" then
cur.str = "%"..cur.str
cur.param = true
params[cur.str] = true
cur.parent.req[cur.str] = true
prev = cur
cur = newObject(cur.parent)
end
param = 0
end
end
root = {} -- array
root.req = {}
cur = newObject(root)
prev = nil
esc = false
param = 0
for i = 1, #str do
chr = str:sub(i,i)
if not esc then
if chr == '\\' then
endParam()
esc = true
elseif chr == '%' then
endParam()
if cur.str ~= "" then
cur = newObject(cur.parent)
end
param = 2
elseif chr == '[' then
endParam()
if prev and cur.str == "" then
table.remove(cur.parent)
cur = prev
end
cur.child = {} -- new array
cur.child.req = {}
cur.child.parent = cur
cur = newObject(cur.child)
elseif chr == ']' then
endParam()
if cur.parent.parent then
new = newObject(cur.parent.parent.parent)
if cur.str == "" then
table.remove(cur.parent)
end
cur = new
end
else
if param > 1 then
param = param - 1
elseif param == 1 then
if not chr:match('%d') then
endParam()
end
end
cur.str = cur.str .. replaceSpecialChar(chr)
end
else
cur.str = cur.str .. chr
esc = false
end
prev = nil
end
endParam()
-- make sure that at least one required parameter has been defined
if not next(root.req) then
throwError("missing-required-parameter")
end
-- make sure that the separator parameter "%s" is not amongst the required parameters
if root.req[parameters.separator] then
throwError("extra-required-parameter", parameters.separator)
end
return root, params
end
local function sortOnRank(claims)
local rankPos
local ranks = {{}, {}, {}, {}} -- preferred, normal, deprecated, (default)
local sorted = {}
for _, v in ipairs(claims) do
rankPos = rankTable[v.rank] or 4
ranks[rankPos][#ranks[rankPos] + 1] = v
end
sorted = ranks[1]
sorted = mergeArrays(sorted, ranks[2])
sorted = mergeArrays(sorted, ranks[3])
return sorted
end
local function isValueInTable(searchedItem, inputTable)
for _, item in pairs(inputTable) do
if item == searchedItem then
return true
end
end
return false
end
local Config = {}
-- allows for recursive calls
function Config:new()
local cfg = {}
setmetatable(cfg, self)
self.__index = self
cfg.separators = {
-- single value objects wrapped in arrays so that we can pass by reference
["sep"] = {copyTable(defaultSeparators["sep"])},
["sep%s"] = {copyTable(defaultSeparators["sep%s"])},
["sep%q"] = {copyTable(defaultSeparators["sep%q"])},
["sep%r"] = {copyTable(defaultSeparators["sep%r"])},
["punc"] = {copyTable(defaultSeparators["punc"])}
}
cfg.entity = nil
cfg.entityID = nil
cfg.propertyID = nil
cfg.propertyValue = nil
cfg.qualifierIDs = {}
cfg.qualifierIDsAndValues = {}
cfg.bestRank = true
cfg.ranks = {true, true, false} -- preferred = true, normal = true, deprecated = false
cfg.foundRank = #cfg.ranks
cfg.flagBest = false
cfg.flagRank = false
cfg.periods = {true, true, true} -- future = true, current = true, former = true
cfg.flagPeriod = false
cfg.atDate = {parseDate(os.date('!%Y-%m-%d'))} -- today as {year, month, day}
cfg.mdyDate = false
cfg.singleClaim = false
cfg.sourcedOnly = false
cfg.editable = false
cfg.editAtEnd = false
cfg.inSitelinks = false
cfg.langCode = mw.language.getContentLanguage().code
cfg.langName = mw.language.fetchLanguageName(cfg.langCode, cfg.langCode)
cfg.langObj = mw.language.new(cfg.langCode)
cfg.siteID = mw.wikibase.getGlobalSiteId()
cfg.states = {}
cfg.states.qualifiersCount = 0
cfg.curState = nil
cfg.prefetchedRefs = nil
return cfg
end
local State = {}
function State:new(cfg, type)
local stt = {}
setmetatable(stt, self)
self.__index = self
stt.conf = cfg
stt.type = type
stt.results = {}
stt.parsedFormat = {}
stt.separator = {}
stt.movSeparator = {}
stt.puncMark = {}
stt.linked = false
stt.rawValue = false
stt.shortName = false
stt.anyLanguage = false
stt.unitOnly = false
stt.singleValue = false
return stt
end
-- if id == nil then item connected to current page is used
function Config:getLabel(id, raw, link, short)
local label = nil
local prefix, title= "", nil
if not id then
id = mw.wikibase.getEntityIdForCurrentPage()
if not id then
return ""
end
end
id = id:upper() -- just to be sure
if raw then
-- check if given id actually exists
if mw.wikibase.isValidEntityId(id) and mw.wikibase.entityExists(id) then
label = id
end
prefix, title = "d:Special:EntityPage/", label -- may be nil
else
-- try short name first if requested
if short then
label = p._property{aliasesP.shortName, [p.args.eid] = id} -- get short name
if label == "" then
label = nil
end
end
-- get label
if not label then
label = mw.wikibase.getLabel(id)
end
end
if not label then
label = ""
elseif link then
-- build a link if requested
if not title then
if id:sub(1,1) == "Q" then
title = mw.wikibase.getSitelink(id)
elseif id:sub(1,1) == "P" then
-- properties have no sitelink, link to Wikidata instead
prefix, title = "d:Special:EntityPage/", id
end
end
label = mw.text.nowiki(label) -- escape raw label text so it cannot be wikitext markup
if title then
label = buildWikilink(prefix .. title, label)
end
end
return label
end
function Config:getEditIcon()
local value = ""
local prefix = ""
local front = " "
local back = ""
if self.entityID:sub(1,1) == "P" then
prefix = "Property:"
end
if self.editAtEnd then
front = '<span style="float:'
if self.langObj:isRTL() then
front = front .. 'left'
else
front = front .. 'right'
end
front = front .. '">'
back = '</span>'
end
value = "[[File:OOjs UI icon edit-ltr-progressive.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
value = value .. "#" .. self.propertyID
elseif self.inSitelinks then
value = value .. "#sitelinks-wikipedia"
end
value = value .. "|" .. i18n['info']['edit-on-wikidata'] .. "]]"
return front .. value .. back
end
-- used to create the final output string when it's all done, so that for references the
-- function extensionTag("ref", ...) is only called when they really ended up in the final output
function Config:concatValues(valuesArray)
local outString = ""
local j, skip
for i = 1, #valuesArray do
-- check if this is a reference
if valuesArray[i].refHash then
j = i - 1
skip = false
-- skip this reference if it is part of a continuous row of references that already contains the exact same reference
while valuesArray[j] and valuesArray[j].refHash do
if valuesArray[i].refHash == valuesArray[j].refHash then
skip = true
break
end
j = j - 1
end
if not skip then
-- add <ref> tag with the reference's hash as its name (to deduplicate references)
outString = outString .. mw.getCurrentFrame():extensionTag("ref", valuesArray[i][1], {name = valuesArray[i].refHash})
end
else
outString = outString .. valuesArray[i][1]
end
end
return outString
end
function Config:convertUnit(unit, raw, link, short, unitOnly)
local space = " "
local label = ""
local itemID
if unit == "" or unit == "1" then
return nil
end
if unitOnly then
space = ""
end
itemID = parseWikidataURL(unit)
if itemID then
if itemID == aliasesQ.percentage then
return "%"
else
label = self:getLabel(itemID, raw, link, short)
if label ~= "" then
return space .. label
end
end
end
return ""
end
function State:getValue(snak)
return self.conf:getValue(snak, self.rawValue, self.linked, self.shortName, self.anyLanguage, self.unitOnly, false, self.type:sub(1,2))
end
function Config:getValue(snak, raw, link, short, anyLang, unitOnly, noSpecial, type)
if snak.snaktype == 'value' then
local datatype = snak.datavalue.type
local subtype = snak.datatype
local datavalue = snak.datavalue.value
if datatype == 'string' then
if subtype == 'url' and link then
-- create link explicitly
if raw then
-- will render as a linked number like [1]
return "[" .. datavalue .. "]"
else
return "[" .. datavalue .. " " .. datavalue .. "]"
end
elseif subtype == 'commonsMedia' then
if link then
return buildWikilink("c:File:" .. datavalue, datavalue)
elseif not raw then
return "[[File:" .. datavalue .. "]]"
else
return datavalue
end
elseif subtype == 'geo-shape' and link then
return buildWikilink("c:" .. datavalue, datavalue)
elseif subtype == 'math' and not raw then
local attribute = nil
if (type == parameters.property or (type == parameters.qualifier and self.propertyID == aliasesP.hasPart)) and snak.property == aliasesP.definingFormula then
attribute = {qid = self.entityID}
end
return mw.getCurrentFrame():extensionTag("math", datavalue, attribute)
elseif subtype == 'external-id' and link then
local url = p._property{aliasesP.formatterURL, [p.args.eid] = snak.property} -- get formatter URL
if url ~= "" then
url = mw.ustring.gsub(url, "$1", datavalue)
return "[" .. url .. " " .. datavalue .. "]"
else
return datavalue
end
else
return datavalue
end
elseif datatype == 'monolingualtext' then
if anyLang or datavalue['language'] == self.langCode then
return datavalue['text']
else
return nil
end
elseif datatype == 'quantity' then
local value = ""
local unit
if not unitOnly then
-- get value and strip + signs from front
value = mw.ustring.gsub(datavalue['amount'], "^%+(.+)$", "%1")
if raw then
return value
end
-- replace decimal mark based on locale
value = replaceDecimalMark(value)
-- add delimiters for readability
value = i18n.addDelimiters(value)
end
unit = self:convertUnit(datavalue['unit'], raw, link, short, unitOnly)
if unit then
value = value .. unit
end
return value
elseif datatype == 'time' then
local y, m, d, p, yDiv, yRound, yFull, value, calendarID, dateStr
local yFactor = 1
local sign = 1
local prefix = ""
local suffix = ""
local mayAddCalendar = false
local calendar = ""
local precision = datavalue['precision']
if precision == 11 then
p = "d"
elseif precision == 10 then
p = "m"
else
p = "y"
yFactor = 10^(9-precision)
end
y, m, d = parseDate(datavalue['time'], p)
if y < 0 then
sign = -1
y = y * sign
end
-- if precision is tens/hundreds/thousands/millions/billions of years
if precision <= 8 then
yDiv = y / yFactor
-- if precision is tens/hundreds/thousands of years
if precision >= 6 then
mayAddCalendar = true
if precision <= 7 then
-- round centuries/millenniums up (e.g. 20th century or 3rd millennium)
yRound = math.ceil(yDiv)
if not raw then
if precision == 6 then
suffix = i18n['datetime']['suffixes']['millennium']
else
suffix = i18n['datetime']['suffixes']['century']
end
suffix = i18n.getOrdinalSuffix(yRound) .. suffix
else
-- if not verbose, take the first year of the century/millennium
-- (e.g. 1901 for 20th century or 2001 for 3rd millennium)
yRound = (yRound - 1) * yFactor + 1
end
else
-- precision == 8
-- round decades down (e.g. 2010s)
yRound = math.floor(yDiv) * yFactor
if not raw then
prefix = i18n['datetime']['prefixes']['decade-period']
suffix = i18n['datetime']['suffixes']['decade-period']
end
end
if raw and sign < 0 then
-- if BCE then compensate for "counting backwards"
-- (e.g. -2019 for 2010s BCE, -2000 for 20th century BCE or -3000 for 3rd millennium BCE)
yRound = yRound + yFactor - 1
end
else
local yReFactor, yReDiv, yReRound
-- round to nearest for tens of thousands of years or more
yRound = math.floor(yDiv + 0.5)
if yRound == 0 then
if precision <= 2 and y ~= 0 then
yReFactor = 1e6
yReDiv = y / yReFactor
yReRound = math.floor(yReDiv + 0.5)
if yReDiv == yReRound then
-- change precision to millions of years only if we have a whole number of them
precision = 3
yFactor = yReFactor
yRound = yReRound
end
end
if yRound == 0 then
-- otherwise, take the unrounded (original) number of years
precision = 5
yFactor = 1
yRound = y
mayAddCalendar = true
end
end
if precision >= 1 and y ~= 0 then
yFull = yRound * yFactor
yReFactor = 1e9
yReDiv = yFull / yReFactor
yReRound = math.floor(yReDiv + 0.5)
if yReDiv == yReRound then
-- change precision to billions of years if we're in that range
precision = 0
yFactor = yReFactor
yRound = yReRound
else
yReFactor = 1e6
yReDiv = yFull / yReFactor
yReRound = math.floor(yReDiv + 0.5)
if yReDiv == yReRound then
-- change precision to millions of years if we're in that range
precision = 3
yFactor = yReFactor
yRound = yReRound
end
end
end
if not raw then
if precision == 3 then
suffix = i18n['datetime']['suffixes']['million-years']
elseif precision == 0 then
suffix = i18n['datetime']['suffixes']['billion-years']
else
yRound = yRound * yFactor
if yRound == 1 then
suffix = i18n['datetime']['suffixes']['year']
else
suffix = i18n['datetime']['suffixes']['years']
end
end
else
yRound = yRound * yFactor
end
end
else
yRound = y
mayAddCalendar = true
end
if mayAddCalendar then
calendarID = parseWikidataURL(datavalue['calendarmodel'])
if calendarID and calendarID == aliasesQ.prolepticJulianCalendar then
if not raw then
if link then
calendar = " ("..buildWikilink(i18n['datetime']['julian-calendar'], i18n['datetime']['julian'])..")"
else
calendar = " ("..i18n['datetime']['julian']..")"
end
else
calendar = "/"..i18n['datetime']['julian']
end
end
end
if not raw then
local ce = nil
if sign < 0 then
ce = i18n['datetime']['BCE']
elseif precision <= 5 then
ce = i18n['datetime']['CE']
end
if ce then
if link then
ce = buildWikilink(i18n['datetime']['common-era'], ce)
end
suffix = suffix .. " " .. ce
end
value = tostring(yRound)
if m then
dateStr = self.langObj:formatDate("F", "1-"..m.."-1")
if d then
if self.mdyDate then
dateStr = dateStr .. " " .. d .. ","
else
dateStr = d .. " " .. dateStr
end
end
value = dateStr .. " " .. value
end
value = prefix .. value .. suffix .. calendar
else
value = padZeros(yRound * sign, 4)
if m then
value = value .. "-" .. padZeros(m, 2)
if d then
value = value .. "-" .. padZeros(d, 2)
end
end
value = value .. calendar
end
return value
elseif datatype == 'globecoordinate' then
-- logic from https://github.com/DataValues/Geo (v4.0.1)
local precision, unitsPerDegree, numDigits, strFormat, value, globe
local latitude, latConv, latValue, latLink
local longitude, lonConv, lonValue, lonLink
local latDirection, latDirectionN, latDirectionS, latDirectionEN
local lonDirection, lonDirectionE, lonDirectionW, lonDirectionEN
local degSymbol, minSymbol, secSymbol, separator
local latDegrees = nil
local latMinutes = nil
local latSeconds = nil
local lonDegrees = nil
local lonMinutes = nil
local lonSeconds = nil
local latDegSym = ""
local latMinSym = ""
local latSecSym = ""
local lonDegSym = ""
local lonMinSym = ""
local lonSecSym = ""
local latDirectionEN_N = "N"
local latDirectionEN_S = "S"
local lonDirectionEN_E = "E"
local lonDirectionEN_W = "W"
if not raw then
latDirectionN = i18n['coord']['latitude-north']
latDirectionS = i18n['coord']['latitude-south']
lonDirectionE = i18n['coord']['longitude-east']
lonDirectionW = i18n['coord']['longitude-west']
degSymbol = i18n['coord']['degrees']
minSymbol = i18n['coord']['minutes']
secSymbol = i18n['coord']['seconds']
separator = i18n['coord']['separator']
else
latDirectionN = latDirectionEN_N
latDirectionS = latDirectionEN_S
lonDirectionE = lonDirectionEN_E
lonDirectionW = lonDirectionEN_W
degSymbol = "/"
minSymbol = "/"
secSymbol = "/"
separator = "/"
end
latitude = datavalue['latitude']
longitude = datavalue['longitude']
if latitude < 0 then
latDirection = latDirectionS
latDirectionEN = latDirectionEN_S
latitude = math.abs(latitude)
else
latDirection = latDirectionN
latDirectionEN = latDirectionEN_N
end
if longitude < 0 then
lonDirection = lonDirectionW
lonDirectionEN = lonDirectionEN_W
longitude = math.abs(longitude)
else
lonDirection = lonDirectionE
lonDirectionEN = lonDirectionEN_E
end
precision = datavalue['precision']
if not precision or precision <= 0 then
precision = 1 / 3600 -- precision not set (correctly), set to arcsecond
end
-- remove insignificant detail
latitude = math.floor(latitude / precision + 0.5) * precision
longitude = math.floor(longitude / precision + 0.5) * precision
if precision >= 1 - (1 / 60) and precision < 1 then
precision = 1
elseif precision >= (1 / 60) - (1 / 3600) and precision < (1 / 60) then
precision = 1 / 60
end
if precision >= 1 then
unitsPerDegree = 1
elseif precision >= (1 / 60) then
unitsPerDegree = 60
else
unitsPerDegree = 3600
end
numDigits = math.ceil(-math.log10(unitsPerDegree * precision))
if numDigits <= 0 then
numDigits = tonumber("0") -- for some reason, 'numDigits = 0' may actually store '-0', so parse from string instead
end
strFormat = "%." .. numDigits .. "f"
if precision >= 1 then
latDegrees = strFormat:format(latitude)
lonDegrees = strFormat:format(longitude)
if not raw then
latDegSym = replaceDecimalMark(latDegrees) .. degSymbol
lonDegSym = replaceDecimalMark(lonDegrees) .. degSymbol
else
latDegSym = latDegrees .. degSymbol
lonDegSym = lonDegrees .. degSymbol
end
else
latConv = math.floor(latitude * unitsPerDegree * 10^numDigits + 0.5) / 10^numDigits
lonConv = math.floor(longitude * unitsPerDegree * 10^numDigits + 0.5) / 10^numDigits
if precision >= (1 / 60) then
latMinutes = latConv
lonMinutes = lonConv
else
latSeconds = latConv
lonSeconds = lonConv
latMinutes = math.floor(latSeconds / 60)
lonMinutes = math.floor(lonSeconds / 60)
latSeconds = strFormat:format(latSeconds - (latMinutes * 60))
lonSeconds = strFormat:format(lonSeconds - (lonMinutes * 60))
if not raw then
latSecSym = replaceDecimalMark(latSeconds) .. secSymbol
lonSecSym = replaceDecimalMark(lonSeconds) .. secSymbol
else
latSecSym = latSeconds .. secSymbol
lonSecSym = lonSeconds .. secSymbol
end
end
latDegrees = math.floor(latMinutes / 60)
lonDegrees = math.floor(lonMinutes / 60)
latDegSym = latDegrees .. degSymbol
lonDegSym = lonDegrees .. degSymbol
latMinutes = latMinutes - (latDegrees * 60)
lonMinutes = lonMinutes - (lonDegrees * 60)
if precision >= (1 / 60) then
latMinutes = strFormat:format(latMinutes)
lonMinutes = strFormat:format(lonMinutes)
if not raw then
latMinSym = replaceDecimalMark(latMinutes) .. minSymbol
lonMinSym = replaceDecimalMark(lonMinutes) .. minSymbol
else
latMinSym = latMinutes .. minSymbol
lonMinSym = lonMinutes .. minSymbol
end
else
latMinSym = latMinutes .. minSymbol
lonMinSym = lonMinutes .. minSymbol
end
end
latValue = latDegSym .. latMinSym .. latSecSym .. latDirection
lonValue = lonDegSym .. lonMinSym .. lonSecSym .. lonDirection
value = latValue .. separator .. lonValue
if link then
globe = parseWikidataURL(datavalue['globe'])
if globe then
globe = mw.wikibase.getLabelByLang(globe, "en"):lower()
else
globe = "earth"
end
latLink = table.concat({latDegrees, latMinutes, latSeconds}, "_")
lonLink = table.concat({lonDegrees, lonMinutes, lonSeconds}, "_")
value = "[https://geohack.toolforge.org/geohack.php?language="..self.langCode.."¶ms="..latLink.."_"..latDirectionEN.."_"..lonLink.."_"..lonDirectionEN.."_globe:"..globe.." "..value.."]"
end
return value
elseif datatype == 'wikibase-entityid' then
local label
local itemID = datavalue['numeric-id']
if subtype == 'wikibase-item' then
itemID = "Q" .. itemID
elseif subtype == 'wikibase-property' then
itemID = "P" .. itemID
else
return '<strong class="error">' .. errorText('unknown-data-type', subtype) .. '</strong>'
end
label = self:getLabel(itemID, raw, link, short)
if label == "" then
label = nil
end
return label
else
return '<strong class="error">' .. errorText('unknown-data-type', datatype) .. '</strong>'
end
elseif snak.snaktype == 'somevalue' and not noSpecial then
if raw then
return " " -- single space represents 'somevalue'
else
return i18n['values']['unknown']
end
elseif snak.snaktype == 'novalue' and not noSpecial then
if raw then
return "" -- empty string represents 'novalue'
else
return i18n['values']['none']
end
else
return nil
end
end
function Config:getSingleRawQualifier(claim, qualifierID)
local qualifiers
if claim.qualifiers then qualifiers = claim.qualifiers[qualifierID] end
if qualifiers and qualifiers[1] then
return self:getValue(qualifiers[1], true) -- raw = true
else
return nil
end
end
function Config:snakEqualsValue(snak, value)
local snakValue = self:getValue(snak, true) -- raw = true
if snakValue and snak.snaktype == 'value' and snak.datavalue.type == 'wikibase-entityid' then value = value:upper() end
return snakValue == value
end
function Config:setRank(rank)
local rankPos
if rank == p.flags.best then
self.bestRank = true
self.flagBest = true -- mark that 'best' flag was given
return
end
if rank:sub(1,9) == p.flags.preferred then
rankPos = 1
elseif rank:sub(1,6) == p.flags.normal then
rankPos = 2
elseif rank:sub(1,10) == p.flags.deprecated then
rankPos = 3
else
return
end
-- one of the rank flags was given, check if another one was given before
if not self.flagRank then
self.ranks = {false, false, false} -- no other rank flag given before, so unset ranks
self.bestRank = self.flagBest -- unsets bestRank only if 'best' flag was not given before
self.flagRank = true -- mark that a rank flag was given
end
if rank:sub(-1) == "+" then
for i = rankPos, 1, -1 do
self.ranks[i] = true
end
elseif rank:sub(-1) == "-" then
for i = rankPos, #self.ranks do
self.ranks[i] = true
end
else
self.ranks[rankPos] = true
end
end
function Config:setPeriod(period)
local periodPos
if period == p.flags.future then
periodPos = 1
elseif period == p.flags.current then
periodPos = 2
elseif period == p.flags.former then
periodPos = 3
else
return
end
-- one of the period flags was given, check if another one was given before
if not self.flagPeriod then
self.periods = {false, false, false} -- no other period flag given before, so unset periods
self.flagPeriod = true -- mark that a period flag was given
end
self.periods[periodPos] = true
end
function Config:qualifierMatches(claim, id, value)
local qualifiers
if claim.qualifiers then qualifiers = claim.qualifiers[id] end
if qualifiers then
for _, v in pairs(qualifiers) do
if self:snakEqualsValue(v, value) then
return true
end
end
elseif value == "" then
-- if the qualifier is not present then treat it the same as the special value 'novalue'
return true
end
return false
end
function Config:rankMatches(rankPos)
if self.bestRank then
return (self.ranks[rankPos] and self.foundRank >= rankPos)
else
return self.ranks[rankPos]
end
end
function Config:timeMatches(claim)
local startTime = nil
local startTimeY = nil
local startTimeM = nil
local startTimeD = nil
local endTime = nil
local endTimeY = nil
local endTimeM = nil
local endTimeD = nil
if self.periods[1] and self.periods[2] and self.periods[3] then
-- any time
return true
end
startTime = self:getSingleRawQualifier(claim, aliasesP.startTime)
if startTime and startTime ~= "" and startTime ~= " " then
startTimeY, startTimeM, startTimeD = parseDate(startTime)
end
endTime = self:getSingleRawQualifier(claim, aliasesP.endTime)
if endTime and endTime ~= "" and endTime ~= " " then
endTimeY, endTimeM, endTimeD = parseDate(endTime)
end
if startTimeY ~= nil and endTimeY ~= nil and datePrecedesDate(endTimeY, endTimeM, endTimeD, startTimeY, startTimeM, startTimeD) then
-- invalidate end time if it precedes start time
endTimeY = nil
endTimeM = nil
endTimeD = nil
end
if self.periods[1] then
-- future
if startTimeY and datePrecedesDate(self.atDate[1], self.atDate[2], self.atDate[3], startTimeY, startTimeM, startTimeD) then
return true
end
end
if self.periods[2] then
-- current
if (startTimeY == nil or not datePrecedesDate(self.atDate[1], self.atDate[2], self.atDate[3], startTimeY, startTimeM, startTimeD)) and
(endTimeY == nil or datePrecedesDate(self.atDate[1], self.atDate[2], self.atDate[3], endTimeY, endTimeM, endTimeD)) then
return true
end
end
if self.periods[3] then
-- former
if endTimeY and not datePrecedesDate(self.atDate[1], self.atDate[2], self.atDate[3], endTimeY, endTimeM, endTimeD) then
return true
end
end
return false
end
function Config:processFlag(flag)
if not flag then
return false
end
if flag == p.flags.linked then
self.curState.linked = true
return true
elseif flag == p.flags.raw then
self.curState.rawValue = true
if self.curState == self.states[parameters.reference] then
-- raw reference values end with periods and require a separator (other than none)
self.separators["sep%r"][1] = {" "}
end
return true
elseif flag == p.flags.short then
self.curState.shortName = true
return true
elseif flag == p.flags.multilanguage then
self.curState.anyLanguage = true
return true
elseif flag == p.flags.unit then
self.curState.unitOnly = true
return true
elseif flag == p.flags.mdy then
self.mdyDate = true
return true
elseif flag == p.flags.single then
self.singleClaim = true
return true
elseif flag == p.flags.sourced then
self.sourcedOnly = true
return true
elseif flag == p.flags.edit then
self.editable = true
return true
elseif flag == p.flags.editAtEnd then
self.editable = true
self.editAtEnd = true
return true
elseif flag == p.flags.best or flag:match('^'..p.flags.preferred..'[+-]?$') or flag:match('^'..p.flags.normal..'[+-]?$') or flag:match('^'..p.flags.deprecated..'[+-]?$') then
self:setRank(flag)
return true
elseif flag == p.flags.future or flag == p.flags.current or flag == p.flags.former then
self:setPeriod(flag)
return true
elseif flag == "" then
-- ignore empty flags and carry on
return true
else
return false
end
end
function Config:processFlagOrCommand(flag)
local param = ""
if not flag then
return false
end
if flag == p.claimCommands.property or flag == p.claimCommands.properties then
param = parameters.property
elseif flag == p.claimCommands.qualifier or flag == p.claimCommands.qualifiers then
self.states.qualifiersCount = self.states.qualifiersCount + 1
param = parameters.qualifier .. self.states.qualifiersCount
self.separators["sep"..param] = {copyTable(defaultSeparators["sep%q\\d"])}
elseif flag == p.claimCommands.reference or flag == p.claimCommands.references then
param = parameters.reference
else
return self:processFlag(flag)
end
if self.states[param] then
return false
end
-- create a new state for each command
self.states[param] = State:new(self, param)
-- use "%x" as the general parameter name
self.states[param].parsedFormat = parseFormat(parameters.general) -- will be overwritten for param=="%p"
-- set the separator
self.states[param].separator = self.separators["sep"..param] -- will be nil for param=="%p", which will be set separately
if flag == p.claimCommands.property or flag == p.claimCommands.qualifier or flag == p.claimCommands.reference then
self.states[param].singleValue = true
end
self.curState = self.states[param]
return true
end
function Config:processSeparators(args)
local sep
for i, v in pairs(self.separators) do
if args[i] then
sep = replaceSpecialChars(args[i])
if sep ~= "" then
self.separators[i][1] = {sep}
else
self.separators[i][1] = nil
end
end
end
end
function Config:setFormatAndSeparators(state, parsedFormat)
state.parsedFormat = parsedFormat
state.separator = self.separators["sep"]
state.movSeparator = self.separators["sep"..parameters.separator]
state.puncMark = self.separators["punc"]
end
-- determines if a claim has references by prefetching them from the claim using getReferences,
-- which applies some filtering that determines if a reference is actually returned,
-- and caches the references for later use
function State:isSourced(claim)
self.conf.prefetchedRefs = self:getReferences(claim)
return (#self.conf.prefetchedRefs > 0)
end
function State:resetCaches()
-- any prefetched references of the previous claim must not be used
self.conf.prefetchedRefs = nil
end
function State:claimMatches(claim)
local matches, rankPos
-- first of all, reset any cached values used for the previous claim
self:resetCaches()
-- if a property value was given, check if it matches the claim's property value
if self.conf.propertyValue then
matches = self.conf:snakEqualsValue(claim.mainsnak, self.conf.propertyValue)
else
matches = true
end
-- if any qualifier values were given, check if each matches one of the claim's qualifier values
for i, v in pairs(self.conf.qualifierIDsAndValues) do
matches = (matches and self.conf:qualifierMatches(claim, i, v))
end
-- check if the claim's rank and time period match
rankPos = rankTable[claim.rank] or 4
matches = (matches and self.conf:rankMatches(rankPos) and self.conf:timeMatches(claim))
-- if only claims with references must be returned, check if this one has any
if self.conf.sourcedOnly then
matches = (matches and self:isSourced(claim)) -- prefetches and caches references
end
return matches, rankPos
end
function State:out()
local result -- collection of arrays with value objects
local valuesArray -- array with value objects
local sep = nil -- value object
local out = {} -- array with value objects
local function walk(formatTable, result)
local valuesArray = {} -- array with value objects
for i, v in pairs(formatTable.req) do
if not result[i] or not result[i][1] then
-- we've got no result for a parameter that is required on this level,
-- so skip this level (and its children) by returning an empty result
return {}
end
end
for _, v in ipairs(formatTable) do
if v.param then
valuesArray = mergeArrays(valuesArray, result[v.str])
elseif v.str ~= "" then
valuesArray[#valuesArray + 1] = {v.str}
end
if v.child then
valuesArray = mergeArrays(valuesArray, walk(v.child, result))
end
end
return valuesArray
end
-- iterate through the results from back to front, so that we know when to add separators
for i = #self.results, 1, -1 do
result = self.results[i]
-- if there is already some output, then add the separators
if #out > 0 then
sep = self.separator[1] -- fixed separator
result[parameters.separator] = {self.movSeparator[1]} -- movable separator
else
sep = nil
result[parameters.separator] = {self.puncMark[1]} -- optional punctuation mark
end
valuesArray = walk(self.parsedFormat, result)
if #valuesArray > 0 then
if sep then
valuesArray[#valuesArray + 1] = sep
end
out = mergeArrays(valuesArray, out)
end
end
-- reset state before next iteration
self.results = {}
return out
end
-- level 1 hook
function State:getProperty(claim)
local value = {self:getValue(claim.mainsnak)} -- create one value object
if #value > 0 then
return {value} -- wrap the value object in an array and return it
else
return {} -- return empty array if there was no value
end
end
-- level 1 hook
function State:getQualifiers(claim, param)
local qualifiers
if claim.qualifiers then qualifiers = claim.qualifiers[self.conf.qualifierIDs[param]] end
if qualifiers then
-- iterate through claim's qualifier statements to collect their values;
-- return array with multiple value objects
return self.conf.states[param]:iterate(qualifiers, {[parameters.general] = hookNames[parameters.qualifier.."\\d"][2], count = 1}) -- pass qualifier state with level 2 hook
else
return {} -- return empty array
end
end
-- level 2 hook
function State:getQualifier(snak)
local value = {self:getValue(snak)} -- create one value object
if #value > 0 then
return {value} -- wrap the value object in an array and return it
else
return {} -- return empty array if there was no value
end
end
-- level 1 hook
function State:getAllQualifiers(claim, param, result, hooks)
local out = {} -- array with value objects
local sep = self.conf.separators["sep"..parameters.qualifier][1] -- value object
-- iterate through the output of the separate "qualifier(s)" commands
for i = 1, self.conf.states.qualifiersCount do
-- if a hook has not been called yet, call it now
if not result[parameters.qualifier..i] then
self:callHook(parameters.qualifier..i, hooks, claim, result)
end
-- if there is output for this particular "qualifier(s)" command, then add it
if result[parameters.qualifier..i] and result[parameters.qualifier..i][1] then
-- if there is already some output, then add the separator
if #out > 0 and sep then
out[#out + 1] = sep
end
out = mergeArrays(out, result[parameters.qualifier..i])
end
end
return out
end
-- level 1 hook
function State:getReferences(claim)
if self.conf.prefetchedRefs then
-- return references that have been prefetched by isSourced
return self.conf.prefetchedRefs
end
if claim.references then
-- iterate through claim's reference statements to collect their values;
-- return array with multiple value objects
return self.conf.states[parameters.reference]:iterate(claim.references, {[parameters.general] = hookNames[parameters.reference][2], count = 1}) -- pass reference state with level 2 hook
else
return {} -- return empty array
end
end
-- level 2 hook
function State:getReference(statement)
local citeParamMapping = i18n['cite']['param-mapping']
local citeConfig = i18n['cite']['config']
local citeTypes = i18n['cite']['output-types']
-- will hold rendered properties of the reference which are not directly from statement.snaks,
-- Namely, is URL generated from an external ID.
local additionalProcessedProperties = {}
-- for each citation type, there will be an associative array that associates lists of rendered properties
-- to citation-template parameters
local candidateParams = {}
-- like above, but only associates one rendered property to each parameter; if the above variable
-- contains more strings for a parameter, the strings will be assigned to numbered params (e.g. "author1")
local citeParams = {}
local citeErrors = {}
local referenceEmpty = true -- will be set to false if at least one parameter is left unremoved
local version = 12 -- increment this each time the below logic is changed to avoid conflict errors
if not statement.snaks then
return {}
end
-- don't use bot-added references referencing Wikimedia projects or containing "inferred from" (such references are not usable on Wikipedia)
if statement.snaks[aliasesP.importedFrom] or statement.snaks[aliasesP.wikimediaImportURL] or statement.snaks[aliasesP.inferredFrom] then
return {}
end
-- don't include "type of reference"
if statement.snaks[aliasesP.typeOfReference] then
statement.snaks[aliasesP.typeOfReference] = nil
end
-- don't include "image" to prevent littering
if statement.snaks[aliasesP.image] then
statement.snaks[aliasesP.image] = nil
end
-- don't include "language" if it is equal to the local one
if self:getReferenceDetail(statement.snaks, aliasesP.language) == self.conf.langName then
statement.snaks[aliasesP.language] = nil
end
if statement.snaks[aliasesP.statedIn] and not statement.snaks[aliasesP.referenceURL] then
-- "stated in" was given but "reference URL" was not.
-- get "Wikidata property" properties from the item in "stated in"
-- if any of the returned properties of the external-id datatype is in statement.snaks, generate a link from it and use the link in the reference
-- find the "Wikidata property" properties in the item from "stated in"
local wikidataPropertiesOfSource = mw.text.split(p._properties{p.flags.raw, aliasesP.wikidataProperty, [p.args.eid] = self.conf:getValue(statement.snaks[aliasesP.statedIn][1], true, false)}, ", ", true)
for i, wikidataPropertyOfSource in pairs(wikidataPropertiesOfSource) do
if statement.snaks[wikidataPropertyOfSource] and statement.snaks[wikidataPropertyOfSource][1].datatype == "external-id" then
local tempLink = self:getReferenceDetail(statement.snaks, wikidataPropertyOfSource, false, true) -- not raw, linked
if mw.ustring.match(tempLink, "^%[%Z- %Z+%]$") then -- getValue returned a URL in square brackets.
-- the link is in wiki markup, so strip the square brackets and the display text
-- gsub also returns another, discarted value, therefore the result is assigned to tempLink first
tempLink = mw.ustring.gsub(tempLink, "^%[(%Z-) %Z+%]$", "%1")
additionalProcessedProperties[aliasesP.referenceURL] = {tempLink}
statement.snaks[wikidataPropertyOfSource] = nil
break
end
end
end
end
-- initialize candidateParams and citeParams
for _, citeType in ipairs(citeTypes) do
candidateParams[citeType] = {}
citeParams[citeType] = {}
end
-- fill candidateParams
for _, citeType in ipairs(citeTypes) do
-- This will contain value--priority pairs for each param name.
local candidateValuesAndPriorities = {}
-- fill candidateValuesAndPriorities
for refProperty in pairs(statement.snaks) do
if citeErrors[citeType] then
break
end
repeat -- just a simple wrapper to emulate "continue"
-- set mappingKey and prefix
local mappingKey
local prefix = ""
if statement.snaks[refProperty][1].datatype == 'external-id' then
mappingKey = "external-id"
prefix = self.conf:getLabel(refProperty)
if prefix ~= "" then
prefix = prefix .. " "
end
else
mappingKey = refProperty
end
local paramName = citeParamMapping[citeType][mappingKey]
-- skip properties with empty parameter name
if paramName == "" then
break -- skip this property for this value of citeType
end
-- handle unknown properties in the reference
if not paramName then
referenceEmpty = false
local error_message = errorText("unknown-property-in-ref", refProperty)
assert(error_message) -- Should not be nil
citeErrors[citeType] = error_message
break
end
-- set processedProperty
local processedProperty
local raw = false -- if the value is wanted raw
if isValueInTable(paramName, citeConfig[citeType]["raw-value-params"] or {}) then
raw = true
end
if isValueInTable(paramName, citeConfig[citeType]["numbered-params"] or {}) then
-- Multiple values may be given.
processedProperty = self:getReferenceDetails(statement.snaks, refProperty, raw, self.linked, true) -- anyLang = true
else
-- If multiple values are given, all but the first suitable one are discarted.
processedProperty = {self:getReferenceDetail(statement.snaks, refProperty, raw, self.linked and (statement.snaks[refProperty][1].datatype ~= 'url'), true)} -- link = true/false, anyLang = true
end
if #processedProperty == 0 then
break
end
referenceEmpty = false
-- add an empty entry to candidateValuesAndPriorities, if there isn't one already
if not candidateValuesAndPriorities[paramName] then
candidateValuesAndPriorities[paramName] = {}
end
-- find the priority of refProperty
local thisPropertyPriority = -1
local thisParamPrioritization = citeConfig[citeType]["prioritization"][paramName]
if thisParamPrioritization then
for i_priority, i_property in ipairs(thisParamPrioritization) do
if i_property == refProperty then
thisPropertyPriority = i_priority
end
end
end
for _, propertyValue in pairs(processedProperty) do
table.insert(
candidateValuesAndPriorities[paramName],
{prefix .. propertyValue, thisPropertyPriority}
)
end
until true
end
-- fill candidateParams[citeType]
if not citeErrors[citeType] then
local compareValuePriorities = function(pair1, pair2)
if pair1[2] == -1 and pair2[2] ~= -1 then
return false
end
if pair1[2] ~= -1 and pair2[2] == -1 then
return true
end
return pair1[2] < pair2[2]
end
-- fill candidateParams[citeType][paramName] for each used param
for paramName, _ in pairs(candidateValuesAndPriorities) do
table.sort(candidateValuesAndPriorities[paramName], compareValuePriorities)
candidateParams[citeType][paramName] = {}
for _, valuePriorityPair in ipairs(candidateValuesAndPriorities[paramName]) do
table.insert(candidateParams[citeType][paramName], valuePriorityPair[1])
end
end
end
end
-- handle additional properties
for refProperty in pairs(additionalProcessedProperties) do
for _, citeType in ipairs(citeTypes) do
repeat
-- skip if there already have been errors
if citeErrors[citeType] then
break
end
local paramName = citeParamMapping[citeType][refProperty]
-- handle unknown properties in the reference
if not paramName then
-- Skip this additional property, but do not cause an error.
break
end
if paramName == "" then
break
end
referenceEmpty = false
if not candidateParams[citeType][paramName] then
candidateParams[citeType][paramName] = {}
end
for _, propertyValue in pairs(additionalProcessedProperties[refProperty]) do
table.insert(candidateParams[citeType][paramName], propertyValue)
end
until true
end
end
-- fill citeParams
for _, citeType in ipairs(citeTypes) do
for paramName, paramValues in pairs(candidateParams[citeType]) do
if #paramValues == 1 or not isValueInTable(paramName, citeConfig[citeType]["numbered-params"] or {}) then
citeParams[citeType][paramName] = paramValues[1]
else
-- There is more than one value for this parameter - the values will
-- go into separate numbered parameters (e.g. "author1", "author2")
for paramNum, paramValue in pairs(paramValues) do
citeParams[citeType][paramName .. paramNum] = paramValue
end
end
end
end
-- handle missing mandatory parameters for the templates
for _, citeType in ipairs(citeTypes) do
for _, requiredCiteParam in pairs(citeConfig[citeType]["mandatory-params"] or {}) do
if not citeParams[citeType][requiredCiteParam] then -- The required param is not present.
if citeErrors[citeType] then -- Do not override the previous error, if it exists.
break
end
local error_message = errorText("missing-mandatory-param", requiredCiteParam)
assert(error_message) -- Should not be nil
citeErrors[citeType] = error_message
end
end
end
local citeTypeToUse = nil
-- choose the output template
for _, citeType in ipairs(citeTypes) do
if not citeErrors[citeType] then
citeTypeToUse = citeType
break
end
end
-- set refContent
local refContent = ""
if citeTypeToUse then
local templateToUse = citeConfig[citeTypeToUse]["template"]
local paramsToUse = citeParams[citeTypeToUse]
if not templateToUse or templateToUse == "" then
throwError("no-such-reference-template", tostring(templateToUse), i18nPath, citeTypeToUse)
end
-- if this module is being substituted then build a regular template call, otherwise expand the template
if mw.isSubsting() then
for i, v in pairs(paramsToUse) do
refContent = refContent .. "|" .. i .. "=" .. v
end
refContent = "{{" .. templateToUse .. refContent .. "}}"
else
xpcall(
function () refContent = mw.getCurrentFrame():expandTemplate{title=templateToUse, args=paramsToUse} end,
function () throwError("no-such-reference-template", templateToUse, i18nPath, citeTypeToUse) end
)
end
-- If the citation couldn't be displayed using any template, but is not empty (barring ignored propeties), throw an error.
elseif not referenceEmpty then
refContent = errorText("malformed-reference-header")
for _, citeType in ipairs(citeTypes) do
refContent = refContent .. errorText("template-failure-reason", citeConfig[citeType]["template"], citeErrors[citeType])
end
refContent = refContent .. errorText("malformed-reference-footer")
end
-- wrap refContent
local ref = {}
if refContent ~= "" then
ref = {refContent}
if not self.rawValue then
-- this should become a <ref> tag, so save the reference's hash for later
ref.refHash = "wikidata-" .. statement.hash .. "-v" .. (tonumber(i18n['version']) + version)
end
return {ref}
else
return {}
end
end
-- gets a detail of one particular type for a reference
function State:getReferenceDetail(snaks, dType, raw, link, anyLang)
local switchLang = anyLang
local value = nil
if not snaks[dType] then
return nil
end
-- if anyLang, first try the local language and otherwise any language
repeat
for _, v in ipairs(snaks[dType]) do
value = self.conf:getValue(v, raw, link, false, anyLang and not switchLang, false, true) -- noSpecial = true
if value then
break
end
end
if value or not anyLang then
break
end
switchLang = not switchLang
until anyLang and switchLang
return value
end
-- gets the details of one particular type for a reference
function State:getReferenceDetails(snaks, dType, raw, link, anyLang)
local values = {}
if not snaks[dType] then
return {}
end
for _, v in ipairs(snaks[dType]) do
-- if nil is returned then it will not be added to the table
values[#values + 1] = self.conf:getValue(v, raw, link, false, anyLang, false, true) -- noSpecial = true
end
return values
end
-- level 1 hook
function State:getAlias(object)
local value = object.value
local title = nil
if value and self.linked then
if self.conf.entityID:sub(1,1) == "Q" then
title = mw.wikibase.getSitelink(self.conf.entityID)
elseif self.conf.entityID:sub(1,1) == "P" then
title = "d:Property:" .. self.conf.entityID
end
if title then
value = buildWikilink(title, value)
end
end
value = {value} -- create one value object
if #value > 0 then
return {value} -- wrap the value object in an array and return it
else
return {} -- return empty array if there was no value
end
end
-- level 1 hook
function State:getBadge(value)
value = self.conf:getLabel(value, self.rawValue, self.linked, self.shortName)
if value == "" then
value = nil
end
value = {value} -- create one value object
if #value > 0 then
return {value} -- wrap the value object in an array and return it
else
return {} -- return empty array if there was no value
end
end
function State:callHook(param, hooks, statement, result)
-- call a parameter's hook if it has been defined and if it has not been called before
if not result[param] and hooks[param] then
local valuesArray = self[hooks[param]](self, statement, param, result, hooks) -- array with value objects
-- add to the result
if #valuesArray > 0 then
result[param] = valuesArray
result.count = result.count + 1
else
result[param] = {} -- an empty array to indicate that we've tried this hook already
return true -- miss == true
end
end
return false
end
-- iterate through claims, claim's qualifiers or claim's references to collect values
function State:iterate(statements, hooks, matchHook)
matchHook = matchHook or alwaysTrue
local matches = false
local rankPos = nil
local result, gotRequired
for _, v in ipairs(statements) do
-- rankPos will be nil for non-claim statements (e.g. qualifiers, references, etc.)
matches, rankPos = matchHook(self, v)
if matches then
result = {count = 0} -- collection of arrays with value objects
local function walk(formatTable)
local miss
for i2, v2 in pairs(formatTable.req) do
-- call a hook, adding its return value to the result
miss = self:callHook(i2, hooks, v, result)
if miss then
-- we miss a required value for this level, so return false
return false
end
if result.count == hooks.count then
-- we're done if all hooks have been called;
-- returning at this point breaks the loop
return true
end
end
for _, v2 in ipairs(formatTable) do
if result.count == hooks.count then
-- we're done if all hooks have been called;
-- returning at this point prevents further childs from being processed
return true
end
if v2.child then
walk(v2.child)
end
end
return true
end
gotRequired = walk(self.parsedFormat)
-- only append the result if we got values for all required parameters on the root level
if gotRequired then
-- if we have a rankPos (only with matchHook() for complete claims), then update the foundRank
if rankPos and self.conf.foundRank > rankPos then
self.conf.foundRank = rankPos
end
-- append the result
self.results[#self.results + 1] = result
-- break if we only need a single value
if self.singleValue then
break
end
end
end
end
return self:out()
end
local function getEntityId(arg, eid, page, allowOmitPropPrefix, globalSiteId)
local id = nil
local prop = nil
if arg then
if arg:sub(1,1) == ":" then
page = arg
eid = nil
elseif arg:sub(1,1):upper() == "Q" or arg:sub(1,9):lower() == "property:" or allowOmitPropPrefix then
eid = arg
page = nil
else
prop = arg
end
end
if eid then
if eid:sub(1,9):lower() == "property:" then
id = replaceAlias(mw.text.trim(eid:sub(10)))
if id:sub(1,1):upper() ~= "P" then
id = ""
end
else
id = replaceAlias(eid)
end
elseif page then
if page:sub(1,1) == ":" then
page = mw.text.trim(page:sub(2))
end
id = mw.wikibase.getEntityIdForTitle(page, globalSiteId) or ""
end
if not id then
id = mw.wikibase.getEntityIdForCurrentPage() or ""
end
id = id:upper()
if not mw.wikibase.isValidEntityId(id) then
id = ""
end
return id, prop
end
local function nextArg(args)
local arg = args[args.pointer]
if arg then
args.pointer = args.pointer + 1
return mw.text.trim(arg)
else
return nil
end
end
local function claimCommand(args, funcName)
local cfg = Config:new()
cfg:processFlagOrCommand(funcName) -- process first command (== function name)
local lastArg, parsedFormat, formatParams, claims, value
local hooks = {count = 0}
-- set the date if given;
-- must come BEFORE processing the flags
if args[p.args.date] then
cfg.atDate = {parseDate(args[p.args.date])}
cfg.periods = {false, true, false} -- change default time constraint to 'current'
end
-- process flags and commands
repeat
lastArg = nextArg(args)
until not cfg:processFlagOrCommand(lastArg)
-- get the entity ID from either the positional argument, the eid argument or the page argument
cfg.entityID, cfg.propertyID = getEntityId(lastArg, args[p.args.eid], args[p.args.page], false, args[p.args.globalSiteId])
if cfg.entityID == "" then
return "" -- we cannot continue without a valid entity ID
end
cfg.entity = mw.wikibase.getEntity(cfg.entityID)
if not cfg.propertyID then
cfg.propertyID = nextArg(args)
end
cfg.propertyID = replaceAlias(cfg.propertyID)
if not cfg.entity or not cfg.propertyID then
return "" -- we cannot continue without an entity or a property ID
end
cfg.propertyID = cfg.propertyID:upper()
if not cfg.entity.claims or not cfg.entity.claims[cfg.propertyID] then
return "" -- there is no use to continue without any claims
end
claims = cfg.entity.claims[cfg.propertyID]
if cfg.states.qualifiersCount > 0 then
-- do further processing if "qualifier(s)" command was given
if #args - args.pointer + 1 > cfg.states.qualifiersCount then
-- claim ID or literal value has been given
cfg.propertyValue = nextArg(args)
end
for i = 1, cfg.states.qualifiersCount do
-- check if given qualifier ID is an alias and add it
cfg.qualifierIDs[parameters.qualifier..i] = replaceAlias(nextArg(args) or ""):upper()
end
elseif cfg.states[parameters.reference] then
-- do further processing if "reference(s)" command was given
cfg.propertyValue = nextArg(args)
end
-- check for special property value 'somevalue' or 'novalue'
if cfg.propertyValue then
cfg.propertyValue = replaceSpecialChars(cfg.propertyValue)
if cfg.propertyValue ~= "" and mw.text.trim(cfg.propertyValue) == "" then
cfg.propertyValue = " " -- single space represents 'somevalue', whereas empty string represents 'novalue'
else
cfg.propertyValue = mw.text.trim(cfg.propertyValue)
end
end
-- parse the desired format, or choose an appropriate format
if args["format"] then
parsedFormat, formatParams = parseFormat(args["format"])
elseif cfg.states.qualifiersCount > 0 then -- "qualifier(s)" command given
if cfg.states[parameters.property] then -- "propert(y|ies)" command given
parsedFormat, formatParams = parseFormat(formats.propertyWithQualifier)
else
parsedFormat, formatParams = parseFormat(formats.qualifier)
end
elseif cfg.states[parameters.property] then -- "propert(y|ies)" command given
parsedFormat, formatParams = parseFormat(formats.property)
else -- "reference(s)" command given
parsedFormat, formatParams = parseFormat(formats.reference)
end
-- if a "qualifier(s)" command and no "propert(y|ies)" command has been given, make the movable separator a semicolon
if cfg.states.qualifiersCount > 0 and not cfg.states[parameters.property] then
cfg.separators["sep"..parameters.separator][1] = {";"}
end
-- if only "reference(s)" has been given, set the default separator to none (except when raw)
if cfg.states[parameters.reference] and not cfg.states[parameters.property] and cfg.states.qualifiersCount == 0
and not cfg.states[parameters.reference].rawValue then
cfg.separators["sep"][1] = nil
end
-- if exactly one "qualifier(s)" command has been given, make "sep%q" point to "sep%q1" to make them equivalent
if cfg.states.qualifiersCount == 1 then
cfg.separators["sep"..parameters.qualifier] = cfg.separators["sep"..parameters.qualifier.."1"]
end
-- process overridden separator values;
-- must come AFTER tweaking the default separators
cfg:processSeparators(args)
-- define the hooks that should be called (getProperty, getQualifiers, getReferences);
-- only define a hook if both its command ("propert(y|ies)", "reference(s)", "qualifier(s)") and its parameter ("%p", "%r", "%q1", "%q2", "%q3") have been given
for i, v in pairs(cfg.states) do
-- e.g. 'formatParams["%q1"] or formatParams["%q"]' to define hook even if "%q1" was not defined to be able to build a complete value for "%q"
if formatParams[i] or formatParams[i:sub(1, 2)] then
hooks[i] = getHookName(i, 1)
hooks.count = hooks.count + 1
end
end
-- the "%q" parameter is not attached to a state, but is a collection of the results of multiple states (attached to "%q1", "%q2", "%q3", ...);
-- so if this parameter is given then this hook must be defined separately, but only if at least one "qualifier(s)" command has been given
if formatParams[parameters.qualifier] and cfg.states.qualifiersCount > 0 then
hooks[parameters.qualifier] = getHookName(parameters.qualifier, 1)
hooks.count = hooks.count + 1
end
-- create a state for "properties" if it doesn't exist yet, which will be used as a base configuration for each claim iteration;
-- must come AFTER defining the hooks
if not cfg.states[parameters.property] then
cfg.states[parameters.property] = State:new(cfg, parameters.property)
-- if the "single" flag has been given then this state should be equivalent to "property" (singular)
if cfg.singleClaim then
cfg.states[parameters.property].singleValue = true
end
end
-- if the "sourced" flag has been given then create a state for "reference" if it doesn't exist yet, using default values,
-- which must exist in order to be able to determine if a claim has any references;
-- must come AFTER defining the hooks
if cfg.sourcedOnly and not cfg.states[parameters.reference] then
cfg:processFlagOrCommand(p.claimCommands.reference) -- use singular "reference" to minimize overhead
end
-- set the parsed format and the separators (and optional punctuation mark);
-- must come AFTER creating the additonal states
cfg:setFormatAndSeparators(cfg.states[parameters.property], parsedFormat)
-- process qualifier matching values, analogous to cfg.propertyValue
for i, v in pairs(args) do
i = tostring(i)
if i:match('^[Pp]%d+$') or aliasesP[i] then
v = replaceSpecialChars(v)
-- check for special qualifier value 'somevalue'
if v ~= "" and mw.text.trim(v) == "" then
v = " " -- single space represents 'somevalue'
end
cfg.qualifierIDsAndValues[replaceAlias(i):upper()] = v
end
end
-- first sort the claims on rank to pre-define the order of output (preferred first, then normal, then deprecated)
claims = sortOnRank(claims)
-- then iterate through the claims to collect values
value = cfg:concatValues(cfg.states[parameters.property]:iterate(claims, hooks, State.claimMatches)) -- pass property state with level 1 hooks and matchHook
-- if desired, add a clickable icon that may be used to edit the returned values on Wikidata
if cfg.editable and value ~= "" then
value = value .. cfg:getEditIcon()
end
return value
end
local function generalCommand(args, funcName)
local cfg = Config:new()
cfg.curState = State:new(cfg)
local lastArg
local value = nil
repeat
lastArg = nextArg(args)
until not cfg:processFlag(lastArg)
-- get the entity ID from either the positional argument, the eid argument or the page argument
cfg.entityID = getEntityId(lastArg, args[p.args.eid], args[p.args.page], true, args[p.args.globalSiteId])
if cfg.entityID == "" or not mw.wikibase.entityExists(cfg.entityID) then
return "" -- we cannot continue without an entity
end
-- serve according to the given command
if funcName == p.generalCommands.label then
value = cfg:getLabel(cfg.entityID, cfg.curState.rawValue, cfg.curState.linked, cfg.curState.shortName)
elseif funcName == p.generalCommands.title then
cfg.inSitelinks = true
if cfg.entityID:sub(1,1) == "Q" then
value = mw.wikibase.getSitelink(cfg.entityID)
end
if cfg.curState.linked and value then
value = buildWikilink(value)
end
elseif funcName == p.generalCommands.description then
value = mw.wikibase.getDescription(cfg.entityID)
else
local parsedFormat, formatParams
local hooks = {count = 0}
cfg.entity = mw.wikibase.getEntity(cfg.entityID)
if funcName == p.generalCommands.alias or funcName == p.generalCommands.badge then
cfg.curState.singleValue = true
end
if funcName == p.generalCommands.alias or funcName == p.generalCommands.aliases then
if not cfg.entity.aliases or not cfg.entity.aliases[cfg.langCode] then
return "" -- there is no use to continue without any aliasses
end
local aliases = cfg.entity.aliases[cfg.langCode]
-- parse the desired format, or parse the default aliases format
if args["format"] then
parsedFormat, formatParams = parseFormat(args["format"])
else
parsedFormat, formatParams = parseFormat(formats.alias)
end
-- process overridden separator values;
-- must come AFTER tweaking the default separators
cfg:processSeparators(args)
-- define the hook that should be called (getAlias);
-- only define the hook if the parameter ("%a") has been given
if formatParams[parameters.alias] then
hooks[parameters.alias] = getHookName(parameters.alias, 1)
hooks.count = hooks.count + 1
end
-- set the parsed format and the separators (and optional punctuation mark)
cfg:setFormatAndSeparators(cfg.curState, parsedFormat)
-- iterate to collect values
value = cfg:concatValues(cfg.curState:iterate(aliases, hooks))
elseif funcName == p.generalCommands.badge or funcName == p.generalCommands.badges then
if not cfg.entity.sitelinks or not cfg.entity.sitelinks[cfg.siteID] or not cfg.entity.sitelinks[cfg.siteID].badges then
return "" -- there is no use to continue without any badges
end
local badges = cfg.entity.sitelinks[cfg.siteID].badges
cfg.inSitelinks = true
-- parse the desired format, or parse the default aliases format
if args["format"] then
parsedFormat, formatParams = parseFormat(args["format"])
else
parsedFormat, formatParams = parseFormat(formats.badge)
end
-- process overridden separator values;
-- must come AFTER tweaking the default separators
cfg:processSeparators(args)
-- define the hook that should be called (getBadge);
-- only define the hook if the parameter ("%b") has been given
if formatParams[parameters.badge] then
hooks[parameters.badge] = getHookName(parameters.badge, 1)
hooks.count = hooks.count + 1
end
-- set the parsed format and the separators (and optional punctuation mark)
cfg:setFormatAndSeparators(cfg.curState, parsedFormat)
-- iterate to collect values
value = cfg:concatValues(cfg.curState:iterate(badges, hooks))
end
end
value = value or ""
if cfg.editable and value ~= "" then
-- if desired, add a clickable icon that may be used to edit the returned value on Wikidata
value = value .. cfg:getEditIcon()
end
return value
end
-- modules that include this module should call the functions with an underscore prepended, e.g.: p._property(args)
local function establishCommands(commandList, commandFunc)
for _, commandName in pairs(commandList) do
local function wikitextWrapper(frame)
local args = copyTable(frame.args)
args.pointer = 1
loadI18n(aliasesP, frame)
return commandFunc(args, commandName)
end
p[commandName] = wikitextWrapper
local function luaWrapper(args)
args = copyTable(args)
args.pointer = 1
loadI18n(aliasesP)
return commandFunc(args, commandName)
end
p["_" .. commandName] = luaWrapper
end
end
establishCommands(p.claimCommands, claimCommand)
establishCommands(p.generalCommands, generalCommand)
-- main function that is supposed to be used by wrapper templates
function p.main(frame)
if not mw.wikibase then return nil end
local f, args
loadI18n(aliasesP, frame)
-- get the parent frame to take the arguments that were passed to the wrapper template
frame = frame:getParent() or frame
if not frame.args[1] then
throwError("no-function-specified")
end
f = mw.text.trim(frame.args[1])
if f == "main" then
throwError("main-called-twice")
end
assert(p["_"..f], errorText('no-such-function', f))
-- copy arguments from immutable to mutable table
args = copyTable(frame.args)
-- remove the function name from the list
table.remove(args, 1)
return p["_"..f](args)
end
return p
j5a6l03tjwodgrvfnv3lb4x5up93wlv
325310
325144
2026-08-22T10:31:19Z
A826
6806
೧ revisions imported from [[:w:ಮಾಡ್ಯೂಲ್:Wd]]
325144
Scribunto
text/plain
-- Original module located at [[:en:Module:Wd]] and [[:en:Module:Wd/i18n]].
require("strict")
local p = {}
local module_arg = ...
local i18n
local i18nPath
local function loadI18n(aliasesP, frame)
local title
if frame then
-- current module invoked by page/template, get its title from frame
title = frame:getTitle()
else
-- current module included by other module, get its title from ...
title = module_arg
end
if not i18n then
i18nPath = title .. "/i18n"
i18n = require(i18nPath).init(aliasesP)
end
end
p.claimCommands = {
property = "property",
properties = "properties",
qualifier = "qualifier",
qualifiers = "qualifiers",
reference = "reference",
references = "references"
}
p.generalCommands = {
label = "label",
title = "title",
description = "description",
alias = "alias",
aliases = "aliases",
badge = "badge",
badges = "badges"
}
p.flags = {
linked = "linked",
short = "short",
raw = "raw",
multilanguage = "multilanguage",
unit = "unit",
-------------
preferred = "preferred",
normal = "normal",
deprecated = "deprecated",
best = "best",
future = "future",
current = "current",
former = "former",
edit = "edit",
editAtEnd = "edit@end",
mdy = "mdy",
single = "single",
sourced = "sourced"
}
p.args = {
eid = "eid",
page = "page",
date = "date",
globalSiteId = "globalSiteId"
}
local aliasesP = {
coord = "P625",
-----------------------
image = "P18",
author = "P50",
authorNameString = "P2093",
publisher = "P123",
importedFrom = "P143",
wikimediaImportURL = "P4656",
statedIn = "P248",
pages = "P304",
language = "P407",
hasPart = "P527",
publicationDate = "P577",
startTime = "P580",
endTime = "P582",
chapter = "P792",
retrieved = "P813",
referenceURL = "P854",
sectionVerseOrParagraph = "P958",
archiveURL = "P1065",
title = "P1476",
formatterURL = "P1630",
quote = "P1683",
shortName = "P1813",
definingFormula = "P2534",
archiveDate = "P2960",
inferredFrom = "P3452",
typeOfReference = "P3865",
column = "P3903",
subjectNamedAs = "P1810",
wikidataProperty = "P1687",
publishedIn = "P1433",
lastUpdate = "P5017"
}
local aliasesQ = {
percentage = "Q11229",
prolepticJulianCalendar = "Q1985786",
citeWeb = "Q5637226",
citeQ = "Q22321052"
}
local parameters = {
property = "%p",
qualifier = "%q",
reference = "%r",
alias = "%a",
badge = "%b",
separator = "%s",
general = "%x"
}
local formats = {
property = "%p[%s][%r]",
qualifier = "%q[%s][%r]",
reference = "%r",
propertyWithQualifier = "%p[ <span style=\"font-size:85\\%\">(%q)</span>][%s][%r]",
alias = "%a[%s]",
badge = "%b[%s]"
}
local hookNames = { -- {level_1, level_2}
[parameters.property] = {"getProperty"},
[parameters.reference] = {"getReferences", "getReference"},
[parameters.qualifier] = {"getAllQualifiers"},
[parameters.qualifier.."\\d"] = {"getQualifiers", "getQualifier"},
[parameters.alias] = {"getAlias"},
[parameters.badge] = {"getBadge"}
}
-- default value objects, should NOT be mutated but instead copied
local defaultSeparators = {
["sep"] = {" "},
["sep%s"] = {","},
["sep%q"] = {"; "},
["sep%q\\d"] = {", "},
["sep%r"] = nil, -- none
["punc"] = nil -- none
}
local rankTable = {
["preferred"] = 1,
["normal"] = 2,
["deprecated"] = 3
}
local function replaceAlias(id)
if aliasesP[id] then
id = aliasesP[id]
end
return id
end
local function errorText(code, ...)
local text = i18n["errors"][code]
if arg then text = mw.ustring.format(text, unpack(arg)) end
return text
end
local function throwError(errorMessage, ...)
error(errorText(errorMessage, unpack(arg)))
end
local function replaceDecimalMark(num)
return mw.ustring.gsub(num, "[.]", i18n['numeric']['decimal-mark'], 1)
end
local function padZeros(num, numDigits)
local numZeros
local negative = false
if num < 0 then
negative = true
num = num * -1
end
num = tostring(num)
numZeros = numDigits - num:len()
for _ = 1, numZeros do
num = "0"..num
end
if negative then
num = "-"..num
end
return num
end
local function replaceSpecialChar(chr)
if chr == '_' then
-- replace underscores with spaces
return ' '
else
return chr
end
end
local function replaceSpecialChars(str)
local chr
local esc = false
local strOut = ""
for i = 1, #str do
chr = str:sub(i,i)
if not esc then
if chr == '\\' then
esc = true
else
strOut = strOut .. replaceSpecialChar(chr)
end
else
strOut = strOut .. chr
esc = false
end
end
return strOut
end
local function buildWikilink(target, label)
if not label or target == label then
return "[[" .. target .. "]]"
else
return "[[" .. target .. "|" .. label .. "]]"
end
end
-- used to make frame.args mutable, to replace #frame.args (which is always 0)
-- with the actual amount and to simply copy tables
local function copyTable(tIn)
if not tIn then
return nil
end
local tOut = {}
for i, v in pairs(tIn) do
tOut[i] = v
end
return tOut
end
-- used to merge output arrays together;
-- note that it currently mutates the first input array
local function mergeArrays(a1, a2)
for i = 1, #a2 do
a1[#a1 + 1] = a2[i]
end
return a1
end
local function split(str, del)
local out = {}
local i, j = str:find(del)
if i and j then
out[1] = str:sub(1, i - 1)
out[2] = str:sub(j + 1)
else
out[1] = str
end
return out
end
local function parseWikidataURL(url)
local id
if url:match('^http[s]?://') then
id = split(url, "Q")
if id[2] then
return "Q" .. id[2]
end
end
return nil
end
local function parseDate(dateStr, precision)
precision = precision or "d"
local i, j, index, ptr
local parts = {nil, nil, nil}
if dateStr == nil then
return parts[1], parts[2], parts[3] -- year, month, day
end
-- 'T' for snak values, '/' for outputs with '/Julian' attached
i, j = dateStr:find("[T/]")
if i then
dateStr = dateStr:sub(1, i-1)
end
local from = 1
if dateStr:sub(1,1) == "-" then
-- this is a negative number, look further ahead
from = 2
end
index = 1
ptr = 1
i, j = dateStr:find("-", from)
if i then
-- year
parts[index] = tonumber(dateStr:sub(ptr, i-1), 10) -- explicitly give base 10 to prevent error
if parts[index] == -0 then
parts[index] = tonumber("0") -- for some reason, 'parts[index] = 0' may actually store '-0', so parse from string instead
end
if precision == "y" then
-- we're done
return parts[1], parts[2], parts[3] -- year, month, day
end
index = index + 1
ptr = i + 1
i, j = dateStr:find("-", ptr)
if i then
-- month
parts[index] = tonumber(dateStr:sub(ptr, i-1), 10)
if precision == "m" then
-- we're done
return parts[1], parts[2], parts[3] -- year, month, day
end
index = index + 1
ptr = i + 1
end
end
if dateStr:sub(ptr) ~= "" then
-- day if we have month, month if we have year, or year
parts[index] = tonumber(dateStr:sub(ptr), 10)
end
return parts[1], parts[2], parts[3] -- year, month, day
end
local function datePrecedesDate(aY, aM, aD, bY, bM, bD)
if aY == nil or bY == nil then
return nil
end
aM = aM or 1
aD = aD or 1
bM = bM or 1
bD = bD or 1
if aY < bY then
return true
end
if aY > bY then
return false
end
if aM < bM then
return true
end
if aM > bM then
return false
end
if aD < bD then
return true
end
return false
end
local function getHookName(param, index)
if hookNames[param] then
return hookNames[param][index]
elseif param:len() > 2 then
return hookNames[param:sub(1, 2).."\\d"][index]
else
return nil
end
end
local function alwaysTrue()
return true
end
-- The following function parses a format string.
--
-- The example below shows how a parsed string is structured in memory.
-- Variables other than 'str' and 'child' are left out for clarity's sake.
--
-- Example:
-- "A %p B [%s[%q1]] C [%r] D"
--
-- Structure:
-- [
-- {
-- str = "A "
-- },
-- {
-- str = "%p"
-- },
-- {
-- str = " B ",
-- child =
-- [
-- {
-- str = "%s",
-- child =
-- [
-- {
-- str = "%q1"
-- }
-- ]
-- }
-- ]
-- },
-- {
-- str = " C ",
-- child =
-- [
-- {
-- str = "%r"
-- }
-- ]
-- },
-- {
-- str = " D"
-- }
-- ]
--
local function parseFormat(str)
local chr, esc, param, root, cur, prev, new
local params = {}
local function newObject(array)
local obj = {} -- new object
obj.str = ""
array[#array + 1] = obj -- array{object}
obj.parent = array
return obj
end
local function endParam()
if param > 0 then
if cur.str ~= "" then
cur.str = "%"..cur.str
cur.param = true
params[cur.str] = true
cur.parent.req[cur.str] = true
prev = cur
cur = newObject(cur.parent)
end
param = 0
end
end
root = {} -- array
root.req = {}
cur = newObject(root)
prev = nil
esc = false
param = 0
for i = 1, #str do
chr = str:sub(i,i)
if not esc then
if chr == '\\' then
endParam()
esc = true
elseif chr == '%' then
endParam()
if cur.str ~= "" then
cur = newObject(cur.parent)
end
param = 2
elseif chr == '[' then
endParam()
if prev and cur.str == "" then
table.remove(cur.parent)
cur = prev
end
cur.child = {} -- new array
cur.child.req = {}
cur.child.parent = cur
cur = newObject(cur.child)
elseif chr == ']' then
endParam()
if cur.parent.parent then
new = newObject(cur.parent.parent.parent)
if cur.str == "" then
table.remove(cur.parent)
end
cur = new
end
else
if param > 1 then
param = param - 1
elseif param == 1 then
if not chr:match('%d') then
endParam()
end
end
cur.str = cur.str .. replaceSpecialChar(chr)
end
else
cur.str = cur.str .. chr
esc = false
end
prev = nil
end
endParam()
-- make sure that at least one required parameter has been defined
if not next(root.req) then
throwError("missing-required-parameter")
end
-- make sure that the separator parameter "%s" is not amongst the required parameters
if root.req[parameters.separator] then
throwError("extra-required-parameter", parameters.separator)
end
return root, params
end
local function sortOnRank(claims)
local rankPos
local ranks = {{}, {}, {}, {}} -- preferred, normal, deprecated, (default)
local sorted = {}
for _, v in ipairs(claims) do
rankPos = rankTable[v.rank] or 4
ranks[rankPos][#ranks[rankPos] + 1] = v
end
sorted = ranks[1]
sorted = mergeArrays(sorted, ranks[2])
sorted = mergeArrays(sorted, ranks[3])
return sorted
end
local function isValueInTable(searchedItem, inputTable)
for _, item in pairs(inputTable) do
if item == searchedItem then
return true
end
end
return false
end
local Config = {}
-- allows for recursive calls
function Config:new()
local cfg = {}
setmetatable(cfg, self)
self.__index = self
cfg.separators = {
-- single value objects wrapped in arrays so that we can pass by reference
["sep"] = {copyTable(defaultSeparators["sep"])},
["sep%s"] = {copyTable(defaultSeparators["sep%s"])},
["sep%q"] = {copyTable(defaultSeparators["sep%q"])},
["sep%r"] = {copyTable(defaultSeparators["sep%r"])},
["punc"] = {copyTable(defaultSeparators["punc"])}
}
cfg.entity = nil
cfg.entityID = nil
cfg.propertyID = nil
cfg.propertyValue = nil
cfg.qualifierIDs = {}
cfg.qualifierIDsAndValues = {}
cfg.bestRank = true
cfg.ranks = {true, true, false} -- preferred = true, normal = true, deprecated = false
cfg.foundRank = #cfg.ranks
cfg.flagBest = false
cfg.flagRank = false
cfg.periods = {true, true, true} -- future = true, current = true, former = true
cfg.flagPeriod = false
cfg.atDate = {parseDate(os.date('!%Y-%m-%d'))} -- today as {year, month, day}
cfg.mdyDate = false
cfg.singleClaim = false
cfg.sourcedOnly = false
cfg.editable = false
cfg.editAtEnd = false
cfg.inSitelinks = false
cfg.langCode = mw.language.getContentLanguage().code
cfg.langName = mw.language.fetchLanguageName(cfg.langCode, cfg.langCode)
cfg.langObj = mw.language.new(cfg.langCode)
cfg.siteID = mw.wikibase.getGlobalSiteId()
cfg.states = {}
cfg.states.qualifiersCount = 0
cfg.curState = nil
cfg.prefetchedRefs = nil
return cfg
end
local State = {}
function State:new(cfg, type)
local stt = {}
setmetatable(stt, self)
self.__index = self
stt.conf = cfg
stt.type = type
stt.results = {}
stt.parsedFormat = {}
stt.separator = {}
stt.movSeparator = {}
stt.puncMark = {}
stt.linked = false
stt.rawValue = false
stt.shortName = false
stt.anyLanguage = false
stt.unitOnly = false
stt.singleValue = false
return stt
end
-- if id == nil then item connected to current page is used
function Config:getLabel(id, raw, link, short)
local label = nil
local prefix, title= "", nil
if not id then
id = mw.wikibase.getEntityIdForCurrentPage()
if not id then
return ""
end
end
id = id:upper() -- just to be sure
if raw then
-- check if given id actually exists
if mw.wikibase.isValidEntityId(id) and mw.wikibase.entityExists(id) then
label = id
end
prefix, title = "d:Special:EntityPage/", label -- may be nil
else
-- try short name first if requested
if short then
label = p._property{aliasesP.shortName, [p.args.eid] = id} -- get short name
if label == "" then
label = nil
end
end
-- get label
if not label then
label = mw.wikibase.getLabel(id)
end
end
if not label then
label = ""
elseif link then
-- build a link if requested
if not title then
if id:sub(1,1) == "Q" then
title = mw.wikibase.getSitelink(id)
elseif id:sub(1,1) == "P" then
-- properties have no sitelink, link to Wikidata instead
prefix, title = "d:Special:EntityPage/", id
end
end
label = mw.text.nowiki(label) -- escape raw label text so it cannot be wikitext markup
if title then
label = buildWikilink(prefix .. title, label)
end
end
return label
end
function Config:getEditIcon()
local value = ""
local prefix = ""
local front = " "
local back = ""
if self.entityID:sub(1,1) == "P" then
prefix = "Property:"
end
if self.editAtEnd then
front = '<span style="float:'
if self.langObj:isRTL() then
front = front .. 'left'
else
front = front .. 'right'
end
front = front .. '">'
back = '</span>'
end
value = "[[File:OOjs UI icon edit-ltr-progressive.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
value = value .. "#" .. self.propertyID
elseif self.inSitelinks then
value = value .. "#sitelinks-wikipedia"
end
value = value .. "|" .. i18n['info']['edit-on-wikidata'] .. "]]"
return front .. value .. back
end
-- used to create the final output string when it's all done, so that for references the
-- function extensionTag("ref", ...) is only called when they really ended up in the final output
function Config:concatValues(valuesArray)
local outString = ""
local j, skip
for i = 1, #valuesArray do
-- check if this is a reference
if valuesArray[i].refHash then
j = i - 1
skip = false
-- skip this reference if it is part of a continuous row of references that already contains the exact same reference
while valuesArray[j] and valuesArray[j].refHash do
if valuesArray[i].refHash == valuesArray[j].refHash then
skip = true
break
end
j = j - 1
end
if not skip then
-- add <ref> tag with the reference's hash as its name (to deduplicate references)
outString = outString .. mw.getCurrentFrame():extensionTag("ref", valuesArray[i][1], {name = valuesArray[i].refHash})
end
else
outString = outString .. valuesArray[i][1]
end
end
return outString
end
function Config:convertUnit(unit, raw, link, short, unitOnly)
local space = " "
local label = ""
local itemID
if unit == "" or unit == "1" then
return nil
end
if unitOnly then
space = ""
end
itemID = parseWikidataURL(unit)
if itemID then
if itemID == aliasesQ.percentage then
return "%"
else
label = self:getLabel(itemID, raw, link, short)
if label ~= "" then
return space .. label
end
end
end
return ""
end
function State:getValue(snak)
return self.conf:getValue(snak, self.rawValue, self.linked, self.shortName, self.anyLanguage, self.unitOnly, false, self.type:sub(1,2))
end
function Config:getValue(snak, raw, link, short, anyLang, unitOnly, noSpecial, type)
if snak.snaktype == 'value' then
local datatype = snak.datavalue.type
local subtype = snak.datatype
local datavalue = snak.datavalue.value
if datatype == 'string' then
if subtype == 'url' and link then
-- create link explicitly
if raw then
-- will render as a linked number like [1]
return "[" .. datavalue .. "]"
else
return "[" .. datavalue .. " " .. datavalue .. "]"
end
elseif subtype == 'commonsMedia' then
if link then
return buildWikilink("c:File:" .. datavalue, datavalue)
elseif not raw then
return "[[File:" .. datavalue .. "]]"
else
return datavalue
end
elseif subtype == 'geo-shape' and link then
return buildWikilink("c:" .. datavalue, datavalue)
elseif subtype == 'math' and not raw then
local attribute = nil
if (type == parameters.property or (type == parameters.qualifier and self.propertyID == aliasesP.hasPart)) and snak.property == aliasesP.definingFormula then
attribute = {qid = self.entityID}
end
return mw.getCurrentFrame():extensionTag("math", datavalue, attribute)
elseif subtype == 'external-id' and link then
local url = p._property{aliasesP.formatterURL, [p.args.eid] = snak.property} -- get formatter URL
if url ~= "" then
url = mw.ustring.gsub(url, "$1", datavalue)
return "[" .. url .. " " .. datavalue .. "]"
else
return datavalue
end
else
return datavalue
end
elseif datatype == 'monolingualtext' then
if anyLang or datavalue['language'] == self.langCode then
return datavalue['text']
else
return nil
end
elseif datatype == 'quantity' then
local value = ""
local unit
if not unitOnly then
-- get value and strip + signs from front
value = mw.ustring.gsub(datavalue['amount'], "^%+(.+)$", "%1")
if raw then
return value
end
-- replace decimal mark based on locale
value = replaceDecimalMark(value)
-- add delimiters for readability
value = i18n.addDelimiters(value)
end
unit = self:convertUnit(datavalue['unit'], raw, link, short, unitOnly)
if unit then
value = value .. unit
end
return value
elseif datatype == 'time' then
local y, m, d, p, yDiv, yRound, yFull, value, calendarID, dateStr
local yFactor = 1
local sign = 1
local prefix = ""
local suffix = ""
local mayAddCalendar = false
local calendar = ""
local precision = datavalue['precision']
if precision == 11 then
p = "d"
elseif precision == 10 then
p = "m"
else
p = "y"
yFactor = 10^(9-precision)
end
y, m, d = parseDate(datavalue['time'], p)
if y < 0 then
sign = -1
y = y * sign
end
-- if precision is tens/hundreds/thousands/millions/billions of years
if precision <= 8 then
yDiv = y / yFactor
-- if precision is tens/hundreds/thousands of years
if precision >= 6 then
mayAddCalendar = true
if precision <= 7 then
-- round centuries/millenniums up (e.g. 20th century or 3rd millennium)
yRound = math.ceil(yDiv)
if not raw then
if precision == 6 then
suffix = i18n['datetime']['suffixes']['millennium']
else
suffix = i18n['datetime']['suffixes']['century']
end
suffix = i18n.getOrdinalSuffix(yRound) .. suffix
else
-- if not verbose, take the first year of the century/millennium
-- (e.g. 1901 for 20th century or 2001 for 3rd millennium)
yRound = (yRound - 1) * yFactor + 1
end
else
-- precision == 8
-- round decades down (e.g. 2010s)
yRound = math.floor(yDiv) * yFactor
if not raw then
prefix = i18n['datetime']['prefixes']['decade-period']
suffix = i18n['datetime']['suffixes']['decade-period']
end
end
if raw and sign < 0 then
-- if BCE then compensate for "counting backwards"
-- (e.g. -2019 for 2010s BCE, -2000 for 20th century BCE or -3000 for 3rd millennium BCE)
yRound = yRound + yFactor - 1
end
else
local yReFactor, yReDiv, yReRound
-- round to nearest for tens of thousands of years or more
yRound = math.floor(yDiv + 0.5)
if yRound == 0 then
if precision <= 2 and y ~= 0 then
yReFactor = 1e6
yReDiv = y / yReFactor
yReRound = math.floor(yReDiv + 0.5)
if yReDiv == yReRound then
-- change precision to millions of years only if we have a whole number of them
precision = 3
yFactor = yReFactor
yRound = yReRound
end
end
if yRound == 0 then
-- otherwise, take the unrounded (original) number of years
precision = 5
yFactor = 1
yRound = y
mayAddCalendar = true
end
end
if precision >= 1 and y ~= 0 then
yFull = yRound * yFactor
yReFactor = 1e9
yReDiv = yFull / yReFactor
yReRound = math.floor(yReDiv + 0.5)
if yReDiv == yReRound then
-- change precision to billions of years if we're in that range
precision = 0
yFactor = yReFactor
yRound = yReRound
else
yReFactor = 1e6
yReDiv = yFull / yReFactor
yReRound = math.floor(yReDiv + 0.5)
if yReDiv == yReRound then
-- change precision to millions of years if we're in that range
precision = 3
yFactor = yReFactor
yRound = yReRound
end
end
end
if not raw then
if precision == 3 then
suffix = i18n['datetime']['suffixes']['million-years']
elseif precision == 0 then
suffix = i18n['datetime']['suffixes']['billion-years']
else
yRound = yRound * yFactor
if yRound == 1 then
suffix = i18n['datetime']['suffixes']['year']
else
suffix = i18n['datetime']['suffixes']['years']
end
end
else
yRound = yRound * yFactor
end
end
else
yRound = y
mayAddCalendar = true
end
if mayAddCalendar then
calendarID = parseWikidataURL(datavalue['calendarmodel'])
if calendarID and calendarID == aliasesQ.prolepticJulianCalendar then
if not raw then
if link then
calendar = " ("..buildWikilink(i18n['datetime']['julian-calendar'], i18n['datetime']['julian'])..")"
else
calendar = " ("..i18n['datetime']['julian']..")"
end
else
calendar = "/"..i18n['datetime']['julian']
end
end
end
if not raw then
local ce = nil
if sign < 0 then
ce = i18n['datetime']['BCE']
elseif precision <= 5 then
ce = i18n['datetime']['CE']
end
if ce then
if link then
ce = buildWikilink(i18n['datetime']['common-era'], ce)
end
suffix = suffix .. " " .. ce
end
value = tostring(yRound)
if m then
dateStr = self.langObj:formatDate("F", "1-"..m.."-1")
if d then
if self.mdyDate then
dateStr = dateStr .. " " .. d .. ","
else
dateStr = d .. " " .. dateStr
end
end
value = dateStr .. " " .. value
end
value = prefix .. value .. suffix .. calendar
else
value = padZeros(yRound * sign, 4)
if m then
value = value .. "-" .. padZeros(m, 2)
if d then
value = value .. "-" .. padZeros(d, 2)
end
end
value = value .. calendar
end
return value
elseif datatype == 'globecoordinate' then
-- logic from https://github.com/DataValues/Geo (v4.0.1)
local precision, unitsPerDegree, numDigits, strFormat, value, globe
local latitude, latConv, latValue, latLink
local longitude, lonConv, lonValue, lonLink
local latDirection, latDirectionN, latDirectionS, latDirectionEN
local lonDirection, lonDirectionE, lonDirectionW, lonDirectionEN
local degSymbol, minSymbol, secSymbol, separator
local latDegrees = nil
local latMinutes = nil
local latSeconds = nil
local lonDegrees = nil
local lonMinutes = nil
local lonSeconds = nil
local latDegSym = ""
local latMinSym = ""
local latSecSym = ""
local lonDegSym = ""
local lonMinSym = ""
local lonSecSym = ""
local latDirectionEN_N = "N"
local latDirectionEN_S = "S"
local lonDirectionEN_E = "E"
local lonDirectionEN_W = "W"
if not raw then
latDirectionN = i18n['coord']['latitude-north']
latDirectionS = i18n['coord']['latitude-south']
lonDirectionE = i18n['coord']['longitude-east']
lonDirectionW = i18n['coord']['longitude-west']
degSymbol = i18n['coord']['degrees']
minSymbol = i18n['coord']['minutes']
secSymbol = i18n['coord']['seconds']
separator = i18n['coord']['separator']
else
latDirectionN = latDirectionEN_N
latDirectionS = latDirectionEN_S
lonDirectionE = lonDirectionEN_E
lonDirectionW = lonDirectionEN_W
degSymbol = "/"
minSymbol = "/"
secSymbol = "/"
separator = "/"
end
latitude = datavalue['latitude']
longitude = datavalue['longitude']
if latitude < 0 then
latDirection = latDirectionS
latDirectionEN = latDirectionEN_S
latitude = math.abs(latitude)
else
latDirection = latDirectionN
latDirectionEN = latDirectionEN_N
end
if longitude < 0 then
lonDirection = lonDirectionW
lonDirectionEN = lonDirectionEN_W
longitude = math.abs(longitude)
else
lonDirection = lonDirectionE
lonDirectionEN = lonDirectionEN_E
end
precision = datavalue['precision']
if not precision or precision <= 0 then
precision = 1 / 3600 -- precision not set (correctly), set to arcsecond
end
-- remove insignificant detail
latitude = math.floor(latitude / precision + 0.5) * precision
longitude = math.floor(longitude / precision + 0.5) * precision
if precision >= 1 - (1 / 60) and precision < 1 then
precision = 1
elseif precision >= (1 / 60) - (1 / 3600) and precision < (1 / 60) then
precision = 1 / 60
end
if precision >= 1 then
unitsPerDegree = 1
elseif precision >= (1 / 60) then
unitsPerDegree = 60
else
unitsPerDegree = 3600
end
numDigits = math.ceil(-math.log10(unitsPerDegree * precision))
if numDigits <= 0 then
numDigits = tonumber("0") -- for some reason, 'numDigits = 0' may actually store '-0', so parse from string instead
end
strFormat = "%." .. numDigits .. "f"
if precision >= 1 then
latDegrees = strFormat:format(latitude)
lonDegrees = strFormat:format(longitude)
if not raw then
latDegSym = replaceDecimalMark(latDegrees) .. degSymbol
lonDegSym = replaceDecimalMark(lonDegrees) .. degSymbol
else
latDegSym = latDegrees .. degSymbol
lonDegSym = lonDegrees .. degSymbol
end
else
latConv = math.floor(latitude * unitsPerDegree * 10^numDigits + 0.5) / 10^numDigits
lonConv = math.floor(longitude * unitsPerDegree * 10^numDigits + 0.5) / 10^numDigits
if precision >= (1 / 60) then
latMinutes = latConv
lonMinutes = lonConv
else
latSeconds = latConv
lonSeconds = lonConv
latMinutes = math.floor(latSeconds / 60)
lonMinutes = math.floor(lonSeconds / 60)
latSeconds = strFormat:format(latSeconds - (latMinutes * 60))
lonSeconds = strFormat:format(lonSeconds - (lonMinutes * 60))
if not raw then
latSecSym = replaceDecimalMark(latSeconds) .. secSymbol
lonSecSym = replaceDecimalMark(lonSeconds) .. secSymbol
else
latSecSym = latSeconds .. secSymbol
lonSecSym = lonSeconds .. secSymbol
end
end
latDegrees = math.floor(latMinutes / 60)
lonDegrees = math.floor(lonMinutes / 60)
latDegSym = latDegrees .. degSymbol
lonDegSym = lonDegrees .. degSymbol
latMinutes = latMinutes - (latDegrees * 60)
lonMinutes = lonMinutes - (lonDegrees * 60)
if precision >= (1 / 60) then
latMinutes = strFormat:format(latMinutes)
lonMinutes = strFormat:format(lonMinutes)
if not raw then
latMinSym = replaceDecimalMark(latMinutes) .. minSymbol
lonMinSym = replaceDecimalMark(lonMinutes) .. minSymbol
else
latMinSym = latMinutes .. minSymbol
lonMinSym = lonMinutes .. minSymbol
end
else
latMinSym = latMinutes .. minSymbol
lonMinSym = lonMinutes .. minSymbol
end
end
latValue = latDegSym .. latMinSym .. latSecSym .. latDirection
lonValue = lonDegSym .. lonMinSym .. lonSecSym .. lonDirection
value = latValue .. separator .. lonValue
if link then
globe = parseWikidataURL(datavalue['globe'])
if globe then
globe = mw.wikibase.getLabelByLang(globe, "en"):lower()
else
globe = "earth"
end
latLink = table.concat({latDegrees, latMinutes, latSeconds}, "_")
lonLink = table.concat({lonDegrees, lonMinutes, lonSeconds}, "_")
value = "[https://geohack.toolforge.org/geohack.php?language="..self.langCode.."¶ms="..latLink.."_"..latDirectionEN.."_"..lonLink.."_"..lonDirectionEN.."_globe:"..globe.." "..value.."]"
end
return value
elseif datatype == 'wikibase-entityid' then
local label
local itemID = datavalue['numeric-id']
if subtype == 'wikibase-item' then
itemID = "Q" .. itemID
elseif subtype == 'wikibase-property' then
itemID = "P" .. itemID
else
return '<strong class="error">' .. errorText('unknown-data-type', subtype) .. '</strong>'
end
label = self:getLabel(itemID, raw, link, short)
if label == "" then
label = nil
end
return label
else
return '<strong class="error">' .. errorText('unknown-data-type', datatype) .. '</strong>'
end
elseif snak.snaktype == 'somevalue' and not noSpecial then
if raw then
return " " -- single space represents 'somevalue'
else
return i18n['values']['unknown']
end
elseif snak.snaktype == 'novalue' and not noSpecial then
if raw then
return "" -- empty string represents 'novalue'
else
return i18n['values']['none']
end
else
return nil
end
end
function Config:getSingleRawQualifier(claim, qualifierID)
local qualifiers
if claim.qualifiers then qualifiers = claim.qualifiers[qualifierID] end
if qualifiers and qualifiers[1] then
return self:getValue(qualifiers[1], true) -- raw = true
else
return nil
end
end
function Config:snakEqualsValue(snak, value)
local snakValue = self:getValue(snak, true) -- raw = true
if snakValue and snak.snaktype == 'value' and snak.datavalue.type == 'wikibase-entityid' then value = value:upper() end
return snakValue == value
end
function Config:setRank(rank)
local rankPos
if rank == p.flags.best then
self.bestRank = true
self.flagBest = true -- mark that 'best' flag was given
return
end
if rank:sub(1,9) == p.flags.preferred then
rankPos = 1
elseif rank:sub(1,6) == p.flags.normal then
rankPos = 2
elseif rank:sub(1,10) == p.flags.deprecated then
rankPos = 3
else
return
end
-- one of the rank flags was given, check if another one was given before
if not self.flagRank then
self.ranks = {false, false, false} -- no other rank flag given before, so unset ranks
self.bestRank = self.flagBest -- unsets bestRank only if 'best' flag was not given before
self.flagRank = true -- mark that a rank flag was given
end
if rank:sub(-1) == "+" then
for i = rankPos, 1, -1 do
self.ranks[i] = true
end
elseif rank:sub(-1) == "-" then
for i = rankPos, #self.ranks do
self.ranks[i] = true
end
else
self.ranks[rankPos] = true
end
end
function Config:setPeriod(period)
local periodPos
if period == p.flags.future then
periodPos = 1
elseif period == p.flags.current then
periodPos = 2
elseif period == p.flags.former then
periodPos = 3
else
return
end
-- one of the period flags was given, check if another one was given before
if not self.flagPeriod then
self.periods = {false, false, false} -- no other period flag given before, so unset periods
self.flagPeriod = true -- mark that a period flag was given
end
self.periods[periodPos] = true
end
function Config:qualifierMatches(claim, id, value)
local qualifiers
if claim.qualifiers then qualifiers = claim.qualifiers[id] end
if qualifiers then
for _, v in pairs(qualifiers) do
if self:snakEqualsValue(v, value) then
return true
end
end
elseif value == "" then
-- if the qualifier is not present then treat it the same as the special value 'novalue'
return true
end
return false
end
function Config:rankMatches(rankPos)
if self.bestRank then
return (self.ranks[rankPos] and self.foundRank >= rankPos)
else
return self.ranks[rankPos]
end
end
function Config:timeMatches(claim)
local startTime = nil
local startTimeY = nil
local startTimeM = nil
local startTimeD = nil
local endTime = nil
local endTimeY = nil
local endTimeM = nil
local endTimeD = nil
if self.periods[1] and self.periods[2] and self.periods[3] then
-- any time
return true
end
startTime = self:getSingleRawQualifier(claim, aliasesP.startTime)
if startTime and startTime ~= "" and startTime ~= " " then
startTimeY, startTimeM, startTimeD = parseDate(startTime)
end
endTime = self:getSingleRawQualifier(claim, aliasesP.endTime)
if endTime and endTime ~= "" and endTime ~= " " then
endTimeY, endTimeM, endTimeD = parseDate(endTime)
end
if startTimeY ~= nil and endTimeY ~= nil and datePrecedesDate(endTimeY, endTimeM, endTimeD, startTimeY, startTimeM, startTimeD) then
-- invalidate end time if it precedes start time
endTimeY = nil
endTimeM = nil
endTimeD = nil
end
if self.periods[1] then
-- future
if startTimeY and datePrecedesDate(self.atDate[1], self.atDate[2], self.atDate[3], startTimeY, startTimeM, startTimeD) then
return true
end
end
if self.periods[2] then
-- current
if (startTimeY == nil or not datePrecedesDate(self.atDate[1], self.atDate[2], self.atDate[3], startTimeY, startTimeM, startTimeD)) and
(endTimeY == nil or datePrecedesDate(self.atDate[1], self.atDate[2], self.atDate[3], endTimeY, endTimeM, endTimeD)) then
return true
end
end
if self.periods[3] then
-- former
if endTimeY and not datePrecedesDate(self.atDate[1], self.atDate[2], self.atDate[3], endTimeY, endTimeM, endTimeD) then
return true
end
end
return false
end
function Config:processFlag(flag)
if not flag then
return false
end
if flag == p.flags.linked then
self.curState.linked = true
return true
elseif flag == p.flags.raw then
self.curState.rawValue = true
if self.curState == self.states[parameters.reference] then
-- raw reference values end with periods and require a separator (other than none)
self.separators["sep%r"][1] = {" "}
end
return true
elseif flag == p.flags.short then
self.curState.shortName = true
return true
elseif flag == p.flags.multilanguage then
self.curState.anyLanguage = true
return true
elseif flag == p.flags.unit then
self.curState.unitOnly = true
return true
elseif flag == p.flags.mdy then
self.mdyDate = true
return true
elseif flag == p.flags.single then
self.singleClaim = true
return true
elseif flag == p.flags.sourced then
self.sourcedOnly = true
return true
elseif flag == p.flags.edit then
self.editable = true
return true
elseif flag == p.flags.editAtEnd then
self.editable = true
self.editAtEnd = true
return true
elseif flag == p.flags.best or flag:match('^'..p.flags.preferred..'[+-]?$') or flag:match('^'..p.flags.normal..'[+-]?$') or flag:match('^'..p.flags.deprecated..'[+-]?$') then
self:setRank(flag)
return true
elseif flag == p.flags.future or flag == p.flags.current or flag == p.flags.former then
self:setPeriod(flag)
return true
elseif flag == "" then
-- ignore empty flags and carry on
return true
else
return false
end
end
function Config:processFlagOrCommand(flag)
local param = ""
if not flag then
return false
end
if flag == p.claimCommands.property or flag == p.claimCommands.properties then
param = parameters.property
elseif flag == p.claimCommands.qualifier or flag == p.claimCommands.qualifiers then
self.states.qualifiersCount = self.states.qualifiersCount + 1
param = parameters.qualifier .. self.states.qualifiersCount
self.separators["sep"..param] = {copyTable(defaultSeparators["sep%q\\d"])}
elseif flag == p.claimCommands.reference or flag == p.claimCommands.references then
param = parameters.reference
else
return self:processFlag(flag)
end
if self.states[param] then
return false
end
-- create a new state for each command
self.states[param] = State:new(self, param)
-- use "%x" as the general parameter name
self.states[param].parsedFormat = parseFormat(parameters.general) -- will be overwritten for param=="%p"
-- set the separator
self.states[param].separator = self.separators["sep"..param] -- will be nil for param=="%p", which will be set separately
if flag == p.claimCommands.property or flag == p.claimCommands.qualifier or flag == p.claimCommands.reference then
self.states[param].singleValue = true
end
self.curState = self.states[param]
return true
end
function Config:processSeparators(args)
local sep
for i, v in pairs(self.separators) do
if args[i] then
sep = replaceSpecialChars(args[i])
if sep ~= "" then
self.separators[i][1] = {sep}
else
self.separators[i][1] = nil
end
end
end
end
function Config:setFormatAndSeparators(state, parsedFormat)
state.parsedFormat = parsedFormat
state.separator = self.separators["sep"]
state.movSeparator = self.separators["sep"..parameters.separator]
state.puncMark = self.separators["punc"]
end
-- determines if a claim has references by prefetching them from the claim using getReferences,
-- which applies some filtering that determines if a reference is actually returned,
-- and caches the references for later use
function State:isSourced(claim)
self.conf.prefetchedRefs = self:getReferences(claim)
return (#self.conf.prefetchedRefs > 0)
end
function State:resetCaches()
-- any prefetched references of the previous claim must not be used
self.conf.prefetchedRefs = nil
end
function State:claimMatches(claim)
local matches, rankPos
-- first of all, reset any cached values used for the previous claim
self:resetCaches()
-- if a property value was given, check if it matches the claim's property value
if self.conf.propertyValue then
matches = self.conf:snakEqualsValue(claim.mainsnak, self.conf.propertyValue)
else
matches = true
end
-- if any qualifier values were given, check if each matches one of the claim's qualifier values
for i, v in pairs(self.conf.qualifierIDsAndValues) do
matches = (matches and self.conf:qualifierMatches(claim, i, v))
end
-- check if the claim's rank and time period match
rankPos = rankTable[claim.rank] or 4
matches = (matches and self.conf:rankMatches(rankPos) and self.conf:timeMatches(claim))
-- if only claims with references must be returned, check if this one has any
if self.conf.sourcedOnly then
matches = (matches and self:isSourced(claim)) -- prefetches and caches references
end
return matches, rankPos
end
function State:out()
local result -- collection of arrays with value objects
local valuesArray -- array with value objects
local sep = nil -- value object
local out = {} -- array with value objects
local function walk(formatTable, result)
local valuesArray = {} -- array with value objects
for i, v in pairs(formatTable.req) do
if not result[i] or not result[i][1] then
-- we've got no result for a parameter that is required on this level,
-- so skip this level (and its children) by returning an empty result
return {}
end
end
for _, v in ipairs(formatTable) do
if v.param then
valuesArray = mergeArrays(valuesArray, result[v.str])
elseif v.str ~= "" then
valuesArray[#valuesArray + 1] = {v.str}
end
if v.child then
valuesArray = mergeArrays(valuesArray, walk(v.child, result))
end
end
return valuesArray
end
-- iterate through the results from back to front, so that we know when to add separators
for i = #self.results, 1, -1 do
result = self.results[i]
-- if there is already some output, then add the separators
if #out > 0 then
sep = self.separator[1] -- fixed separator
result[parameters.separator] = {self.movSeparator[1]} -- movable separator
else
sep = nil
result[parameters.separator] = {self.puncMark[1]} -- optional punctuation mark
end
valuesArray = walk(self.parsedFormat, result)
if #valuesArray > 0 then
if sep then
valuesArray[#valuesArray + 1] = sep
end
out = mergeArrays(valuesArray, out)
end
end
-- reset state before next iteration
self.results = {}
return out
end
-- level 1 hook
function State:getProperty(claim)
local value = {self:getValue(claim.mainsnak)} -- create one value object
if #value > 0 then
return {value} -- wrap the value object in an array and return it
else
return {} -- return empty array if there was no value
end
end
-- level 1 hook
function State:getQualifiers(claim, param)
local qualifiers
if claim.qualifiers then qualifiers = claim.qualifiers[self.conf.qualifierIDs[param]] end
if qualifiers then
-- iterate through claim's qualifier statements to collect their values;
-- return array with multiple value objects
return self.conf.states[param]:iterate(qualifiers, {[parameters.general] = hookNames[parameters.qualifier.."\\d"][2], count = 1}) -- pass qualifier state with level 2 hook
else
return {} -- return empty array
end
end
-- level 2 hook
function State:getQualifier(snak)
local value = {self:getValue(snak)} -- create one value object
if #value > 0 then
return {value} -- wrap the value object in an array and return it
else
return {} -- return empty array if there was no value
end
end
-- level 1 hook
function State:getAllQualifiers(claim, param, result, hooks)
local out = {} -- array with value objects
local sep = self.conf.separators["sep"..parameters.qualifier][1] -- value object
-- iterate through the output of the separate "qualifier(s)" commands
for i = 1, self.conf.states.qualifiersCount do
-- if a hook has not been called yet, call it now
if not result[parameters.qualifier..i] then
self:callHook(parameters.qualifier..i, hooks, claim, result)
end
-- if there is output for this particular "qualifier(s)" command, then add it
if result[parameters.qualifier..i] and result[parameters.qualifier..i][1] then
-- if there is already some output, then add the separator
if #out > 0 and sep then
out[#out + 1] = sep
end
out = mergeArrays(out, result[parameters.qualifier..i])
end
end
return out
end
-- level 1 hook
function State:getReferences(claim)
if self.conf.prefetchedRefs then
-- return references that have been prefetched by isSourced
return self.conf.prefetchedRefs
end
if claim.references then
-- iterate through claim's reference statements to collect their values;
-- return array with multiple value objects
return self.conf.states[parameters.reference]:iterate(claim.references, {[parameters.general] = hookNames[parameters.reference][2], count = 1}) -- pass reference state with level 2 hook
else
return {} -- return empty array
end
end
-- level 2 hook
function State:getReference(statement)
local citeParamMapping = i18n['cite']['param-mapping']
local citeConfig = i18n['cite']['config']
local citeTypes = i18n['cite']['output-types']
-- will hold rendered properties of the reference which are not directly from statement.snaks,
-- Namely, is URL generated from an external ID.
local additionalProcessedProperties = {}
-- for each citation type, there will be an associative array that associates lists of rendered properties
-- to citation-template parameters
local candidateParams = {}
-- like above, but only associates one rendered property to each parameter; if the above variable
-- contains more strings for a parameter, the strings will be assigned to numbered params (e.g. "author1")
local citeParams = {}
local citeErrors = {}
local referenceEmpty = true -- will be set to false if at least one parameter is left unremoved
local version = 12 -- increment this each time the below logic is changed to avoid conflict errors
if not statement.snaks then
return {}
end
-- don't use bot-added references referencing Wikimedia projects or containing "inferred from" (such references are not usable on Wikipedia)
if statement.snaks[aliasesP.importedFrom] or statement.snaks[aliasesP.wikimediaImportURL] or statement.snaks[aliasesP.inferredFrom] then
return {}
end
-- don't include "type of reference"
if statement.snaks[aliasesP.typeOfReference] then
statement.snaks[aliasesP.typeOfReference] = nil
end
-- don't include "image" to prevent littering
if statement.snaks[aliasesP.image] then
statement.snaks[aliasesP.image] = nil
end
-- don't include "language" if it is equal to the local one
if self:getReferenceDetail(statement.snaks, aliasesP.language) == self.conf.langName then
statement.snaks[aliasesP.language] = nil
end
if statement.snaks[aliasesP.statedIn] and not statement.snaks[aliasesP.referenceURL] then
-- "stated in" was given but "reference URL" was not.
-- get "Wikidata property" properties from the item in "stated in"
-- if any of the returned properties of the external-id datatype is in statement.snaks, generate a link from it and use the link in the reference
-- find the "Wikidata property" properties in the item from "stated in"
local wikidataPropertiesOfSource = mw.text.split(p._properties{p.flags.raw, aliasesP.wikidataProperty, [p.args.eid] = self.conf:getValue(statement.snaks[aliasesP.statedIn][1], true, false)}, ", ", true)
for i, wikidataPropertyOfSource in pairs(wikidataPropertiesOfSource) do
if statement.snaks[wikidataPropertyOfSource] and statement.snaks[wikidataPropertyOfSource][1].datatype == "external-id" then
local tempLink = self:getReferenceDetail(statement.snaks, wikidataPropertyOfSource, false, true) -- not raw, linked
if mw.ustring.match(tempLink, "^%[%Z- %Z+%]$") then -- getValue returned a URL in square brackets.
-- the link is in wiki markup, so strip the square brackets and the display text
-- gsub also returns another, discarted value, therefore the result is assigned to tempLink first
tempLink = mw.ustring.gsub(tempLink, "^%[(%Z-) %Z+%]$", "%1")
additionalProcessedProperties[aliasesP.referenceURL] = {tempLink}
statement.snaks[wikidataPropertyOfSource] = nil
break
end
end
end
end
-- initialize candidateParams and citeParams
for _, citeType in ipairs(citeTypes) do
candidateParams[citeType] = {}
citeParams[citeType] = {}
end
-- fill candidateParams
for _, citeType in ipairs(citeTypes) do
-- This will contain value--priority pairs for each param name.
local candidateValuesAndPriorities = {}
-- fill candidateValuesAndPriorities
for refProperty in pairs(statement.snaks) do
if citeErrors[citeType] then
break
end
repeat -- just a simple wrapper to emulate "continue"
-- set mappingKey and prefix
local mappingKey
local prefix = ""
if statement.snaks[refProperty][1].datatype == 'external-id' then
mappingKey = "external-id"
prefix = self.conf:getLabel(refProperty)
if prefix ~= "" then
prefix = prefix .. " "
end
else
mappingKey = refProperty
end
local paramName = citeParamMapping[citeType][mappingKey]
-- skip properties with empty parameter name
if paramName == "" then
break -- skip this property for this value of citeType
end
-- handle unknown properties in the reference
if not paramName then
referenceEmpty = false
local error_message = errorText("unknown-property-in-ref", refProperty)
assert(error_message) -- Should not be nil
citeErrors[citeType] = error_message
break
end
-- set processedProperty
local processedProperty
local raw = false -- if the value is wanted raw
if isValueInTable(paramName, citeConfig[citeType]["raw-value-params"] or {}) then
raw = true
end
if isValueInTable(paramName, citeConfig[citeType]["numbered-params"] or {}) then
-- Multiple values may be given.
processedProperty = self:getReferenceDetails(statement.snaks, refProperty, raw, self.linked, true) -- anyLang = true
else
-- If multiple values are given, all but the first suitable one are discarted.
processedProperty = {self:getReferenceDetail(statement.snaks, refProperty, raw, self.linked and (statement.snaks[refProperty][1].datatype ~= 'url'), true)} -- link = true/false, anyLang = true
end
if #processedProperty == 0 then
break
end
referenceEmpty = false
-- add an empty entry to candidateValuesAndPriorities, if there isn't one already
if not candidateValuesAndPriorities[paramName] then
candidateValuesAndPriorities[paramName] = {}
end
-- find the priority of refProperty
local thisPropertyPriority = -1
local thisParamPrioritization = citeConfig[citeType]["prioritization"][paramName]
if thisParamPrioritization then
for i_priority, i_property in ipairs(thisParamPrioritization) do
if i_property == refProperty then
thisPropertyPriority = i_priority
end
end
end
for _, propertyValue in pairs(processedProperty) do
table.insert(
candidateValuesAndPriorities[paramName],
{prefix .. propertyValue, thisPropertyPriority}
)
end
until true
end
-- fill candidateParams[citeType]
if not citeErrors[citeType] then
local compareValuePriorities = function(pair1, pair2)
if pair1[2] == -1 and pair2[2] ~= -1 then
return false
end
if pair1[2] ~= -1 and pair2[2] == -1 then
return true
end
return pair1[2] < pair2[2]
end
-- fill candidateParams[citeType][paramName] for each used param
for paramName, _ in pairs(candidateValuesAndPriorities) do
table.sort(candidateValuesAndPriorities[paramName], compareValuePriorities)
candidateParams[citeType][paramName] = {}
for _, valuePriorityPair in ipairs(candidateValuesAndPriorities[paramName]) do
table.insert(candidateParams[citeType][paramName], valuePriorityPair[1])
end
end
end
end
-- handle additional properties
for refProperty in pairs(additionalProcessedProperties) do
for _, citeType in ipairs(citeTypes) do
repeat
-- skip if there already have been errors
if citeErrors[citeType] then
break
end
local paramName = citeParamMapping[citeType][refProperty]
-- handle unknown properties in the reference
if not paramName then
-- Skip this additional property, but do not cause an error.
break
end
if paramName == "" then
break
end
referenceEmpty = false
if not candidateParams[citeType][paramName] then
candidateParams[citeType][paramName] = {}
end
for _, propertyValue in pairs(additionalProcessedProperties[refProperty]) do
table.insert(candidateParams[citeType][paramName], propertyValue)
end
until true
end
end
-- fill citeParams
for _, citeType in ipairs(citeTypes) do
for paramName, paramValues in pairs(candidateParams[citeType]) do
if #paramValues == 1 or not isValueInTable(paramName, citeConfig[citeType]["numbered-params"] or {}) then
citeParams[citeType][paramName] = paramValues[1]
else
-- There is more than one value for this parameter - the values will
-- go into separate numbered parameters (e.g. "author1", "author2")
for paramNum, paramValue in pairs(paramValues) do
citeParams[citeType][paramName .. paramNum] = paramValue
end
end
end
end
-- handle missing mandatory parameters for the templates
for _, citeType in ipairs(citeTypes) do
for _, requiredCiteParam in pairs(citeConfig[citeType]["mandatory-params"] or {}) do
if not citeParams[citeType][requiredCiteParam] then -- The required param is not present.
if citeErrors[citeType] then -- Do not override the previous error, if it exists.
break
end
local error_message = errorText("missing-mandatory-param", requiredCiteParam)
assert(error_message) -- Should not be nil
citeErrors[citeType] = error_message
end
end
end
local citeTypeToUse = nil
-- choose the output template
for _, citeType in ipairs(citeTypes) do
if not citeErrors[citeType] then
citeTypeToUse = citeType
break
end
end
-- set refContent
local refContent = ""
if citeTypeToUse then
local templateToUse = citeConfig[citeTypeToUse]["template"]
local paramsToUse = citeParams[citeTypeToUse]
if not templateToUse or templateToUse == "" then
throwError("no-such-reference-template", tostring(templateToUse), i18nPath, citeTypeToUse)
end
-- if this module is being substituted then build a regular template call, otherwise expand the template
if mw.isSubsting() then
for i, v in pairs(paramsToUse) do
refContent = refContent .. "|" .. i .. "=" .. v
end
refContent = "{{" .. templateToUse .. refContent .. "}}"
else
xpcall(
function () refContent = mw.getCurrentFrame():expandTemplate{title=templateToUse, args=paramsToUse} end,
function () throwError("no-such-reference-template", templateToUse, i18nPath, citeTypeToUse) end
)
end
-- If the citation couldn't be displayed using any template, but is not empty (barring ignored propeties), throw an error.
elseif not referenceEmpty then
refContent = errorText("malformed-reference-header")
for _, citeType in ipairs(citeTypes) do
refContent = refContent .. errorText("template-failure-reason", citeConfig[citeType]["template"], citeErrors[citeType])
end
refContent = refContent .. errorText("malformed-reference-footer")
end
-- wrap refContent
local ref = {}
if refContent ~= "" then
ref = {refContent}
if not self.rawValue then
-- this should become a <ref> tag, so save the reference's hash for later
ref.refHash = "wikidata-" .. statement.hash .. "-v" .. (tonumber(i18n['version']) + version)
end
return {ref}
else
return {}
end
end
-- gets a detail of one particular type for a reference
function State:getReferenceDetail(snaks, dType, raw, link, anyLang)
local switchLang = anyLang
local value = nil
if not snaks[dType] then
return nil
end
-- if anyLang, first try the local language and otherwise any language
repeat
for _, v in ipairs(snaks[dType]) do
value = self.conf:getValue(v, raw, link, false, anyLang and not switchLang, false, true) -- noSpecial = true
if value then
break
end
end
if value or not anyLang then
break
end
switchLang = not switchLang
until anyLang and switchLang
return value
end
-- gets the details of one particular type for a reference
function State:getReferenceDetails(snaks, dType, raw, link, anyLang)
local values = {}
if not snaks[dType] then
return {}
end
for _, v in ipairs(snaks[dType]) do
-- if nil is returned then it will not be added to the table
values[#values + 1] = self.conf:getValue(v, raw, link, false, anyLang, false, true) -- noSpecial = true
end
return values
end
-- level 1 hook
function State:getAlias(object)
local value = object.value
local title = nil
if value and self.linked then
if self.conf.entityID:sub(1,1) == "Q" then
title = mw.wikibase.getSitelink(self.conf.entityID)
elseif self.conf.entityID:sub(1,1) == "P" then
title = "d:Property:" .. self.conf.entityID
end
if title then
value = buildWikilink(title, value)
end
end
value = {value} -- create one value object
if #value > 0 then
return {value} -- wrap the value object in an array and return it
else
return {} -- return empty array if there was no value
end
end
-- level 1 hook
function State:getBadge(value)
value = self.conf:getLabel(value, self.rawValue, self.linked, self.shortName)
if value == "" then
value = nil
end
value = {value} -- create one value object
if #value > 0 then
return {value} -- wrap the value object in an array and return it
else
return {} -- return empty array if there was no value
end
end
function State:callHook(param, hooks, statement, result)
-- call a parameter's hook if it has been defined and if it has not been called before
if not result[param] and hooks[param] then
local valuesArray = self[hooks[param]](self, statement, param, result, hooks) -- array with value objects
-- add to the result
if #valuesArray > 0 then
result[param] = valuesArray
result.count = result.count + 1
else
result[param] = {} -- an empty array to indicate that we've tried this hook already
return true -- miss == true
end
end
return false
end
-- iterate through claims, claim's qualifiers or claim's references to collect values
function State:iterate(statements, hooks, matchHook)
matchHook = matchHook or alwaysTrue
local matches = false
local rankPos = nil
local result, gotRequired
for _, v in ipairs(statements) do
-- rankPos will be nil for non-claim statements (e.g. qualifiers, references, etc.)
matches, rankPos = matchHook(self, v)
if matches then
result = {count = 0} -- collection of arrays with value objects
local function walk(formatTable)
local miss
for i2, v2 in pairs(formatTable.req) do
-- call a hook, adding its return value to the result
miss = self:callHook(i2, hooks, v, result)
if miss then
-- we miss a required value for this level, so return false
return false
end
if result.count == hooks.count then
-- we're done if all hooks have been called;
-- returning at this point breaks the loop
return true
end
end
for _, v2 in ipairs(formatTable) do
if result.count == hooks.count then
-- we're done if all hooks have been called;
-- returning at this point prevents further childs from being processed
return true
end
if v2.child then
walk(v2.child)
end
end
return true
end
gotRequired = walk(self.parsedFormat)
-- only append the result if we got values for all required parameters on the root level
if gotRequired then
-- if we have a rankPos (only with matchHook() for complete claims), then update the foundRank
if rankPos and self.conf.foundRank > rankPos then
self.conf.foundRank = rankPos
end
-- append the result
self.results[#self.results + 1] = result
-- break if we only need a single value
if self.singleValue then
break
end
end
end
end
return self:out()
end
local function getEntityId(arg, eid, page, allowOmitPropPrefix, globalSiteId)
local id = nil
local prop = nil
if arg then
if arg:sub(1,1) == ":" then
page = arg
eid = nil
elseif arg:sub(1,1):upper() == "Q" or arg:sub(1,9):lower() == "property:" or allowOmitPropPrefix then
eid = arg
page = nil
else
prop = arg
end
end
if eid then
if eid:sub(1,9):lower() == "property:" then
id = replaceAlias(mw.text.trim(eid:sub(10)))
if id:sub(1,1):upper() ~= "P" then
id = ""
end
else
id = replaceAlias(eid)
end
elseif page then
if page:sub(1,1) == ":" then
page = mw.text.trim(page:sub(2))
end
id = mw.wikibase.getEntityIdForTitle(page, globalSiteId) or ""
end
if not id then
id = mw.wikibase.getEntityIdForCurrentPage() or ""
end
id = id:upper()
if not mw.wikibase.isValidEntityId(id) then
id = ""
end
return id, prop
end
local function nextArg(args)
local arg = args[args.pointer]
if arg then
args.pointer = args.pointer + 1
return mw.text.trim(arg)
else
return nil
end
end
local function claimCommand(args, funcName)
local cfg = Config:new()
cfg:processFlagOrCommand(funcName) -- process first command (== function name)
local lastArg, parsedFormat, formatParams, claims, value
local hooks = {count = 0}
-- set the date if given;
-- must come BEFORE processing the flags
if args[p.args.date] then
cfg.atDate = {parseDate(args[p.args.date])}
cfg.periods = {false, true, false} -- change default time constraint to 'current'
end
-- process flags and commands
repeat
lastArg = nextArg(args)
until not cfg:processFlagOrCommand(lastArg)
-- get the entity ID from either the positional argument, the eid argument or the page argument
cfg.entityID, cfg.propertyID = getEntityId(lastArg, args[p.args.eid], args[p.args.page], false, args[p.args.globalSiteId])
if cfg.entityID == "" then
return "" -- we cannot continue without a valid entity ID
end
cfg.entity = mw.wikibase.getEntity(cfg.entityID)
if not cfg.propertyID then
cfg.propertyID = nextArg(args)
end
cfg.propertyID = replaceAlias(cfg.propertyID)
if not cfg.entity or not cfg.propertyID then
return "" -- we cannot continue without an entity or a property ID
end
cfg.propertyID = cfg.propertyID:upper()
if not cfg.entity.claims or not cfg.entity.claims[cfg.propertyID] then
return "" -- there is no use to continue without any claims
end
claims = cfg.entity.claims[cfg.propertyID]
if cfg.states.qualifiersCount > 0 then
-- do further processing if "qualifier(s)" command was given
if #args - args.pointer + 1 > cfg.states.qualifiersCount then
-- claim ID or literal value has been given
cfg.propertyValue = nextArg(args)
end
for i = 1, cfg.states.qualifiersCount do
-- check if given qualifier ID is an alias and add it
cfg.qualifierIDs[parameters.qualifier..i] = replaceAlias(nextArg(args) or ""):upper()
end
elseif cfg.states[parameters.reference] then
-- do further processing if "reference(s)" command was given
cfg.propertyValue = nextArg(args)
end
-- check for special property value 'somevalue' or 'novalue'
if cfg.propertyValue then
cfg.propertyValue = replaceSpecialChars(cfg.propertyValue)
if cfg.propertyValue ~= "" and mw.text.trim(cfg.propertyValue) == "" then
cfg.propertyValue = " " -- single space represents 'somevalue', whereas empty string represents 'novalue'
else
cfg.propertyValue = mw.text.trim(cfg.propertyValue)
end
end
-- parse the desired format, or choose an appropriate format
if args["format"] then
parsedFormat, formatParams = parseFormat(args["format"])
elseif cfg.states.qualifiersCount > 0 then -- "qualifier(s)" command given
if cfg.states[parameters.property] then -- "propert(y|ies)" command given
parsedFormat, formatParams = parseFormat(formats.propertyWithQualifier)
else
parsedFormat, formatParams = parseFormat(formats.qualifier)
end
elseif cfg.states[parameters.property] then -- "propert(y|ies)" command given
parsedFormat, formatParams = parseFormat(formats.property)
else -- "reference(s)" command given
parsedFormat, formatParams = parseFormat(formats.reference)
end
-- if a "qualifier(s)" command and no "propert(y|ies)" command has been given, make the movable separator a semicolon
if cfg.states.qualifiersCount > 0 and not cfg.states[parameters.property] then
cfg.separators["sep"..parameters.separator][1] = {";"}
end
-- if only "reference(s)" has been given, set the default separator to none (except when raw)
if cfg.states[parameters.reference] and not cfg.states[parameters.property] and cfg.states.qualifiersCount == 0
and not cfg.states[parameters.reference].rawValue then
cfg.separators["sep"][1] = nil
end
-- if exactly one "qualifier(s)" command has been given, make "sep%q" point to "sep%q1" to make them equivalent
if cfg.states.qualifiersCount == 1 then
cfg.separators["sep"..parameters.qualifier] = cfg.separators["sep"..parameters.qualifier.."1"]
end
-- process overridden separator values;
-- must come AFTER tweaking the default separators
cfg:processSeparators(args)
-- define the hooks that should be called (getProperty, getQualifiers, getReferences);
-- only define a hook if both its command ("propert(y|ies)", "reference(s)", "qualifier(s)") and its parameter ("%p", "%r", "%q1", "%q2", "%q3") have been given
for i, v in pairs(cfg.states) do
-- e.g. 'formatParams["%q1"] or formatParams["%q"]' to define hook even if "%q1" was not defined to be able to build a complete value for "%q"
if formatParams[i] or formatParams[i:sub(1, 2)] then
hooks[i] = getHookName(i, 1)
hooks.count = hooks.count + 1
end
end
-- the "%q" parameter is not attached to a state, but is a collection of the results of multiple states (attached to "%q1", "%q2", "%q3", ...);
-- so if this parameter is given then this hook must be defined separately, but only if at least one "qualifier(s)" command has been given
if formatParams[parameters.qualifier] and cfg.states.qualifiersCount > 0 then
hooks[parameters.qualifier] = getHookName(parameters.qualifier, 1)
hooks.count = hooks.count + 1
end
-- create a state for "properties" if it doesn't exist yet, which will be used as a base configuration for each claim iteration;
-- must come AFTER defining the hooks
if not cfg.states[parameters.property] then
cfg.states[parameters.property] = State:new(cfg, parameters.property)
-- if the "single" flag has been given then this state should be equivalent to "property" (singular)
if cfg.singleClaim then
cfg.states[parameters.property].singleValue = true
end
end
-- if the "sourced" flag has been given then create a state for "reference" if it doesn't exist yet, using default values,
-- which must exist in order to be able to determine if a claim has any references;
-- must come AFTER defining the hooks
if cfg.sourcedOnly and not cfg.states[parameters.reference] then
cfg:processFlagOrCommand(p.claimCommands.reference) -- use singular "reference" to minimize overhead
end
-- set the parsed format and the separators (and optional punctuation mark);
-- must come AFTER creating the additonal states
cfg:setFormatAndSeparators(cfg.states[parameters.property], parsedFormat)
-- process qualifier matching values, analogous to cfg.propertyValue
for i, v in pairs(args) do
i = tostring(i)
if i:match('^[Pp]%d+$') or aliasesP[i] then
v = replaceSpecialChars(v)
-- check for special qualifier value 'somevalue'
if v ~= "" and mw.text.trim(v) == "" then
v = " " -- single space represents 'somevalue'
end
cfg.qualifierIDsAndValues[replaceAlias(i):upper()] = v
end
end
-- first sort the claims on rank to pre-define the order of output (preferred first, then normal, then deprecated)
claims = sortOnRank(claims)
-- then iterate through the claims to collect values
value = cfg:concatValues(cfg.states[parameters.property]:iterate(claims, hooks, State.claimMatches)) -- pass property state with level 1 hooks and matchHook
-- if desired, add a clickable icon that may be used to edit the returned values on Wikidata
if cfg.editable and value ~= "" then
value = value .. cfg:getEditIcon()
end
return value
end
local function generalCommand(args, funcName)
local cfg = Config:new()
cfg.curState = State:new(cfg)
local lastArg
local value = nil
repeat
lastArg = nextArg(args)
until not cfg:processFlag(lastArg)
-- get the entity ID from either the positional argument, the eid argument or the page argument
cfg.entityID = getEntityId(lastArg, args[p.args.eid], args[p.args.page], true, args[p.args.globalSiteId])
if cfg.entityID == "" or not mw.wikibase.entityExists(cfg.entityID) then
return "" -- we cannot continue without an entity
end
-- serve according to the given command
if funcName == p.generalCommands.label then
value = cfg:getLabel(cfg.entityID, cfg.curState.rawValue, cfg.curState.linked, cfg.curState.shortName)
elseif funcName == p.generalCommands.title then
cfg.inSitelinks = true
if cfg.entityID:sub(1,1) == "Q" then
value = mw.wikibase.getSitelink(cfg.entityID)
end
if cfg.curState.linked and value then
value = buildWikilink(value)
end
elseif funcName == p.generalCommands.description then
value = mw.wikibase.getDescription(cfg.entityID)
else
local parsedFormat, formatParams
local hooks = {count = 0}
cfg.entity = mw.wikibase.getEntity(cfg.entityID)
if funcName == p.generalCommands.alias or funcName == p.generalCommands.badge then
cfg.curState.singleValue = true
end
if funcName == p.generalCommands.alias or funcName == p.generalCommands.aliases then
if not cfg.entity.aliases or not cfg.entity.aliases[cfg.langCode] then
return "" -- there is no use to continue without any aliasses
end
local aliases = cfg.entity.aliases[cfg.langCode]
-- parse the desired format, or parse the default aliases format
if args["format"] then
parsedFormat, formatParams = parseFormat(args["format"])
else
parsedFormat, formatParams = parseFormat(formats.alias)
end
-- process overridden separator values;
-- must come AFTER tweaking the default separators
cfg:processSeparators(args)
-- define the hook that should be called (getAlias);
-- only define the hook if the parameter ("%a") has been given
if formatParams[parameters.alias] then
hooks[parameters.alias] = getHookName(parameters.alias, 1)
hooks.count = hooks.count + 1
end
-- set the parsed format and the separators (and optional punctuation mark)
cfg:setFormatAndSeparators(cfg.curState, parsedFormat)
-- iterate to collect values
value = cfg:concatValues(cfg.curState:iterate(aliases, hooks))
elseif funcName == p.generalCommands.badge or funcName == p.generalCommands.badges then
if not cfg.entity.sitelinks or not cfg.entity.sitelinks[cfg.siteID] or not cfg.entity.sitelinks[cfg.siteID].badges then
return "" -- there is no use to continue without any badges
end
local badges = cfg.entity.sitelinks[cfg.siteID].badges
cfg.inSitelinks = true
-- parse the desired format, or parse the default aliases format
if args["format"] then
parsedFormat, formatParams = parseFormat(args["format"])
else
parsedFormat, formatParams = parseFormat(formats.badge)
end
-- process overridden separator values;
-- must come AFTER tweaking the default separators
cfg:processSeparators(args)
-- define the hook that should be called (getBadge);
-- only define the hook if the parameter ("%b") has been given
if formatParams[parameters.badge] then
hooks[parameters.badge] = getHookName(parameters.badge, 1)
hooks.count = hooks.count + 1
end
-- set the parsed format and the separators (and optional punctuation mark)
cfg:setFormatAndSeparators(cfg.curState, parsedFormat)
-- iterate to collect values
value = cfg:concatValues(cfg.curState:iterate(badges, hooks))
end
end
value = value or ""
if cfg.editable and value ~= "" then
-- if desired, add a clickable icon that may be used to edit the returned value on Wikidata
value = value .. cfg:getEditIcon()
end
return value
end
-- modules that include this module should call the functions with an underscore prepended, e.g.: p._property(args)
local function establishCommands(commandList, commandFunc)
for _, commandName in pairs(commandList) do
local function wikitextWrapper(frame)
local args = copyTable(frame.args)
args.pointer = 1
loadI18n(aliasesP, frame)
return commandFunc(args, commandName)
end
p[commandName] = wikitextWrapper
local function luaWrapper(args)
args = copyTable(args)
args.pointer = 1
loadI18n(aliasesP)
return commandFunc(args, commandName)
end
p["_" .. commandName] = luaWrapper
end
end
establishCommands(p.claimCommands, claimCommand)
establishCommands(p.generalCommands, generalCommand)
-- main function that is supposed to be used by wrapper templates
function p.main(frame)
if not mw.wikibase then return nil end
local f, args
loadI18n(aliasesP, frame)
-- get the parent frame to take the arguments that were passed to the wrapper template
frame = frame:getParent() or frame
if not frame.args[1] then
throwError("no-function-specified")
end
f = mw.text.trim(frame.args[1])
if f == "main" then
throwError("main-called-twice")
end
assert(p["_"..f], errorText('no-such-function', f))
-- copy arguments from immutable to mutable table
args = copyTable(frame.args)
-- remove the function name from the list
table.remove(args, 1)
return p["_"..f](args)
end
return p
j5a6l03tjwodgrvfnv3lb4x5up93wlv
ಟೆಂಪ್ಲೇಟು:Wikidata property link
10
95258
325323
252656
2025-03-05T08:44:44Z
w>A826
0
೧ revision imported from [[:en:Template:Wikidata_property_link]]
325323
wikitext
text/x-wiki
<includeonly>{{#switch:{{str left|{{uc:{{{id|}}}}}|1}}
| N <!--none--> = {{#switch:{{str left|{{uc:{{{1|}}}}}|1}}
| P = [[d:Special:EntityPage/{{uc:{{{1|}}}}}|{{wikidata|label|{{uc:{{{1|}}}}}}}]]
| [[d:Special:EntityPage/P{{uc:{{{1|}}}}}|{{wikidata|label|P{{uc:{{{1|}}}}}}}]]
}}
| O <!--only--> = {{#switch:{{str left|{{uc:{{{1|}}}}}|1}}
| P = [[d:Special:EntityPage/{{uc:{{{1|}}}}}|{{uc:{{{1|}}}}}]]
| [[d:Special:EntityPage/P{{uc:{{{1|}}}}}|P{{uc:{{{1|}}}}}]]
}}
| F <!--first--> = {{#switch:{{str left|{{uc:{{{1|}}}}}|1}}
| P = [[d:Special:EntityPage/{{uc:{{{1|}}}}}|{{uc:{{{1|}}}}}]]{{#if:{{wikidata|label|{{uc:{{{1|}}}}}}}|: <small>{{wikidata|label|{{uc:{{{1|}}}}}}}</small>}}
| [[d:Special:EntityPage/P{{uc:{{{1|}}}}}|P{{uc:{{{1|}}}}}]]{{#if:{{wikidata|label|P{{uc:{{{1|}}}}}}}|: <small>{{wikidata|label|P{{uc:{{{1|}}}}}}}</small>}}
}}
| #default = {{#switch:{{str left|{{uc:{{{1|}}}}}|1}}
| P = [[d:Special:EntityPage/{{uc:{{{1|}}}}}|{{wikidata|label|{{uc:{{{1|}}}}}}} <small>({{uc:{{{1|}}}}})</small>]]
| [[d:Special:EntityPage/P{{uc:{{{1|}}}}}|{{wikidata|label|P{{uc:{{{1|}}}}}}} <small>(P{{uc:{{{1|}}}}})</small>]]
}}
}}</includeonly><noinclude>{{Documentation}}</noinclude>
k8jv170qlggs0249fpe48ygwkpgfzbn
325324
325323
2026-08-22T10:31:21Z
A826
6806
೧ revisions imported from [[:w:ಟೆಂಪ್ಲೇಟು:Wikidata_property_link]]
325323
wikitext
text/x-wiki
<includeonly>{{#switch:{{str left|{{uc:{{{id|}}}}}|1}}
| N <!--none--> = {{#switch:{{str left|{{uc:{{{1|}}}}}|1}}
| P = [[d:Special:EntityPage/{{uc:{{{1|}}}}}|{{wikidata|label|{{uc:{{{1|}}}}}}}]]
| [[d:Special:EntityPage/P{{uc:{{{1|}}}}}|{{wikidata|label|P{{uc:{{{1|}}}}}}}]]
}}
| O <!--only--> = {{#switch:{{str left|{{uc:{{{1|}}}}}|1}}
| P = [[d:Special:EntityPage/{{uc:{{{1|}}}}}|{{uc:{{{1|}}}}}]]
| [[d:Special:EntityPage/P{{uc:{{{1|}}}}}|P{{uc:{{{1|}}}}}]]
}}
| F <!--first--> = {{#switch:{{str left|{{uc:{{{1|}}}}}|1}}
| P = [[d:Special:EntityPage/{{uc:{{{1|}}}}}|{{uc:{{{1|}}}}}]]{{#if:{{wikidata|label|{{uc:{{{1|}}}}}}}|: <small>{{wikidata|label|{{uc:{{{1|}}}}}}}</small>}}
| [[d:Special:EntityPage/P{{uc:{{{1|}}}}}|P{{uc:{{{1|}}}}}]]{{#if:{{wikidata|label|P{{uc:{{{1|}}}}}}}|: <small>{{wikidata|label|P{{uc:{{{1|}}}}}}}</small>}}
}}
| #default = {{#switch:{{str left|{{uc:{{{1|}}}}}|1}}
| P = [[d:Special:EntityPage/{{uc:{{{1|}}}}}|{{wikidata|label|{{uc:{{{1|}}}}}}} <small>({{uc:{{{1|}}}}})</small>]]
| [[d:Special:EntityPage/P{{uc:{{{1|}}}}}|{{wikidata|label|P{{uc:{{{1|}}}}}}} <small>(P{{uc:{{{1|}}}}})</small>]]
}}
}}</includeonly><noinclude>{{Documentation}}</noinclude>
k8jv170qlggs0249fpe48ygwkpgfzbn
ಟೆಂಪ್ಲೇಟು:Strong
10
96683
325319
259520
2024-10-31T15:47:34Z
w>A826
0
೧ ಬದಲಾವಣೆ
259519
wikitext
text/x-wiki
<strong {{#if:{{{role|}}}|role="{{{role}}}"}} {{#if:{{{class|}}}|class="{{{class}}}"}} {{#if:{{{id|}}}|id="{{{id}}}"}} {{#if:{{{style|}}}|style="{{{style}}}"}} {{#if:{{{title|}}}|title="{{{title}}}"}}>{{{1}}}</strong><noinclude>
{{documentation}}
<!-- Add cats and interwikis to the /doc subpage, not here! -->
</noinclude>
jhbv1h6fd9kjc1d4eovhzvnxrpqq09r
325320
325319
2026-08-22T10:31:20Z
A826
6806
೧ revisions imported from [[:w:ಟೆಂಪ್ಲೇಟು:Strong]]
259519
wikitext
text/x-wiki
<strong {{#if:{{{role|}}}|role="{{{role}}}"}} {{#if:{{{class|}}}|class="{{{class}}}"}} {{#if:{{{id|}}}|id="{{{id}}}"}} {{#if:{{{style|}}}|style="{{{style}}}"}} {{#if:{{{title|}}}|title="{{{title}}}"}}>{{{1}}}</strong><noinclude>
{{documentation}}
<!-- Add cats and interwikis to the /doc subpage, not here! -->
</noinclude>
jhbv1h6fd9kjc1d4eovhzvnxrpqq09r
ಮಾಡ್ಯೂಲ್:Text
828
96684
325325
259522
2025-07-10T03:38:57Z
w>A826
0
೧ ಬದಲಾವಣೆ
325325
Scribunto
text/plain
local yesNo = require("Module:Yesno")
local Text = { serial = "2024-09-21",
suite = "Text" }
--[=[
Text utilities
]=]
local function fiatQuote( apply, alien, advance )
-- Quote text
-- Parameter:
-- apply -- string, with text
-- alien -- string, with language code
-- advance -- number, with level 1 or 2
local r = apply and tostring(apply) or ""
alien = alien or "en"
advance = tonumber(advance) or 0
local suite
local data = mw.loadData('Module:Text/data')
local QuoteLang = data.QuoteLang
local QuoteType = data.QuoteType
local slang = alien:match( "^(%l+)-" )
suite = QuoteLang[alien] or slang and QuoteLang[slang] or QuoteLang["en"]
if suite then
local quotes = QuoteType[ suite ]
if quotes then
local space
if quotes[ 3 ] then
space = " "
else
space = ""
end
quotes = quotes[ advance ]
if quotes then
r = mw.ustring.format( "%s%s%s%s%s",
mw.ustring.char( quotes[ 1 ] ),
space,
apply,
space,
mw.ustring.char( quotes[ 2 ] ) )
end
else
mw.log( "fiatQuote() " .. suite )
end
end
return r
end -- fiatQuote()
Text.char = function ( apply, again, accept )
-- Create string from codepoints
-- Parameter:
-- apply -- table (sequence) with numerical codepoints, or nil
-- again -- number of repetitions, or nil
-- accept -- true, if no error messages to be appended
-- Returns: string
local r = ""
apply = type(apply) == "table" and apply or {}
again = math.floor(tonumber(again) or 1)
if again < 1 then
return ""
end
local bad = { }
local codes = { }
for _, v in ipairs( apply ) do
local n = tonumber(v)
if not n or (n < 32 and n ~= 9 and n ~= 10) then
table.insert(bad, tostring(v))
else
table.insert(codes, math.floor(n))
end
end
if #bad > 0 then
if not accept then
r = tostring( mw.html.create( "span" )
:addClass( "error" )
:wikitext( "bad codepoints: " .. table.concat( bad, " " )) )
end
return r
end
if #codes > 0 then
r = mw.ustring.char( unpack( codes ) )
if again > 1 then
r = r:rep(again)
end
end
return r
end -- Text.char()
local function trimAndFormat(args, fmt)
local result = {}
if type(args) ~= 'table' then
args = {args}
end
for _, v in ipairs(args) do
v = mw.text.trim(tostring(v))
if v ~= "" then
table.insert(result,fmt and mw.ustring.format(fmt, v) or v)
end
end
return result
end
Text.concatParams = function ( args, apply, adapt )
-- Concat list items into one string
-- Parameter:
-- args -- table (sequence) with numKey=string
-- apply -- string (optional); separator (default: "|")
-- adapt -- string (optional); format including "%s"
-- Returns: string
local collect = { }
return table.concat(trimAndFormat(args,adapt), apply or "|")
end -- Text.concatParams()
Text.containsCJK = function ( s )
-- Is any CJK code within?
-- Parameter:
-- s -- string
-- Returns: true, if CJK detected
s = s and tostring(s) or ""
local patternCJK = mw.loadData('Module:Text/data').PatternCJK
return mw.ustring.find( s, patternCJK ) ~= nil
end -- Text.containsCJK()
Text.removeDelimited = function (s, prefix, suffix)
-- Remove all text in s delimited by prefix and suffix (inclusive)
-- Arguments:
-- s = string to process
-- prefix = initial delimiter
-- suffix = ending delimiter
-- Returns: stripped string
s = s and tostring(s) or ""
prefix = prefix and tostring(prefix) or ""
suffix = suffix and tostring(suffix) or ""
local prefixLen = mw.ustring.len(prefix)
local suffixLen = mw.ustring.len(suffix)
if prefixLen == 0 or suffixLen == 0 then
return s
end
local i = s:find(prefix, 1, true)
local r = s
local j
while i do
j = r:find(suffix, i + prefixLen)
if j then
r = r:sub(1, i - 1)..r:sub(j+suffixLen)
else
r = r:sub(1, i - 1)
end
i = r:find(prefix, 1, true)
end
return r
end
Text.getPlain = function ( adjust )
-- Remove wikisyntax from string, except templates
-- Parameter:
-- adjust -- string
-- Returns: string
local r = Text.removeDelimited(adjust,"<!--","-->")
r = r:gsub( "(</?%l[^>]*>)", "" )
:gsub( "'''", "" )
:gsub( "''", "" )
:gsub( " ", " " )
return r
end -- Text.getPlain()
Text.isLatinRange = function (s)
-- Are characters expected to be latin or symbols within latin texts?
-- Arguments:
-- s = string to analyze
-- Returns: true, if valid for latin only
s = s and tostring(s) or "" --- ensure input is always string
local PatternLatin = mw.loadData('Module:Text/data').PatternLatin
return mw.ustring.match(s, PatternLatin) ~= nil
end -- Text.isLatinRange()
Text.isQuote = function ( s )
-- Is this character any quotation mark?
-- Parameter:
-- s = single character to analyze
-- Returns: true, if s is quotation mark
s = s and tostring(s) or ""
if s == "" then
return false
end
local SeekQuote = mw.loadData('Module:Text/data').SeekQuote
return mw.ustring.find( SeekQuote, s, 1, true ) ~= nil
end -- Text.isQuote()
Text.listToText = function ( args, adapt )
-- Format list items similar to mw.text.listToText()
-- Parameter:
-- args -- table (sequence) with numKey=string
-- adapt -- string (optional); format including "%s"
-- Returns: string
return mw.text.listToText(trimAndFormat(args, adapt))
end -- Text.listToText()
Text.quote = function ( apply, alien, advance )
-- Quote text
-- Parameter:
-- apply -- string, with text
-- alien -- string, with language code, or nil
-- advance -- number, with level 1 or 2, or nil
-- Returns: quoted string
apply = apply and tostring(apply) or ""
local mode, slang
if type( alien ) == "string" then
slang = mw.text.trim( alien ):lower()
else
slang = mw.title.getCurrentTitle().pageLanguage
if not slang then
-- TODO FIXME: Introduction expected 2017-04
slang = mw.language.getContentLanguage():getCode()
end
end
if advance == 2 then
mode = 2
else
mode = 1
end
return fiatQuote( mw.text.trim( apply ), slang, mode )
end -- Text.quote()
Text.quoteUnquoted = function ( apply, alien, advance )
-- Quote text, if not yet quoted and not empty
-- Parameter:
-- apply -- string, with text
-- alien -- string, with language code, or nil
-- advance -- number, with level 1 or 2, or nil
-- Returns: string; possibly quoted
local r = mw.text.trim( apply and tostring(apply) or "" )
local s = mw.ustring.sub( r, 1, 1 )
if s ~= "" and not Text.isQuote( s, advance ) then
s = mw.ustring.sub( r, -1, 1 )
if not Text.isQuote( s ) then
r = Text.quote( r, alien, advance )
end
end
return r
end -- Text.quoteUnquoted()
Text.removeDiacritics = function ( adjust )
-- Remove all diacritics
-- Parameter:
-- adjust -- string
-- Returns: string; all latin letters should be ASCII
-- or basic greek or cyrillic or symbols etc.
local cleanup, decomposed
local PatternCombined = mw.loadData('Module:Text/data').PatternCombined
decomposed = mw.ustring.toNFD( adjust and tostring(adjust) or "" )
cleanup = mw.ustring.gsub( decomposed, PatternCombined, "" )
return mw.ustring.toNFC( cleanup )
end -- Text.removeDiacritics()
Text.sentenceTerminated = function ( analyse )
-- Is string terminated by dot, question or exclamation mark?
-- Quotation, link termination and so on granted
-- Parameter:
-- analyse -- string
-- Returns: true, if sentence terminated
local r
local PatternTerminated = mw.loadData('Module:Text/data').PatternTerminated
if mw.ustring.find( analyse, PatternTerminated ) then
r = true
else
r = false
end
return r
end -- Text.sentenceTerminated()
Text.ucfirstAll = function ( adjust)
-- Capitalize all words
-- Arguments:
-- adjust = string to adjust
-- Returns: string with all first letters in upper case
adjust = adjust and tostring(adjust) or ""
local r = mw.text.decode(adjust,true)
local i = 1
local c, j, m
m = (r ~= adjust)
r = " "..r
while i do
i = mw.ustring.find( r, "%W%l", i )
if i then
j = i + 1
c = mw.ustring.upper( mw.ustring.sub( r, j, j ) )
r = string.format( "%s%s%s",
mw.ustring.sub( r, 1, i ),
c,
mw.ustring.sub( r, i + 2 ) )
i = j
end
end -- while i
r = r:sub( 2 )
if m then
r = mw.text.encode(r)
end
return r
end -- Text.ucfirstAll()
Text.uprightNonlatin = function ( adjust )
-- Ensure non-italics for non-latin text parts
-- One single greek letter might be granted
-- Precondition:
-- adjust -- string
-- Returns: string with non-latin parts enclosed in <span>
local r
local data = mw.loadData('Module:Text/data')
local PatternLatin = data.PatternLatin
local RangesLatin = data.RangesLatin
local NumLatinRanges = data.NumLatinRanges
if mw.ustring.match( adjust, PatternLatin ) then
-- latin only, horizontal dashes, quotes
r = adjust
else
local c
local j = false
local k = 1
local m = false
local n = mw.ustring.len( adjust )
local span = "%s%s<span dir='auto' style='font-style:normal'>%s</span>"
local flat = function ( a )
-- isLatin
local range
-- NumLatinRanges has to be precomputed because # does not work from loadData
for i = 1, NumLatinRanges do
range = RangesLatin[ i ]
if a >= range[ 1 ] and a <= range[ 2 ] then
return true
end
end -- for i
end -- flat()
local focus = function ( a )
-- char is not ambivalent
local r = ( a > 64 )
if r then
r = ( a < 8192 or a > 8212 )
else
r = ( a == 38 or a == 60 ) -- '&' '<'
end
return r
end -- focus()
local form = function ( a )
return string.format( span,
r,
mw.ustring.sub( adjust, k, j - 1 ),
mw.ustring.sub( adjust, j, a ) )
end -- form()
r = ""
for i = 1, n do
c = mw.ustring.codepoint( adjust, i, i )
if focus( c ) then
if flat( c ) then
if j then
if m then
if i == m then
-- single greek letter.
j = false
end
m = false
end
if j then
local nx = i - 1
local s = ""
for ix = nx, 1, -1 do
c = mw.ustring.sub( adjust, ix, ix )
if c == " " or c == "(" then
nx = nx - 1
s = c .. s
else
break -- for ix
end
end -- for ix
r = form( nx ) .. s
j = false
k = i
end
end
elseif not j then
j = i
if c >= 880 and c <= 1023 then
-- single greek letter?
m = i + 1
else
m = false
end
end
elseif m then
m = m + 1
end
end -- for i
if j and ( not m or m < n ) then
r = form( n )
else
r = r .. mw.ustring.sub( adjust, k )
end
end
return r
end -- Text.uprightNonlatin()
Text.test = function ( about )
local r
if about == "quote" then
data = mw.loadData('Module:Text/data')
r = { }
r.QuoteLang = data.QuoteLang
r.QuoteType = data.QuoteType
end
return r
end -- Text.test()
-- Non Unicode-aware version of mw.text.split and mw.text.gsplit
-- based on [[phab:diffusion/ELUA/browse/master/includes/Engines/LuaCommon/lualib/mw.text.lua]]
-- These run up to 60 times faster than the Unicode-aware versions
Text.split = function ( text, pattern, plain )
local ret = {}
for m in Text.gsplit( text, pattern, plain ) do
ret[#ret+1] = m
end
return ret
end
Text.gsplit = function ( text, pattern, plain )
local s, l = 1, string.len( text )
return function ()
if s then
local e, n = string.find( text, pattern, s, plain )
local ret
if not e then
ret = string.sub( text, s )
s = nil
elseif n < e then
-- Empty separator!
ret = string.sub( text, s, e )
if e < l then
s = e + 1
else
s = nil
end
else
ret = e > s and string.sub( text, s, e - 1 ) or ''
s = n + 1
end
return ret
end
end, nil, nil
end
-- Export
local p = { }
for _, func in ipairs({'containsCJK','isLatinRange','isQuote','sentenceTerminated'}) do
p[func] = function (frame)
return Text[func]( frame.args[ 1 ] or "" ) and "1" or ""
end
end
for _, func in ipairs({'getPlain','removeDiacritics','ucfirstAll','uprightNonlatin'}) do
p[func] = function (frame)
return Text[func]( frame.args[ 1 ] or "" )
end
end
function p.char( frame )
local params = frame:getParent().args
local story = params[ 1 ]
local codes, lenient, multiple
if not story then
params = frame.args
story = params[ 1 ]
end
if story then
local items = mw.text.split( mw.text.trim(story), "%s+" )
if #items > 0 then
local j
lenient = (yesNo(params.errors) == false)
codes = { }
multiple = tonumber( params[ "*" ] )
for _, v in ipairs( items ) do
j = tonumber((v:sub( 1, 1 ) == "x" and "0" or "") .. v)
table.insert( codes, j or v )
end
end
end
return Text.char( codes, multiple, lenient )
end
function p.concatParams( frame )
local args
local template = frame.args.template
if type( template ) == "string" then
template = mw.text.trim( template )
template = ( template == "1" )
end
if template then
args = frame:getParent().args
else
args = frame.args
end
return Text.concatParams( args,
frame.args.separator,
frame.args.format )
end
function p.listToFormat(frame)
local lists = {}
local pformat = frame.args["format"]
local sep = frame.args["sep"] or ";"
-- Parameter parsen: Listen
for k, v in pairs(frame.args) do
local knum = tonumber(k)
if knum then lists[knum] = v end
end
-- Listen splitten
local maxListLen = 0
for i = 1, #lists do
lists[i] = mw.text.split(lists[i], sep)
if #lists[i] > maxListLen then maxListLen = #lists[i] end
end
-- Ergebnisstring generieren
local result = ""
local result_line = ""
for i = 1, maxListLen do
result_line = pformat
for j = 1, #lists do
result_line = mw.ustring.gsub(result_line, "%%s", lists[j][i], 1)
end
result = result .. result_line
end
return result
end
function p.listToText( frame )
local args
local template = frame.args.template
if type( template ) == "string" then
template = mw.text.trim( template )
template = ( template == "1" )
end
if template then
args = frame:getParent().args
else
args = frame.args
end
return Text.listToText( args, frame.args.format )
end
function p.quote( frame )
local slang = frame.args[2]
if type( slang ) == "string" then
slang = mw.text.trim( slang )
if slang == "" then
slang = false
end
end
return Text.quote( frame.args[ 1 ] or "",
slang,
tonumber( frame.args[3] ) )
end
function p.quoteUnquoted( frame )
local slang = frame.args[2]
if type( slang ) == "string" then
slang = mw.text.trim( slang )
if slang == "" then
slang = false
end
end
return Text.quoteUnquoted( frame.args[ 1 ] or "",
slang,
tonumber( frame.args[3] ) )
end
function p.zip(frame)
local lists = {}
local seps = {}
local defaultsep = frame.args["sep"] or ""
local innersep = frame.args["isep"] or ""
local outersep = frame.args["osep"] or ""
-- Parameter parsen
for k, v in pairs(frame.args) do
local knum = tonumber(k)
if knum then lists[knum] = v else
if string.sub(k, 1, 3) == "sep" then
local sepnum = tonumber(string.sub(k, 4))
if sepnum then seps[sepnum] = v end
end
end
end
-- sofern keine expliziten Separatoren angegeben sind, den Standardseparator verwenden
for i = 1, math.max(#seps, #lists) do
if not seps[i] then seps[i] = defaultsep end
end
-- Listen splitten
local maxListLen = 0
for i = 1, #lists do
lists[i] = mw.text.split(lists[i], seps[i])
if #lists[i] > maxListLen then maxListLen = #lists[i] end
end
local result = ""
for i = 1, maxListLen do
if i ~= 1 then result = result .. outersep end
for j = 1, #lists do
if j ~= 1 then result = result .. innersep end
result = result .. (lists[j][i] or "")
end
end
return result
end
function p.split(frame)
local text = frame.args.text or frame.args[1] or ''
local pattern = frame.args.pattern or frame.args[2] or ''
local plain = yesNo(frame.args.plain or frame.args[3])
local index = tonumber(frame.args.index) or tonumber(frame.args[4]) or 1
local a = Text.split(text, pattern, plain)
if index < 0 then index = #a + index + 1 end
return a[index]
end
function p.failsafe()
return Text.serial
end
p.Text = function ()
return Text
end -- p.Text
return p
651uzyv6p5vsoexbfr111b6ilkxeurw
325326
325325
2026-08-22T10:31:21Z
A826
6806
೧ revisions imported from [[:w:ಮಾಡ್ಯೂಲ್:Text]]
325325
Scribunto
text/plain
local yesNo = require("Module:Yesno")
local Text = { serial = "2024-09-21",
suite = "Text" }
--[=[
Text utilities
]=]
local function fiatQuote( apply, alien, advance )
-- Quote text
-- Parameter:
-- apply -- string, with text
-- alien -- string, with language code
-- advance -- number, with level 1 or 2
local r = apply and tostring(apply) or ""
alien = alien or "en"
advance = tonumber(advance) or 0
local suite
local data = mw.loadData('Module:Text/data')
local QuoteLang = data.QuoteLang
local QuoteType = data.QuoteType
local slang = alien:match( "^(%l+)-" )
suite = QuoteLang[alien] or slang and QuoteLang[slang] or QuoteLang["en"]
if suite then
local quotes = QuoteType[ suite ]
if quotes then
local space
if quotes[ 3 ] then
space = " "
else
space = ""
end
quotes = quotes[ advance ]
if quotes then
r = mw.ustring.format( "%s%s%s%s%s",
mw.ustring.char( quotes[ 1 ] ),
space,
apply,
space,
mw.ustring.char( quotes[ 2 ] ) )
end
else
mw.log( "fiatQuote() " .. suite )
end
end
return r
end -- fiatQuote()
Text.char = function ( apply, again, accept )
-- Create string from codepoints
-- Parameter:
-- apply -- table (sequence) with numerical codepoints, or nil
-- again -- number of repetitions, or nil
-- accept -- true, if no error messages to be appended
-- Returns: string
local r = ""
apply = type(apply) == "table" and apply or {}
again = math.floor(tonumber(again) or 1)
if again < 1 then
return ""
end
local bad = { }
local codes = { }
for _, v in ipairs( apply ) do
local n = tonumber(v)
if not n or (n < 32 and n ~= 9 and n ~= 10) then
table.insert(bad, tostring(v))
else
table.insert(codes, math.floor(n))
end
end
if #bad > 0 then
if not accept then
r = tostring( mw.html.create( "span" )
:addClass( "error" )
:wikitext( "bad codepoints: " .. table.concat( bad, " " )) )
end
return r
end
if #codes > 0 then
r = mw.ustring.char( unpack( codes ) )
if again > 1 then
r = r:rep(again)
end
end
return r
end -- Text.char()
local function trimAndFormat(args, fmt)
local result = {}
if type(args) ~= 'table' then
args = {args}
end
for _, v in ipairs(args) do
v = mw.text.trim(tostring(v))
if v ~= "" then
table.insert(result,fmt and mw.ustring.format(fmt, v) or v)
end
end
return result
end
Text.concatParams = function ( args, apply, adapt )
-- Concat list items into one string
-- Parameter:
-- args -- table (sequence) with numKey=string
-- apply -- string (optional); separator (default: "|")
-- adapt -- string (optional); format including "%s"
-- Returns: string
local collect = { }
return table.concat(trimAndFormat(args,adapt), apply or "|")
end -- Text.concatParams()
Text.containsCJK = function ( s )
-- Is any CJK code within?
-- Parameter:
-- s -- string
-- Returns: true, if CJK detected
s = s and tostring(s) or ""
local patternCJK = mw.loadData('Module:Text/data').PatternCJK
return mw.ustring.find( s, patternCJK ) ~= nil
end -- Text.containsCJK()
Text.removeDelimited = function (s, prefix, suffix)
-- Remove all text in s delimited by prefix and suffix (inclusive)
-- Arguments:
-- s = string to process
-- prefix = initial delimiter
-- suffix = ending delimiter
-- Returns: stripped string
s = s and tostring(s) or ""
prefix = prefix and tostring(prefix) or ""
suffix = suffix and tostring(suffix) or ""
local prefixLen = mw.ustring.len(prefix)
local suffixLen = mw.ustring.len(suffix)
if prefixLen == 0 or suffixLen == 0 then
return s
end
local i = s:find(prefix, 1, true)
local r = s
local j
while i do
j = r:find(suffix, i + prefixLen)
if j then
r = r:sub(1, i - 1)..r:sub(j+suffixLen)
else
r = r:sub(1, i - 1)
end
i = r:find(prefix, 1, true)
end
return r
end
Text.getPlain = function ( adjust )
-- Remove wikisyntax from string, except templates
-- Parameter:
-- adjust -- string
-- Returns: string
local r = Text.removeDelimited(adjust,"<!--","-->")
r = r:gsub( "(</?%l[^>]*>)", "" )
:gsub( "'''", "" )
:gsub( "''", "" )
:gsub( " ", " " )
return r
end -- Text.getPlain()
Text.isLatinRange = function (s)
-- Are characters expected to be latin or symbols within latin texts?
-- Arguments:
-- s = string to analyze
-- Returns: true, if valid for latin only
s = s and tostring(s) or "" --- ensure input is always string
local PatternLatin = mw.loadData('Module:Text/data').PatternLatin
return mw.ustring.match(s, PatternLatin) ~= nil
end -- Text.isLatinRange()
Text.isQuote = function ( s )
-- Is this character any quotation mark?
-- Parameter:
-- s = single character to analyze
-- Returns: true, if s is quotation mark
s = s and tostring(s) or ""
if s == "" then
return false
end
local SeekQuote = mw.loadData('Module:Text/data').SeekQuote
return mw.ustring.find( SeekQuote, s, 1, true ) ~= nil
end -- Text.isQuote()
Text.listToText = function ( args, adapt )
-- Format list items similar to mw.text.listToText()
-- Parameter:
-- args -- table (sequence) with numKey=string
-- adapt -- string (optional); format including "%s"
-- Returns: string
return mw.text.listToText(trimAndFormat(args, adapt))
end -- Text.listToText()
Text.quote = function ( apply, alien, advance )
-- Quote text
-- Parameter:
-- apply -- string, with text
-- alien -- string, with language code, or nil
-- advance -- number, with level 1 or 2, or nil
-- Returns: quoted string
apply = apply and tostring(apply) or ""
local mode, slang
if type( alien ) == "string" then
slang = mw.text.trim( alien ):lower()
else
slang = mw.title.getCurrentTitle().pageLanguage
if not slang then
-- TODO FIXME: Introduction expected 2017-04
slang = mw.language.getContentLanguage():getCode()
end
end
if advance == 2 then
mode = 2
else
mode = 1
end
return fiatQuote( mw.text.trim( apply ), slang, mode )
end -- Text.quote()
Text.quoteUnquoted = function ( apply, alien, advance )
-- Quote text, if not yet quoted and not empty
-- Parameter:
-- apply -- string, with text
-- alien -- string, with language code, or nil
-- advance -- number, with level 1 or 2, or nil
-- Returns: string; possibly quoted
local r = mw.text.trim( apply and tostring(apply) or "" )
local s = mw.ustring.sub( r, 1, 1 )
if s ~= "" and not Text.isQuote( s, advance ) then
s = mw.ustring.sub( r, -1, 1 )
if not Text.isQuote( s ) then
r = Text.quote( r, alien, advance )
end
end
return r
end -- Text.quoteUnquoted()
Text.removeDiacritics = function ( adjust )
-- Remove all diacritics
-- Parameter:
-- adjust -- string
-- Returns: string; all latin letters should be ASCII
-- or basic greek or cyrillic or symbols etc.
local cleanup, decomposed
local PatternCombined = mw.loadData('Module:Text/data').PatternCombined
decomposed = mw.ustring.toNFD( adjust and tostring(adjust) or "" )
cleanup = mw.ustring.gsub( decomposed, PatternCombined, "" )
return mw.ustring.toNFC( cleanup )
end -- Text.removeDiacritics()
Text.sentenceTerminated = function ( analyse )
-- Is string terminated by dot, question or exclamation mark?
-- Quotation, link termination and so on granted
-- Parameter:
-- analyse -- string
-- Returns: true, if sentence terminated
local r
local PatternTerminated = mw.loadData('Module:Text/data').PatternTerminated
if mw.ustring.find( analyse, PatternTerminated ) then
r = true
else
r = false
end
return r
end -- Text.sentenceTerminated()
Text.ucfirstAll = function ( adjust)
-- Capitalize all words
-- Arguments:
-- adjust = string to adjust
-- Returns: string with all first letters in upper case
adjust = adjust and tostring(adjust) or ""
local r = mw.text.decode(adjust,true)
local i = 1
local c, j, m
m = (r ~= adjust)
r = " "..r
while i do
i = mw.ustring.find( r, "%W%l", i )
if i then
j = i + 1
c = mw.ustring.upper( mw.ustring.sub( r, j, j ) )
r = string.format( "%s%s%s",
mw.ustring.sub( r, 1, i ),
c,
mw.ustring.sub( r, i + 2 ) )
i = j
end
end -- while i
r = r:sub( 2 )
if m then
r = mw.text.encode(r)
end
return r
end -- Text.ucfirstAll()
Text.uprightNonlatin = function ( adjust )
-- Ensure non-italics for non-latin text parts
-- One single greek letter might be granted
-- Precondition:
-- adjust -- string
-- Returns: string with non-latin parts enclosed in <span>
local r
local data = mw.loadData('Module:Text/data')
local PatternLatin = data.PatternLatin
local RangesLatin = data.RangesLatin
local NumLatinRanges = data.NumLatinRanges
if mw.ustring.match( adjust, PatternLatin ) then
-- latin only, horizontal dashes, quotes
r = adjust
else
local c
local j = false
local k = 1
local m = false
local n = mw.ustring.len( adjust )
local span = "%s%s<span dir='auto' style='font-style:normal'>%s</span>"
local flat = function ( a )
-- isLatin
local range
-- NumLatinRanges has to be precomputed because # does not work from loadData
for i = 1, NumLatinRanges do
range = RangesLatin[ i ]
if a >= range[ 1 ] and a <= range[ 2 ] then
return true
end
end -- for i
end -- flat()
local focus = function ( a )
-- char is not ambivalent
local r = ( a > 64 )
if r then
r = ( a < 8192 or a > 8212 )
else
r = ( a == 38 or a == 60 ) -- '&' '<'
end
return r
end -- focus()
local form = function ( a )
return string.format( span,
r,
mw.ustring.sub( adjust, k, j - 1 ),
mw.ustring.sub( adjust, j, a ) )
end -- form()
r = ""
for i = 1, n do
c = mw.ustring.codepoint( adjust, i, i )
if focus( c ) then
if flat( c ) then
if j then
if m then
if i == m then
-- single greek letter.
j = false
end
m = false
end
if j then
local nx = i - 1
local s = ""
for ix = nx, 1, -1 do
c = mw.ustring.sub( adjust, ix, ix )
if c == " " or c == "(" then
nx = nx - 1
s = c .. s
else
break -- for ix
end
end -- for ix
r = form( nx ) .. s
j = false
k = i
end
end
elseif not j then
j = i
if c >= 880 and c <= 1023 then
-- single greek letter?
m = i + 1
else
m = false
end
end
elseif m then
m = m + 1
end
end -- for i
if j and ( not m or m < n ) then
r = form( n )
else
r = r .. mw.ustring.sub( adjust, k )
end
end
return r
end -- Text.uprightNonlatin()
Text.test = function ( about )
local r
if about == "quote" then
data = mw.loadData('Module:Text/data')
r = { }
r.QuoteLang = data.QuoteLang
r.QuoteType = data.QuoteType
end
return r
end -- Text.test()
-- Non Unicode-aware version of mw.text.split and mw.text.gsplit
-- based on [[phab:diffusion/ELUA/browse/master/includes/Engines/LuaCommon/lualib/mw.text.lua]]
-- These run up to 60 times faster than the Unicode-aware versions
Text.split = function ( text, pattern, plain )
local ret = {}
for m in Text.gsplit( text, pattern, plain ) do
ret[#ret+1] = m
end
return ret
end
Text.gsplit = function ( text, pattern, plain )
local s, l = 1, string.len( text )
return function ()
if s then
local e, n = string.find( text, pattern, s, plain )
local ret
if not e then
ret = string.sub( text, s )
s = nil
elseif n < e then
-- Empty separator!
ret = string.sub( text, s, e )
if e < l then
s = e + 1
else
s = nil
end
else
ret = e > s and string.sub( text, s, e - 1 ) or ''
s = n + 1
end
return ret
end
end, nil, nil
end
-- Export
local p = { }
for _, func in ipairs({'containsCJK','isLatinRange','isQuote','sentenceTerminated'}) do
p[func] = function (frame)
return Text[func]( frame.args[ 1 ] or "" ) and "1" or ""
end
end
for _, func in ipairs({'getPlain','removeDiacritics','ucfirstAll','uprightNonlatin'}) do
p[func] = function (frame)
return Text[func]( frame.args[ 1 ] or "" )
end
end
function p.char( frame )
local params = frame:getParent().args
local story = params[ 1 ]
local codes, lenient, multiple
if not story then
params = frame.args
story = params[ 1 ]
end
if story then
local items = mw.text.split( mw.text.trim(story), "%s+" )
if #items > 0 then
local j
lenient = (yesNo(params.errors) == false)
codes = { }
multiple = tonumber( params[ "*" ] )
for _, v in ipairs( items ) do
j = tonumber((v:sub( 1, 1 ) == "x" and "0" or "") .. v)
table.insert( codes, j or v )
end
end
end
return Text.char( codes, multiple, lenient )
end
function p.concatParams( frame )
local args
local template = frame.args.template
if type( template ) == "string" then
template = mw.text.trim( template )
template = ( template == "1" )
end
if template then
args = frame:getParent().args
else
args = frame.args
end
return Text.concatParams( args,
frame.args.separator,
frame.args.format )
end
function p.listToFormat(frame)
local lists = {}
local pformat = frame.args["format"]
local sep = frame.args["sep"] or ";"
-- Parameter parsen: Listen
for k, v in pairs(frame.args) do
local knum = tonumber(k)
if knum then lists[knum] = v end
end
-- Listen splitten
local maxListLen = 0
for i = 1, #lists do
lists[i] = mw.text.split(lists[i], sep)
if #lists[i] > maxListLen then maxListLen = #lists[i] end
end
-- Ergebnisstring generieren
local result = ""
local result_line = ""
for i = 1, maxListLen do
result_line = pformat
for j = 1, #lists do
result_line = mw.ustring.gsub(result_line, "%%s", lists[j][i], 1)
end
result = result .. result_line
end
return result
end
function p.listToText( frame )
local args
local template = frame.args.template
if type( template ) == "string" then
template = mw.text.trim( template )
template = ( template == "1" )
end
if template then
args = frame:getParent().args
else
args = frame.args
end
return Text.listToText( args, frame.args.format )
end
function p.quote( frame )
local slang = frame.args[2]
if type( slang ) == "string" then
slang = mw.text.trim( slang )
if slang == "" then
slang = false
end
end
return Text.quote( frame.args[ 1 ] or "",
slang,
tonumber( frame.args[3] ) )
end
function p.quoteUnquoted( frame )
local slang = frame.args[2]
if type( slang ) == "string" then
slang = mw.text.trim( slang )
if slang == "" then
slang = false
end
end
return Text.quoteUnquoted( frame.args[ 1 ] or "",
slang,
tonumber( frame.args[3] ) )
end
function p.zip(frame)
local lists = {}
local seps = {}
local defaultsep = frame.args["sep"] or ""
local innersep = frame.args["isep"] or ""
local outersep = frame.args["osep"] or ""
-- Parameter parsen
for k, v in pairs(frame.args) do
local knum = tonumber(k)
if knum then lists[knum] = v else
if string.sub(k, 1, 3) == "sep" then
local sepnum = tonumber(string.sub(k, 4))
if sepnum then seps[sepnum] = v end
end
end
end
-- sofern keine expliziten Separatoren angegeben sind, den Standardseparator verwenden
for i = 1, math.max(#seps, #lists) do
if not seps[i] then seps[i] = defaultsep end
end
-- Listen splitten
local maxListLen = 0
for i = 1, #lists do
lists[i] = mw.text.split(lists[i], seps[i])
if #lists[i] > maxListLen then maxListLen = #lists[i] end
end
local result = ""
for i = 1, maxListLen do
if i ~= 1 then result = result .. outersep end
for j = 1, #lists do
if j ~= 1 then result = result .. innersep end
result = result .. (lists[j][i] or "")
end
end
return result
end
function p.split(frame)
local text = frame.args.text or frame.args[1] or ''
local pattern = frame.args.pattern or frame.args[2] or ''
local plain = yesNo(frame.args.plain or frame.args[3])
local index = tonumber(frame.args.index) or tonumber(frame.args[4]) or 1
local a = Text.split(text, pattern, plain)
if index < 0 then index = #a + index + 1 end
return a[index]
end
function p.failsafe()
return Text.serial
end
p.Text = function ()
return Text
end -- p.Text
return p
651uzyv6p5vsoexbfr111b6ilkxeurw
ಟೆಂಪ್ಲೇಟು:Terminate sentence
10
96685
325327
259528
2024-10-31T15:47:34Z
w>A826
0
೧ ಬದಲಾವಣೆ
259527
wikitext
text/x-wiki
{{{1}}}{{#if:{{#invoke:text|sentenceTerminated|{{{1|}}}}}||{{{2|.}}}}}<noinclude>{{documentation}}</noinclude>
qn47z9jj1gbam5odtqcnrnt6hqvwhtn
325328
325327
2026-08-22T10:31:21Z
A826
6806
೧ revisions imported from [[:w:ಟೆಂಪ್ಲೇಟು:Terminate_sentence]]
259527
wikitext
text/x-wiki
{{{1}}}{{#if:{{#invoke:text|sentenceTerminated|{{{1|}}}}}||{{{2|.}}}}}<noinclude>{{documentation}}</noinclude>
qn47z9jj1gbam5odtqcnrnt6hqvwhtn
ಮಾಡ್ಯೂಲ್:Wd/i18n
828
98920
325311
275872
2025-08-03T13:22:40Z
w>A826
0
೧ revisions imported from [[:en:Module:Wd/i18n]]
325311
Scribunto
text/plain
-- The values and functions in this submodule should be localized per wiki.
local p = {}
function p.init(aliasesP)
p = {
["version"] = "8", -- increment this each time the below parameters are changed to avoid reference conflict errors
["errors"] = {
["unknown-data-type"] = "Unknown or unsupported datatype '%s'.",
["missing-required-parameter"] = "No required parameters defined, needing at least one",
["extra-required-parameter"] = "Parameter '%s' must be defined as optional",
["no-function-specified"] = "You must specify a function to call", -- equal to the standard module error message
["main-called-twice"] = 'The function "main" cannot be called twice',
["no-such-function"] = 'The function "%s" does not exist', -- equal to the standard module error message
["no-such-reference-template"] = 'Error: template "%s", which is set in %s as the output template for the citation-output type "%s", does not exist',
-- Parts of the error message signalling a malformed reference.
["malformed-reference-header"] = "<span style=\"color:#dd3333\">\nError: Unable to display the reference from Wikidata properly. Technical details:\n",
["malformed-reference-footer"] = "See [[Module:wd/doc#References|the documentation]] for further details.\n</span>\n[[Category:Module:Wd reference errors]]",
["template-failure-reason"] = "* Reason for the failure of {{tl|%s}}: %s\n",
["missing-mandatory-param"] = 'The output template call would miss the mandatory parameter <code>%s</code>.',
["unknown-property-in-ref"] = 'The Wikidata reference contains the property {{property|%s}}, which is not assigned to any parameter of this template.'
},
["info"] = {
["edit-on-wikidata"] = "Edit this on Wikidata"
},
["numeric"] = {
["decimal-mark"] = ".",
["delimiter"] = ","
},
["datetime"] = {
["prefixes"] = {
["decade-period"] = ""
},
["suffixes"] = {
["decade-period"] = "s",
["millennium"] = " millennium",
["century"] = " century",
["million-years"] = " million years",
["billion-years"] = " billion years",
["year"] = " year",
["years"] = " years"
},
["julian-calendar"] = "Julian calendar", -- linked page title
["julian"] = "Julian",
["BCE"] = "BCE",
["CE"] = "CE",
["common-era"] = "Common Era" -- linked page title
},
["coord"] = {
["latitude-north"] = "N",
["latitude-south"] = "S",
["longitude-east"] = "E",
["longitude-west"] = "W",
["degrees"] = "°",
["minutes"] = "'",
["seconds"] = '"',
["separator"] = ", "
},
["values"] = {
["unknown"] = "unknown",
["none"] = "none"
},
["cite"] = {
["output-types"] = {"web", "q"}, -- In this order, the output types will be tried
["param-mapping"] = {
["web"] = {
-- <= left side: all allowed reference properties for *web page sources* per https://www.wikidata.org/wiki/Help:Sources
-- => right side: corresponding parameter names in (equivalent of) [[:en:Template:Cite web]] (if non-existent, keep empty i.e. "")
[aliasesP.statedIn] = "website",
[aliasesP.referenceURL] = "url",
[aliasesP.publicationDate] = "date",
[aliasesP.lastUpdate] = "date",
[aliasesP.retrieved] = "access-date",
[aliasesP.title] = "title",
[aliasesP.subjectNamedAs] = "title",
[aliasesP.archiveURL] = "archive-url",
[aliasesP.archiveDate] = "archive-date",
[aliasesP.language] = "language",
[aliasesP.author] = "author",
[aliasesP.authorNameString] = "author",
[aliasesP.publisher] = "publisher",
[aliasesP.quote] = "quote",
[aliasesP.pages] = "pages", -- extra option
[aliasesP.publishedIn] = "website",
[aliasesP.sectionVerseOrParagraph] = "at"
},
["q"] = {
-- <= left side: all allowed reference properties for *sources other than web pages* per https://www.wikidata.org/wiki/Help:Sources
-- => right side: corresponding parameter names in (equivalent of) [[:en:Template:Cite Q]] (if non-existent, keep empty i.e. "")
[aliasesP.statedIn] = "1",
[aliasesP.pages] = "pages",
[aliasesP.column] = "at",
[aliasesP.chapter] = "chapter",
[aliasesP.sectionVerseOrParagraph] = "section",
["external-id"] = "id", -- used for any type of database property ID
[aliasesP.title] = "title",
[aliasesP.publicationDate] = "date",
[aliasesP.lastUpdate] = "date",
[aliasesP.retrieved] = "access-date"
}
},
["config"] = {
-- supported fields:
-- - template: name of the template used for output
-- - numbered-params: citation params accepting an arbitrary number of values by numbering the params (e.g. author1, author2)
-- - raw-value-params: params taking a raw value (which means the property is rendered with getValue with raw=true)
-- - mandatory-params: params that are required be in the template call (after potentially appending numbers to params listed in numbered-params)
-- - prioritization: table associating a list of properties, in the order in which they are preferred, to template parameters;
-- properties not mentioned here have the lowest priority;
-- prioritization of properties handled through additionalProcessedProperties is unsupported;
-- no key of this table can be from numbered-params
-- Leaving out the "template" field causes the output type to be ignored.
["web"] = {
["template"] = "Cite web",
["numbered-params"] = {"author"},
["mandatory-params"] = {"url"},
["prioritization"] = {
["date"] = {aliasesP.lastUpdate, aliasesP.publicationDate},
["title"] = {aliasesP.title, aliasesP.subjectNamedAs}
}
},
["q"] = {
["template"] = "Cite Q",
["raw-value-params"] = {"1"}, -- the first, unnamed parameter of CiteQ takes a QID, not the name of the item cited
["mandatory-params"] = {"1"},
["prioritization"] = {
["date"] = {aliasesP.lastUpdate, aliasesP.publicationDate}
}
}
}
}
}
p.getOrdinalSuffix = function(num)
if tostring(num):sub(-2,-2) == '1' then
return "th" -- 10th, 11th, 12th, 13th, ... 19th
end
num = tostring(num):sub(-1)
if num == '1' then
return "st"
elseif num == '2' then
return "nd"
elseif num == '3' then
return "rd"
else
return "th"
end
end
p.addDelimiters = function(n)
local left, num, right = string.match(n, "^([^%d]*%d)(%d*)(.-)$")
if left and num and right then
return left .. (num:reverse():gsub("(%d%d%d)", "%1" .. p['numeric']['delimiter']):reverse()) .. right
else
return n
end
end
return p
end
return p
pgkxz3kqyoyu0zj2nmtkjkdr0ntnin5
325312
325145
2026-08-22T10:31:19Z
A826
6806
೧ revisions imported from [[:w:ಮಾಡ್ಯೂಲ್:Wd/i18n]]
325145
Scribunto
text/plain
-- The values and functions in this submodule should be localized per wiki.
local p = {}
function p.init(aliasesP)
p = {
["version"] = "8", -- increment this each time the below parameters are changed to avoid reference conflict errors
["errors"] = {
["unknown-data-type"] = "Unknown or unsupported datatype '%s'.",
["missing-required-parameter"] = "No required parameters defined, needing at least one",
["extra-required-parameter"] = "Parameter '%s' must be defined as optional",
["no-function-specified"] = "You must specify a function to call", -- equal to the standard module error message
["main-called-twice"] = 'The function "main" cannot be called twice',
["no-such-function"] = 'The function "%s" does not exist', -- equal to the standard module error message
["no-such-reference-template"] = 'Error: template "%s", which is set in %s as the output template for the citation-output type "%s", does not exist',
-- Parts of the error message signalling a malformed reference.
["malformed-reference-header"] = "<span style=\"color:#dd3333\">\nError: Unable to display the reference from Wikidata properly. Technical details:\n",
["malformed-reference-footer"] = "See [[Module:wd/doc#References|the documentation]] for further details.\n</span>\n[[Category:Module:Wd reference errors]]",
["template-failure-reason"] = "* Reason for the failure of {{tl|%s}}: %s\n",
["missing-mandatory-param"] = 'The output template call would miss the mandatory parameter <code>%s</code>.',
["unknown-property-in-ref"] = 'The Wikidata reference contains the property {{property|%s}}, which is not assigned to any parameter of this template.'
},
["info"] = {
["edit-on-wikidata"] = "Edit this on Wikidata"
},
["numeric"] = {
["decimal-mark"] = ".",
["delimiter"] = ","
},
["datetime"] = {
["prefixes"] = {
["decade-period"] = ""
},
["suffixes"] = {
["decade-period"] = "s",
["millennium"] = " millennium",
["century"] = " century",
["million-years"] = " million years",
["billion-years"] = " billion years",
["year"] = " year",
["years"] = " years"
},
["julian-calendar"] = "Julian calendar", -- linked page title
["julian"] = "Julian",
["BCE"] = "BCE",
["CE"] = "CE",
["common-era"] = "Common Era" -- linked page title
},
["coord"] = {
["latitude-north"] = "N",
["latitude-south"] = "S",
["longitude-east"] = "E",
["longitude-west"] = "W",
["degrees"] = "°",
["minutes"] = "'",
["seconds"] = '"',
["separator"] = ", "
},
["values"] = {
["unknown"] = "unknown",
["none"] = "none"
},
["cite"] = {
["output-types"] = {"web", "q"}, -- In this order, the output types will be tried
["param-mapping"] = {
["web"] = {
-- <= left side: all allowed reference properties for *web page sources* per https://www.wikidata.org/wiki/Help:Sources
-- => right side: corresponding parameter names in (equivalent of) [[:en:Template:Cite web]] (if non-existent, keep empty i.e. "")
[aliasesP.statedIn] = "website",
[aliasesP.referenceURL] = "url",
[aliasesP.publicationDate] = "date",
[aliasesP.lastUpdate] = "date",
[aliasesP.retrieved] = "access-date",
[aliasesP.title] = "title",
[aliasesP.subjectNamedAs] = "title",
[aliasesP.archiveURL] = "archive-url",
[aliasesP.archiveDate] = "archive-date",
[aliasesP.language] = "language",
[aliasesP.author] = "author",
[aliasesP.authorNameString] = "author",
[aliasesP.publisher] = "publisher",
[aliasesP.quote] = "quote",
[aliasesP.pages] = "pages", -- extra option
[aliasesP.publishedIn] = "website",
[aliasesP.sectionVerseOrParagraph] = "at"
},
["q"] = {
-- <= left side: all allowed reference properties for *sources other than web pages* per https://www.wikidata.org/wiki/Help:Sources
-- => right side: corresponding parameter names in (equivalent of) [[:en:Template:Cite Q]] (if non-existent, keep empty i.e. "")
[aliasesP.statedIn] = "1",
[aliasesP.pages] = "pages",
[aliasesP.column] = "at",
[aliasesP.chapter] = "chapter",
[aliasesP.sectionVerseOrParagraph] = "section",
["external-id"] = "id", -- used for any type of database property ID
[aliasesP.title] = "title",
[aliasesP.publicationDate] = "date",
[aliasesP.lastUpdate] = "date",
[aliasesP.retrieved] = "access-date"
}
},
["config"] = {
-- supported fields:
-- - template: name of the template used for output
-- - numbered-params: citation params accepting an arbitrary number of values by numbering the params (e.g. author1, author2)
-- - raw-value-params: params taking a raw value (which means the property is rendered with getValue with raw=true)
-- - mandatory-params: params that are required be in the template call (after potentially appending numbers to params listed in numbered-params)
-- - prioritization: table associating a list of properties, in the order in which they are preferred, to template parameters;
-- properties not mentioned here have the lowest priority;
-- prioritization of properties handled through additionalProcessedProperties is unsupported;
-- no key of this table can be from numbered-params
-- Leaving out the "template" field causes the output type to be ignored.
["web"] = {
["template"] = "Cite web",
["numbered-params"] = {"author"},
["mandatory-params"] = {"url"},
["prioritization"] = {
["date"] = {aliasesP.lastUpdate, aliasesP.publicationDate},
["title"] = {aliasesP.title, aliasesP.subjectNamedAs}
}
},
["q"] = {
["template"] = "Cite Q",
["raw-value-params"] = {"1"}, -- the first, unnamed parameter of CiteQ takes a QID, not the name of the item cited
["mandatory-params"] = {"1"},
["prioritization"] = {
["date"] = {aliasesP.lastUpdate, aliasesP.publicationDate}
}
}
}
}
}
p.getOrdinalSuffix = function(num)
if tostring(num):sub(-2,-2) == '1' then
return "th" -- 10th, 11th, 12th, 13th, ... 19th
end
num = tostring(num):sub(-1)
if num == '1' then
return "st"
elseif num == '2' then
return "nd"
elseif num == '3' then
return "rd"
else
return "th"
end
end
p.addDelimiters = function(n)
local left, num, right = string.match(n, "^([^%d]*%d)(%d*)(.-)$")
if left and num and right then
return left .. (num:reverse():gsub("(%d%d%d)", "%1" .. p['numeric']['delimiter']):reverse()) .. right
else
return n
end
end
return p
end
return p
pgkxz3kqyoyu0zj2nmtkjkdr0ntnin5
ಟೆಂಪ್ಲೇಟು:Databox
10
121070
325303
2026-07-26T16:17:23Z
w>A826
0
Protected "[[ಟೆಂಪ್ಲೇಟು:Databox]]": ಹೆಚ್ಚಿನ ದಟ್ಟಣೆ ಪುಟ ([ಸಂಪಾದನೆ=ನಿರ್ವಾಹಕರು ಮಾತ್ರ] (ಅನಿರ್ದಿಷ್ಟ) [ಸ್ಥಳಾಂತರ=ನಿರ್ವಾಹಕರು ಮಾತ್ರ] (ಅನಿರ್ದಿಷ್ಟ))
325303
wikitext
text/x-wiki
{{#invoke:Databox|databox|useImage={{{useImage|}}}|excludeProperties={{{excludeProperties|}}}}}
etixe24he4rn2h9b4euxkal7ihzwk91
325304
325303
2026-08-22T10:30:37Z
A826
6806
೧ revisions imported from [[:w:ಟೆಂಪ್ಲೇಟು:Databox]]
325303
wikitext
text/x-wiki
{{#invoke:Databox|databox|useImage={{{useImage|}}}|excludeProperties={{{excludeProperties|}}}}}
etixe24he4rn2h9b4euxkal7ihzwk91
ಮಾಡ್ಯೂಲ್:Databox
828
121071
325305
2026-08-06T05:07:45Z
w>A826
0
325305
Scribunto
text/plain
-- A modified version based on sv.wikipedia.org/wiki/Modul:Databox
-- Displays Wikidata properties dynamically inside an infobox.
function valuesToKeys(array)
local result = {}
for _, v in pairs(array) do
result[v] = true
end
return result
end
local p = {}
function p.databox(frame)
local args = frame:getParent().args
local argsLocal = frame.args
local itemId = nil
if args.item then
itemId = args.item
end
local useImage = nil
if argsLocal.useImage then
useImage = argsLocal["useImage"]
end
-- Option to display aliases below the title (defaults to true)
local useAliases = true
if argsLocal.useAliases and (argsLocal.useAliases == "false" or argsLocal.useAliases == "no" or argsLocal.useAliases == "0") then
useAliases = false
end
-- local excludeProperties parameter allows excluding specific properties per page if needed
local excludeProperties = {}
if argsLocal.excludeProperties then
for item in string.gmatch(argsLocal.excludeProperties, "[^,]+") do
table.insert(excludeProperties, item)
end
end
local lang = mw.language.getContentLanguage()
local item = mw.wikibase.getEntity(itemId)
if item == nil then
mw.addWarning("Wikidata item not found")
return ""
end
local databoxRoot = mw.html.create('div')
:addClass('infobox')
:css({
float = 'right',
border = '1px solid #aaa',
['max-width'] = '250px',
padding = '0 0.4em',
margin = '0 0 0.4em 0.4em',
})
-- Title
local titleDiv = databoxRoot:tag('div')
:css({
['text-align'] = 'center',
['background-color'] = '#f5f5f5',
padding = '0.5em 0',
margin = '0.5em 0',
['font-size'] = '120%',
['font-weight'] = 'bold',
})
:wikitext(item:getLabel() or mw.title.getCurrentTitle().text)
-- Aliases display (Color set to #6f9f9c)
if useAliases and item.aliases then
local langCode = lang:getCode()
local aliases = item.aliases[langCode]
if aliases and #aliases > 0 then
local aliasList = {}
for _, aliasObj in ipairs(aliases) do
table.insert(aliasList, aliasObj.value)
end
titleDiv:tag('div')
:css({
['font-size'] = '75%',
['font-weight'] = 'normal',
['font-style'] = 'italic',
['color'] = '#6f9f9c',
['margin-top'] = '0.2em'
})
:wikitext(table.concat(aliasList, ', '))
end
end
-- Image
local databoxImage = nil
if useImage and useImage ~= "" then
local allWikidataImages = item:getAllStatements('P18')
if #allWikidataImages >= 1 then
for _, image in ipairs( allWikidataImages ) do
if image.mainsnak.datavalue.value == useImage then
databoxImage = useImage
break
end
end
end
end
if databoxImage == nil then
local bestWikidataImages = item:getBestStatements('P18')
if #bestWikidataImages >= 1 then
databoxImage = bestWikidataImages[1].mainsnak.datavalue.value
end
end
if databoxImage then
databoxRoot
:tag('div')
:wikitext('[[File:' .. databoxImage .. '|frameless|240px|center]]')
end
-- Signature (P109)
local signatureImage = nil
local signatureImages = item:getBestStatements('P109')
if #signatureImages >= 1 then
signatureImage = signatureImages[1].mainsnak.datavalue.value
end
if signatureImage then
databoxRoot
:tag('div')
:css({
['text-align'] = 'center',
['font-size'] = '90%',
['font-style'] = 'italic',
padding = '0.2em 0',
})
:wikitext('Signature')
databoxRoot
:tag('div')
:wikitext('[[File:' .. signatureImage .. '|frameless|200px|center]]')
end
-- Table
local dataTable = databoxRoot
:tag('table')
:css({
['text-align'] = 'left',
['font-size'] = '90%',
['word-break'] = 'break-word',
['width'] = '100%',
['table-layout'] = 'fixed',
})
dataTable:tag('caption')
:addClass('notheme')
:css({
['background-color'] = '#f5f5f5',
['font-weight'] = 'bold',
['margin-top'] = '0.2em',
})
:wikitext(item:formatStatements('P31').value)
local properties = mw.wikibase.orderProperties(item:getProperties())
-- Excluded property table handles local exclusions
local excludeProperties_hash = valuesToKeys(excludeProperties)
excludeProperties_hash['P31'] = true -- Instance of
excludeProperties_hash['P373'] = true -- Commons category
excludeProperties_hash['P935'] = true -- Commons gallery
excludeProperties_hash['P910'] = true -- Main category of topic
excludeProperties_hash['P1792'] = true -- Category of associated people
excludeProperties_hash['P9495'] = true -- Category for maps or plans
excludeProperties_hash['P1014'] = true -- Category for pictures taken with this camera
excludeProperties_hash['P5777'] = true -- Category for the view of the item
excludeProperties_hash['P8744'] = true -- Economy of topic
excludeProperties_hash['P8745'] = true -- Demographics of topic
excludeProperties_hash['P1889'] = true -- Different from
local edit_message = mw.message.new('vector-view-edit'):plain()
for _, property in pairs(properties) do
local datatype = item.claims[property][1].mainsnak.datatype
local valueCount = #item:getBestStatements(property)
if datatype ~= 'commonsMedia' and datatype ~= 'external-id' and datatype ~= 'quantity' and datatype ~= 'wikibase-property' and datatype ~= 'geo-shape' and datatype ~= 'tabular-data' and not excludeProperties_hash[property] and valueCount > 0 and valueCount <= 5 then
local propertyValue = item:formatStatements(property)
if propertyValue and propertyValue.value then
-- Get the raw value to make it clickable
local displayValue = propertyValue.value
local claims = item.claims[property]
if claims then
local linkedValues = {}
for _, claim in ipairs(claims) do
if claim.mainsnak and claim.mainsnak.datavalue then
local value = claim.mainsnak.datavalue.value
if type(value) == 'table' and value.id then
-- It's a Wikidata item, create a link
local entity = mw.wikibase.getEntity(value.id)
if entity then
local label = entity:getLabel()
if label then
table.insert(linkedValues, '[[:d:' .. value.id .. '|' .. label .. ']]')
else
table.insert(linkedValues, '[[:d:' .. value.id .. '|' .. value.id .. ']]')
end
else
table.insert(linkedValues, '[[:d:' .. value.id .. '|' .. value.id .. ']]')
end
elseif type(value) == 'string' then
table.insert(linkedValues, value)
elseif type(value) == 'number' then
table.insert(linkedValues, tostring(value))
end
end
end
if #linkedValues > 0 then
displayValue = table.concat(linkedValues, ', ')
end
end
dataTable:tag('tr')
:tag('th')
:attr('scope', 'row')
:wikitext(lang:ucfirst(propertyValue.label)):done()
:tag('td')
:wikitext(displayValue)
:wikitext(' [[File:OOjs UI icon edit-ltr.svg|' .. edit_message .. '|12px|baseline|class=noviewer|link=https://www.wikidata.org/wiki/' .. item.id .. '#' .. property .. ']]')
end
end
end
-- Helper function to clean category name
local function cleanCategoryName(value)
if not value then return nil end
if type(value) == 'table' then
value = tostring(value)
end
value = value:gsub("^Category:", "")
value = value:gsub("^%s+", ""):gsub("%s+$", "")
return value
end
-- Helper function to get entity label or value
local function getEntityLabel(value)
if type(value) == 'table' and value.id then
local entity = mw.wikibase.getEntity(value.id)
if entity then
return entity:getLabel() or value.id
end
return value.id
elseif type(value) == 'table' then
return tostring(value)
end
return value
end
-- Economy of topic (P8744)
local economyStatements = item:getBestStatements('P8744')
if #economyStatements >= 1 and economyStatements[1].mainsnak.datavalue then
local economyValue = economyStatements[1].mainsnak.datavalue.value
local displayValue = getEntityLabel(economyValue)
if displayValue then
dataTable:tag('tr')
:tag('th')
:attr('scope', 'row')
:wikitext('Economy of topic'):done()
:tag('td')
:wikitext("'''" .. displayValue .. "'''")
:wikitext(' [[File:OOjs UI icon edit-ltr.svg|' .. edit_message .. '|12px|baseline|class=noviewer|link=https://www.wikidata.org/wiki/' .. item.id .. '#P8744]]')
end
end
-- Demographics of topic (P8745)
local demographicsStatements = item:getBestStatements('P8745')
if #demographicsStatements >= 1 and demographicsStatements[1].mainsnak.datavalue then
local demographicsValue = demographicsStatements[1].mainsnak.datavalue.value
local displayValue = getEntityLabel(demographicsValue)
if displayValue then
dataTable:tag('tr')
:tag('th')
:attr('scope', 'row')
:wikitext('Demographics of topic'):done()
:tag('td')
:wikitext("'''" .. displayValue .. "'''")
:wikitext(' [[File:OOjs UI icon edit-ltr.svg|' .. edit_message .. '|12px|baseline|class=noviewer|link=https://www.wikidata.org/wiki/' .. item.id .. '#P8745]]')
end
end
-- Different from (P1889)
local differentFromStatements = item:getBestStatements('P1889')
if #differentFromStatements >= 1 and differentFromStatements[1].mainsnak.datavalue then
local differentFromValue = differentFromStatements[1].mainsnak.datavalue.value
local displayValue = getEntityLabel(differentFromValue)
if displayValue then
dataTable:tag('tr')
:tag('th')
:attr('scope', 'row')
:wikitext('Different from'):done()
:tag('td')
:wikitext("'''" .. displayValue .. "'''")
:wikitext(' [[File:OOjs UI icon edit-ltr.svg|' .. edit_message .. '|12px|baseline|class=noviewer|link=https://www.wikidata.org/wiki/' .. item.id .. '#P1889]]')
end
end
-- Commons Gallery (P935)
local commonsGalleryStatements = item:getBestStatements('P935')
if #commonsGalleryStatements >= 1 and commonsGalleryStatements[1].mainsnak.datavalue then
local commonsGallery = commonsGalleryStatements[1].mainsnak.datavalue.value
local displayValue = getEntityLabel(commonsGallery)
if displayValue then
local cleanValue = cleanCategoryName(displayValue)
dataTable:tag('tr')
:tag('th')
:attr('scope', 'row')
:wikitext('Commons gallery'):done()
:tag('td')
:wikitext('[[:commons:' .. cleanValue .. '|' .. cleanValue .. ']]')
:wikitext(' [[File:OOjs UI icon edit-ltr.svg|' .. edit_message .. '|12px|baseline|class=noviewer|link=https://www.wikidata.org/wiki/' .. item.id .. '#P935]]')
end
end
-- Commons Category (P373)
local commonsCategoryStatements = item:getBestStatements('P373')
if #commonsCategoryStatements >= 1 and commonsCategoryStatements[1].mainsnak.datavalue then
local commonsCat = commonsCategoryStatements[1].mainsnak.datavalue.value
local displayValue = getEntityLabel(commonsCat)
if displayValue then
-- Split categories if multiple (comma separated)
local categories = {}
for cat in string.gmatch(displayValue, "[^,]+") do
local trimmedCat = cat:gsub("^%s+", ""):gsub("%s+$", "")
local cleanCat = cleanCategoryName(trimmedCat)
categories[#categories + 1] = '[[:commons:Category:' .. cleanCat .. '|' .. cleanCat .. ']]'
end
local categoryLinksText = table.concat(categories, ' • ')
dataTable:tag('tr')
:tag('th')
:attr('scope', 'row')
:wikitext('Commons category'):done()
:tag('td')
:wikitext(categoryLinksText)
:wikitext(' [[File:OOjs UI icon edit-ltr.svg|' .. edit_message .. '|12px|baseline|class=noviewer|link=https://www.wikidata.org/wiki/' .. item.id .. '#P373]]')
end
end
-- Map
local coordinates_statements = item:getBestStatements('P625')
if #coordinates_statements >= 1 and coordinates_statements[1].mainsnak.datavalue and coordinates_statements[1].mainsnak.datavalue.value.globe == 'http://www.wikidata.org/entity/Q2' then
-- Build the call to mapframe
local latitude = coordinates_statements[1].mainsnak.datavalue.value.latitude
local longitude = coordinates_statements[1].mainsnak.datavalue.value.longitude
local geojson = {
type = 'Feature',
geometry = {
type = 'Point',
coordinates = { longitude, latitude }
},
properties = {
title = item:getLabel() or mw.title.getCurrentTitle().text,
['marker-symbol'] = 'marker',
['marker-color'] = '#224422',
}
}
databoxRoot:wikitext(frame:extensionTag('mapframe', mw.text.jsonEncode(geojson), {
height = 240,
width = 240,
frameless = 'frameless',
align = 'center',
latitude = latitude,
longitude = longitude,
zoom = zoom
}))
end
-- Wikidata Link (Footer)
databoxRoot:tag('div')
:css({
['display'] = 'flex',
['align-items'] = 'center',
['justify-content'] = 'center',
padding = '0.3em 0',
['width'] = '100%',
['font-size'] = '90%',
['text-align'] = 'center',
})
:addClass('databox-from-wikidata-link')
:wikitext('[[File:Wikidata-logo.svg|22px|class=noviewer skin-invert|link=https://www.wikidata.org/wiki/' .. item.id .. ']]')
:tag('div')
:css({ margin = '0 0 0 0.3em' })
:wikitext('[[d:' .. item.id .. '|From Wikidata]]')
return tostring(databoxRoot)
end
return p
5bdvkd90hwgtbjtbzg8cl43ntkqlay9
325306
325305
2026-08-22T10:30:37Z
A826
6806
೧ revisions imported from [[:w:ಮಾಡ್ಯೂಲ್:Databox]]
325305
Scribunto
text/plain
-- A modified version based on sv.wikipedia.org/wiki/Modul:Databox
-- Displays Wikidata properties dynamically inside an infobox.
function valuesToKeys(array)
local result = {}
for _, v in pairs(array) do
result[v] = true
end
return result
end
local p = {}
function p.databox(frame)
local args = frame:getParent().args
local argsLocal = frame.args
local itemId = nil
if args.item then
itemId = args.item
end
local useImage = nil
if argsLocal.useImage then
useImage = argsLocal["useImage"]
end
-- Option to display aliases below the title (defaults to true)
local useAliases = true
if argsLocal.useAliases and (argsLocal.useAliases == "false" or argsLocal.useAliases == "no" or argsLocal.useAliases == "0") then
useAliases = false
end
-- local excludeProperties parameter allows excluding specific properties per page if needed
local excludeProperties = {}
if argsLocal.excludeProperties then
for item in string.gmatch(argsLocal.excludeProperties, "[^,]+") do
table.insert(excludeProperties, item)
end
end
local lang = mw.language.getContentLanguage()
local item = mw.wikibase.getEntity(itemId)
if item == nil then
mw.addWarning("Wikidata item not found")
return ""
end
local databoxRoot = mw.html.create('div')
:addClass('infobox')
:css({
float = 'right',
border = '1px solid #aaa',
['max-width'] = '250px',
padding = '0 0.4em',
margin = '0 0 0.4em 0.4em',
})
-- Title
local titleDiv = databoxRoot:tag('div')
:css({
['text-align'] = 'center',
['background-color'] = '#f5f5f5',
padding = '0.5em 0',
margin = '0.5em 0',
['font-size'] = '120%',
['font-weight'] = 'bold',
})
:wikitext(item:getLabel() or mw.title.getCurrentTitle().text)
-- Aliases display (Color set to #6f9f9c)
if useAliases and item.aliases then
local langCode = lang:getCode()
local aliases = item.aliases[langCode]
if aliases and #aliases > 0 then
local aliasList = {}
for _, aliasObj in ipairs(aliases) do
table.insert(aliasList, aliasObj.value)
end
titleDiv:tag('div')
:css({
['font-size'] = '75%',
['font-weight'] = 'normal',
['font-style'] = 'italic',
['color'] = '#6f9f9c',
['margin-top'] = '0.2em'
})
:wikitext(table.concat(aliasList, ', '))
end
end
-- Image
local databoxImage = nil
if useImage and useImage ~= "" then
local allWikidataImages = item:getAllStatements('P18')
if #allWikidataImages >= 1 then
for _, image in ipairs( allWikidataImages ) do
if image.mainsnak.datavalue.value == useImage then
databoxImage = useImage
break
end
end
end
end
if databoxImage == nil then
local bestWikidataImages = item:getBestStatements('P18')
if #bestWikidataImages >= 1 then
databoxImage = bestWikidataImages[1].mainsnak.datavalue.value
end
end
if databoxImage then
databoxRoot
:tag('div')
:wikitext('[[File:' .. databoxImage .. '|frameless|240px|center]]')
end
-- Signature (P109)
local signatureImage = nil
local signatureImages = item:getBestStatements('P109')
if #signatureImages >= 1 then
signatureImage = signatureImages[1].mainsnak.datavalue.value
end
if signatureImage then
databoxRoot
:tag('div')
:css({
['text-align'] = 'center',
['font-size'] = '90%',
['font-style'] = 'italic',
padding = '0.2em 0',
})
:wikitext('Signature')
databoxRoot
:tag('div')
:wikitext('[[File:' .. signatureImage .. '|frameless|200px|center]]')
end
-- Table
local dataTable = databoxRoot
:tag('table')
:css({
['text-align'] = 'left',
['font-size'] = '90%',
['word-break'] = 'break-word',
['width'] = '100%',
['table-layout'] = 'fixed',
})
dataTable:tag('caption')
:addClass('notheme')
:css({
['background-color'] = '#f5f5f5',
['font-weight'] = 'bold',
['margin-top'] = '0.2em',
})
:wikitext(item:formatStatements('P31').value)
local properties = mw.wikibase.orderProperties(item:getProperties())
-- Excluded property table handles local exclusions
local excludeProperties_hash = valuesToKeys(excludeProperties)
excludeProperties_hash['P31'] = true -- Instance of
excludeProperties_hash['P373'] = true -- Commons category
excludeProperties_hash['P935'] = true -- Commons gallery
excludeProperties_hash['P910'] = true -- Main category of topic
excludeProperties_hash['P1792'] = true -- Category of associated people
excludeProperties_hash['P9495'] = true -- Category for maps or plans
excludeProperties_hash['P1014'] = true -- Category for pictures taken with this camera
excludeProperties_hash['P5777'] = true -- Category for the view of the item
excludeProperties_hash['P8744'] = true -- Economy of topic
excludeProperties_hash['P8745'] = true -- Demographics of topic
excludeProperties_hash['P1889'] = true -- Different from
local edit_message = mw.message.new('vector-view-edit'):plain()
for _, property in pairs(properties) do
local datatype = item.claims[property][1].mainsnak.datatype
local valueCount = #item:getBestStatements(property)
if datatype ~= 'commonsMedia' and datatype ~= 'external-id' and datatype ~= 'quantity' and datatype ~= 'wikibase-property' and datatype ~= 'geo-shape' and datatype ~= 'tabular-data' and not excludeProperties_hash[property] and valueCount > 0 and valueCount <= 5 then
local propertyValue = item:formatStatements(property)
if propertyValue and propertyValue.value then
-- Get the raw value to make it clickable
local displayValue = propertyValue.value
local claims = item.claims[property]
if claims then
local linkedValues = {}
for _, claim in ipairs(claims) do
if claim.mainsnak and claim.mainsnak.datavalue then
local value = claim.mainsnak.datavalue.value
if type(value) == 'table' and value.id then
-- It's a Wikidata item, create a link
local entity = mw.wikibase.getEntity(value.id)
if entity then
local label = entity:getLabel()
if label then
table.insert(linkedValues, '[[:d:' .. value.id .. '|' .. label .. ']]')
else
table.insert(linkedValues, '[[:d:' .. value.id .. '|' .. value.id .. ']]')
end
else
table.insert(linkedValues, '[[:d:' .. value.id .. '|' .. value.id .. ']]')
end
elseif type(value) == 'string' then
table.insert(linkedValues, value)
elseif type(value) == 'number' then
table.insert(linkedValues, tostring(value))
end
end
end
if #linkedValues > 0 then
displayValue = table.concat(linkedValues, ', ')
end
end
dataTable:tag('tr')
:tag('th')
:attr('scope', 'row')
:wikitext(lang:ucfirst(propertyValue.label)):done()
:tag('td')
:wikitext(displayValue)
:wikitext(' [[File:OOjs UI icon edit-ltr.svg|' .. edit_message .. '|12px|baseline|class=noviewer|link=https://www.wikidata.org/wiki/' .. item.id .. '#' .. property .. ']]')
end
end
end
-- Helper function to clean category name
local function cleanCategoryName(value)
if not value then return nil end
if type(value) == 'table' then
value = tostring(value)
end
value = value:gsub("^Category:", "")
value = value:gsub("^%s+", ""):gsub("%s+$", "")
return value
end
-- Helper function to get entity label or value
local function getEntityLabel(value)
if type(value) == 'table' and value.id then
local entity = mw.wikibase.getEntity(value.id)
if entity then
return entity:getLabel() or value.id
end
return value.id
elseif type(value) == 'table' then
return tostring(value)
end
return value
end
-- Economy of topic (P8744)
local economyStatements = item:getBestStatements('P8744')
if #economyStatements >= 1 and economyStatements[1].mainsnak.datavalue then
local economyValue = economyStatements[1].mainsnak.datavalue.value
local displayValue = getEntityLabel(economyValue)
if displayValue then
dataTable:tag('tr')
:tag('th')
:attr('scope', 'row')
:wikitext('Economy of topic'):done()
:tag('td')
:wikitext("'''" .. displayValue .. "'''")
:wikitext(' [[File:OOjs UI icon edit-ltr.svg|' .. edit_message .. '|12px|baseline|class=noviewer|link=https://www.wikidata.org/wiki/' .. item.id .. '#P8744]]')
end
end
-- Demographics of topic (P8745)
local demographicsStatements = item:getBestStatements('P8745')
if #demographicsStatements >= 1 and demographicsStatements[1].mainsnak.datavalue then
local demographicsValue = demographicsStatements[1].mainsnak.datavalue.value
local displayValue = getEntityLabel(demographicsValue)
if displayValue then
dataTable:tag('tr')
:tag('th')
:attr('scope', 'row')
:wikitext('Demographics of topic'):done()
:tag('td')
:wikitext("'''" .. displayValue .. "'''")
:wikitext(' [[File:OOjs UI icon edit-ltr.svg|' .. edit_message .. '|12px|baseline|class=noviewer|link=https://www.wikidata.org/wiki/' .. item.id .. '#P8745]]')
end
end
-- Different from (P1889)
local differentFromStatements = item:getBestStatements('P1889')
if #differentFromStatements >= 1 and differentFromStatements[1].mainsnak.datavalue then
local differentFromValue = differentFromStatements[1].mainsnak.datavalue.value
local displayValue = getEntityLabel(differentFromValue)
if displayValue then
dataTable:tag('tr')
:tag('th')
:attr('scope', 'row')
:wikitext('Different from'):done()
:tag('td')
:wikitext("'''" .. displayValue .. "'''")
:wikitext(' [[File:OOjs UI icon edit-ltr.svg|' .. edit_message .. '|12px|baseline|class=noviewer|link=https://www.wikidata.org/wiki/' .. item.id .. '#P1889]]')
end
end
-- Commons Gallery (P935)
local commonsGalleryStatements = item:getBestStatements('P935')
if #commonsGalleryStatements >= 1 and commonsGalleryStatements[1].mainsnak.datavalue then
local commonsGallery = commonsGalleryStatements[1].mainsnak.datavalue.value
local displayValue = getEntityLabel(commonsGallery)
if displayValue then
local cleanValue = cleanCategoryName(displayValue)
dataTable:tag('tr')
:tag('th')
:attr('scope', 'row')
:wikitext('Commons gallery'):done()
:tag('td')
:wikitext('[[:commons:' .. cleanValue .. '|' .. cleanValue .. ']]')
:wikitext(' [[File:OOjs UI icon edit-ltr.svg|' .. edit_message .. '|12px|baseline|class=noviewer|link=https://www.wikidata.org/wiki/' .. item.id .. '#P935]]')
end
end
-- Commons Category (P373)
local commonsCategoryStatements = item:getBestStatements('P373')
if #commonsCategoryStatements >= 1 and commonsCategoryStatements[1].mainsnak.datavalue then
local commonsCat = commonsCategoryStatements[1].mainsnak.datavalue.value
local displayValue = getEntityLabel(commonsCat)
if displayValue then
-- Split categories if multiple (comma separated)
local categories = {}
for cat in string.gmatch(displayValue, "[^,]+") do
local trimmedCat = cat:gsub("^%s+", ""):gsub("%s+$", "")
local cleanCat = cleanCategoryName(trimmedCat)
categories[#categories + 1] = '[[:commons:Category:' .. cleanCat .. '|' .. cleanCat .. ']]'
end
local categoryLinksText = table.concat(categories, ' • ')
dataTable:tag('tr')
:tag('th')
:attr('scope', 'row')
:wikitext('Commons category'):done()
:tag('td')
:wikitext(categoryLinksText)
:wikitext(' [[File:OOjs UI icon edit-ltr.svg|' .. edit_message .. '|12px|baseline|class=noviewer|link=https://www.wikidata.org/wiki/' .. item.id .. '#P373]]')
end
end
-- Map
local coordinates_statements = item:getBestStatements('P625')
if #coordinates_statements >= 1 and coordinates_statements[1].mainsnak.datavalue and coordinates_statements[1].mainsnak.datavalue.value.globe == 'http://www.wikidata.org/entity/Q2' then
-- Build the call to mapframe
local latitude = coordinates_statements[1].mainsnak.datavalue.value.latitude
local longitude = coordinates_statements[1].mainsnak.datavalue.value.longitude
local geojson = {
type = 'Feature',
geometry = {
type = 'Point',
coordinates = { longitude, latitude }
},
properties = {
title = item:getLabel() or mw.title.getCurrentTitle().text,
['marker-symbol'] = 'marker',
['marker-color'] = '#224422',
}
}
databoxRoot:wikitext(frame:extensionTag('mapframe', mw.text.jsonEncode(geojson), {
height = 240,
width = 240,
frameless = 'frameless',
align = 'center',
latitude = latitude,
longitude = longitude,
zoom = zoom
}))
end
-- Wikidata Link (Footer)
databoxRoot:tag('div')
:css({
['display'] = 'flex',
['align-items'] = 'center',
['justify-content'] = 'center',
padding = '0.3em 0',
['width'] = '100%',
['font-size'] = '90%',
['text-align'] = 'center',
})
:addClass('databox-from-wikidata-link')
:wikitext('[[File:Wikidata-logo.svg|22px|class=noviewer skin-invert|link=https://www.wikidata.org/wiki/' .. item.id .. ']]')
:tag('div')
:css({ margin = '0 0 0 0.3em' })
:wikitext('[[d:' .. item.id .. '|From Wikidata]]')
return tostring(databoxRoot)
end
return p
5bdvkd90hwgtbjtbzg8cl43ntkqlay9
ಟೆಂಪ್ಲೇಟು:Databox/doc
10
121072
325307
2026-07-26T16:19:52Z
w>A826
0
/* ಉದಾಹರಣೆಗಳು */
325307
wikitext
text/x-wiki
{{Documentation subpage|[[Template:Databox]]|override=doc}}
{{#ifeq:{{NAMESPACE}}|Template|{{Lua|Module:Databox}}}}
ಈ ಮಾಡ್ಯೂಲ್ ವಿಕಿಡೇಟಾ (Wikidata) ಆಧಾರಿತ ಅತ್ಯಂತ ಸರಳವಾದ ಇನ್ಫೋಬಾಕ್ಸ್ (infobox) ವ್ಯವಸ್ಥೆಯನ್ನು ಒದಗಿಸುತ್ತದೆ.
[[File:Wikidata Reuse Days 2022 - Databox.pdf|thumb|ವಿಕಿಡೇಟಾ ಮರುಬಳಕೆ ದಿನಗಳು 2022 ರಲ್ಲಿ ನೀಡಲಾದ ಡೇಟಾಬಾಕ್ಸ್ನ ಪರಿಚಯಾತ್ಮಕ ಪ್ರಸ್ತುತಿ]]
ಇದು ಸಂಪೂರ್ಣವಾಗಿ ಸ್ವಯಂಚಾಲಿತವಾಗಿದೆ, ಇದನ್ನು ಬಳಸಲು ಯಾವುದೇ ಸಂರಚನೆಯ ಅಗತ್ಯವಿಲ್ಲ ಮತ್ತು ಅಸ್ತಿತ್ವದ ಪ್ರಕಾರಕ್ಕೆ (ವ್ಯಕ್ತಿ, ಸ್ಥಳ...) ಅನುಗುಣವಾಗಿ ಯಾವುದೇ ಬದಲಾವಣೆಗಳನ್ನು ಹೊಂದುವುದಿಲ್ಲ.
== ಇದು ಹೇಗೆ ಕೆಲಸ ಮಾಡುತ್ತದೆ? ==
ಈ ಮಾಡ್ಯೂಲ್ [[Template:Databox|Databox template]] ನ ಬ್ಯಾಕೆಂಡ್ ಕೋಡ್ ಆಗಿದೆ.
ಇದು ಪ್ರಸ್ತುತ ಪುಟಕ್ಕೆ ಲಿಂಕ್ ಮಾಡಲಾದ ವಿಕಿಡೇಟಾ ಐಟಂ ಅಥವಾ 'item' ಪ್ಯಾರಾಮೀಟರ್ನಲ್ಲಿ ಭರ್ತಿ ಮಾಡಲಾದ ಐಟಂ ಐಡಿಯನ್ನು ಬಳಸಿಕೊಂಡು ಸ್ವಯಂಚಾಲಿತವಾಗಿ ಇನ್ಫೋಬಾಕ್ಸ್ ಅನ್ನು ನಿರ್ಮಿಸುತ್ತದೆ.
ಇದರ ಮೂಲ ಅಲ್ಗಾರಿದಮ್ ಹೀಗಿದೆ:
* ಇನ್ಫೋಬಾಕ್ಸ್ ಶೀರ್ಷಿಕೆಗಾಗಿ ಐಟಂನ ಲೇಬಲ್ ಅನ್ನು ಬಳಸಿ, ಅಥವಾ ಯಾವುದೂ ಇಲ್ಲದಿದ್ದರೆ, ಪುಟದ ಶೀರ್ಷಿಕೆಯನ್ನು ಬಳಸಿ.
* ಮುಖ್ಯ ಚಿತ್ರಕ್ಕಾಗಿ {{P|18}} ರ ಮೌಲ್ಯವನ್ನು ಬಳಸಿ.
* ಡೇಟಾ ಟೇಬಲ್ ಶೀರ್ಷಿಕೆಗಾಗಿ {{P|31}} ರ ಮೌಲ್ಯವನ್ನು ಬಳಸಿ.
* ಐಟಂ ಬಳಸುವ ಎಲ್ಲಾ ಪ್ರಾಪರ್ಟಿಗಳನ್ನು (Properties) ತೆಗೆದುಕೊಂಡು, ಅವುಗಳನ್ನು [[MediaWiki:Wikibase-SortedProperties]] ಪ್ರಕಾರ ವಿಂಗಡಿಸಿ, ಮತ್ತು ಪ್ರತಿಯೊಂದಕ್ಕೂ:
** ಪ್ರಾಪರ್ಟಿಯು {{datatype|external-id}}, {{datatype|commonsMedia}} ಅಥವಾ {{datatype|quantity}} ಡೇಟಾ ಪ್ರಕಾರವನ್ನು ಹೊಂದಿದ್ದರೆ, ಏನನ್ನೂ ಪ್ರದರ್ಶಿಸಬೇಡಿ.
** ಪ್ರಾಪರ್ಟಿಯು ಮಾಡ್ಯೂಲ್ನ 'site_excluded_properties' ಅರ್ರೇನಲ್ಲಿದ್ದರೆ, ಏನನ್ನೂ ಪ್ರದರ್ಶಿಸಬೇಡಿ (ಇನ್ಫೋಬಾಕ್ಸ್ಗಳಲ್ಲಿ ಪ್ರದರ್ಶಿಸಲು ಅಷ್ಟು ಪ್ರಸ್ತುತವಲ್ಲದ ಪ್ರಾಪರ್ಟಿಗಳನ್ನು ಫಿಲ್ಟರ್ ಮಾಡಲು ಇದನ್ನು ಮಾಡಲಾಗುತ್ತದೆ).
** ಪ್ರಾಪರ್ಟಿಯು 5 ಕ್ಕಿಂತ ಹೆಚ್ಚು ಮೌಲ್ಯಗಳನ್ನು ಹೊಂದಿದ್ದರೆ ಏನನ್ನೂ ಪ್ರದರ್ಶಿಸಬೇಡಿ (ಇನ್ಫೋಬಾಕ್ಸ್ನಲ್ಲಿ ದೀರ್ಘ ಪಟ್ಟಿಗಳನ್ನು ತಪ್ಪಿಸಲು).
** "ಅತ್ಯುತ್ತಮ" ಶ್ರೇಯಾಂಕವನ್ನು ಹೊಂದಿರುವ ಮೌಲ್ಯಗಳನ್ನು ಪ್ರದರ್ಶಿಸಲು ಡಿಫಾಲ್ಟ್ [[mw:Extension:Wikibase client|Wikibase]] ರೆಂಡರಿಂಗ್ ವ್ಯವಸ್ಥೆಯನ್ನು ಬಳಸಿ.
* {{P|625}} ಗೆ ಮೌಲ್ಯವಿದ್ದರೆ, [[mw:Help:Extension:Kartographer|Kartographer]] ಬಳಸಿ ನಕ್ಷೆಯನ್ನು ಪ್ರದರ್ಶಿಸಿ.
== ಅನುಸ್ಥಾಪನಾ ಸೂಚನೆಗಳು ==
'''ಮಾಡ್ಯೂಲ್ ಕೋಡ್ ಸೇರಿಸಿ'''
1. ಡೇಟಾಬಾಕ್ಸ್ ಮಾಡ್ಯೂಲ್ ಅನ್ನು ನಿಮ್ಮ ವಿಕಿಗೆ ಕಾಪಿ-ಪೇಸ್ಟ್ ಮಾಡಿ
* <code>[[d:Module:Databox#com-module-code|Module:Databox-Code]]</code> ಗೆ ಹೋಗಿ ಮತ್ತು ಕೋಡ್ ಬ್ಲಾಕ್ನಲ್ಲಿರುವ ಎಲ್ಲಾ ವಿಷಯಗಳನ್ನು ಕಾಪಿ ಮಾಡಿ.
* ಈ ವಿಷಯಗಳನ್ನು ನಿಮ್ಮ ಸ್ವಂತ ವಿಕಿಯ <code>Module:Databox</code> ಪುಟಕ್ಕೆ ಪೇಸ್ಟ್ ಮಾಡಿ (ಇನ್ನೂ ಇಲ್ಲದಿದ್ದರೆ, ಒಂದನ್ನು ರಚಿಸಿ).
2. ಹೊಸದಾಗಿ ರಚಿಸಲಾದ ಪುಟದ (Module:Databox) ಸೈಟ್ಲಿಂಕ್ ಅನ್ನು ವಿಕಿಡೇಟಾ ಐಟಂ <code>Module:Databox</code> ([[d:Q53931871|Q53931871]]) ಗೆ ಸೇರಿಸಿ.
'''ಟೆಂಪ್ಲೇಟ್ ಕೋಡ್ ಸೇರಿಸಿ'''
3. ಕೆಳಗಿನ ಟೆಂಪ್ಲೇಟ್ ಕೋಡ್ ಅನ್ನು ನಿಮ್ಮ ಸ್ವಂತ ವಿಕಿ <code>Template:Databox</code> ಪುಟಕ್ಕೆ ಕಾಪಿ-ಪೇಸ್ಟ್ ಮಾಡಿ.
{{#invoke:Databox|databox|useImage={{{useImage|}}}|excludeProperties={{{excludeProperties|}}}}}
4. ಹೊಸದಾಗಿ ರಚಿಸಲಾದ Template:Databox ಪುಟವನ್ನು ವಿಕಿಡೇಟಾ ಐಟಂ <code>Template:Databox</code> ([[d:Q20702632|Q20702632]]) ಗೆ ಸಂಪರ್ಕಿಸಿ.
5. ಟೆಂಪ್ಲೇಟ್ ಅನ್ನು ಪರೀಕ್ಷಿಸಿ
* ವಿಕಿಡೇಟಾ ಐಟಂಗೆ ಸಂಪರ್ಕಗೊಂಡಿರುವ ಲೇಖನವನ್ನು ಎಡಿಟ್ ಮಾಡಿ, ಉದಾಹರಣೆಗೆ ನಿಮ್ಮ ದೇಶದ ರಾಜಧಾನಿ ನಗರ.
* ಎಡಿಟ್ ಸೋರ್ಸ್ (edit source) ವೀಕ್ಷಣೆಗೆ ಹೋಗಿ ಮತ್ತು ಪುಟದ ಮೇಲ್ಭಾಗದಲ್ಲಿ <nowiki>{{Databox}}</nowiki> ಕೋಡ್ ಸೇರಿಸಿ.
* ಪುಟದಲ್ಲಿ ಡೇಟಾಬಾಕ್ಸ್ ಕಾಣಿಸಿಕೊಂಡಿದೆಯೇ ಎಂದು ಪರಿಶೀಲಿಸಲು ಮುನ್ನೋಟ (Preview) ನೋಡಿ, ತದನಂತರ ಬದಲಾವಣೆಗಳನ್ನು ಉಳಿಸಲು ಪ್ರಕಟಿಸಿ.
* ಅಭಿನಂದನೆಗಳು, ನೀವು ನಿಮ್ಮ ಮೊದಲ ಡೇಟಾಬಾಕ್ಸ್ ಅನ್ನು ಸ್ಥಾಪಿಸಿದ್ದೀರಿ!
== ಡೇಟಾಬಾಕ್ಸ್ ಡೇಟಾವನ್ನು ಎಡಿಟ್ ಮಾಡಿ ==
ಕೆಲವೊಮ್ಮೆ ಡೇಟಾ ತಪ್ಪಾಗಿರಬಹುದು ಅಥವಾ ಹಳೆಯದಾಗಿರಬಹುದು ಮತ್ತು ಅದನ್ನು ಬದಲಾಯಿಸುವ ಅಥವಾ ನವೀಕರಿಸುವ ಅಗತ್ಯವಿರುತ್ತದೆ, ಆದರೆ ನೀವು ಅದನ್ನು ಪ್ರಸ್ತುತ ಪುಟದಿಂದ ಮಾಡಲು ಸಾಧ್ಯವಿಲ್ಲ. ಡೇಟಾಬಾಕ್ಸ್ನಲ್ಲಿ ಕಂಡುಬರುವ ಡೇಟಾವನ್ನು ಸ್ಥಳೀಯವಾಗಿ ಸಂಗ್ರಹಿಸಲಾಗಿರುವುದಿಲ್ಲ, ಇದನ್ನು [[d:|Wikidata]] ನಿಂದ ಪಡೆಯಲಾಗುತ್ತದೆ.
'''ಡೇಟಾಬಾಕ್ಸ್ನಲ್ಲಿ ತೋರಿಸಲಾದ ಡೇಟಾವನ್ನು ಬದಲಾಯಿಸಲು ಅಥವಾ ಎಡಿಟ್ ಮಾಡಲು:'''
1. ಡೇಟಾಬಾಕ್ಸ್ನಲ್ಲಿರುವ ಹೇಳಿಕೆಯ (statement) ಪಕ್ಕದಲ್ಲಿರುವ ಪೆನ್ಸಿಲ್ ಐಕಾನ್ [[File:OOjs UI icon edit-ltr-gray.svg|20px]] ಮೇಲೆ ಕ್ಲಿಕ್ ಮಾಡಿ.
2. ಇದು ನಿಮ್ಮನ್ನು ವಿಕಿಡೇಟಾ ಐಟಂನಲ್ಲಿ ಆ ಹೇಳಿಕೆಯನ್ನು ಎಲ್ಲಿ ಸಂಗ್ರಹಿಸಲಾಗಿದೆ ಎಂಬುದಕ್ಕೆ ಕರೆದೊಯ್ಯುತ್ತದೆ.
3. ಸ್ಟೇಟ್ಮೆಂಟ್ ಬಾಕ್ಸ್ನ ಬದಿಯಲ್ಲಿರುವ ಪೆನ್ಸಿಲ್ ಐಕಾನ್ ಮೇಲೆ ಮತ್ತೆ ಕ್ಲಿಕ್ ಮಾಡಿ. ಇದು ವಿಕಿಡೇಟಾದಲ್ಲಿ ಎಡಿಟ್ ಮೋಡ್ ಅನ್ನು ತೆರೆಯುತ್ತದೆ.
* ಇನ್ಪುಟ್ ಫೀಲ್ಡ್ನಲ್ಲಿ ಹೊಸ ಮೌಲ್ಯವನ್ನು ನಮೂದಿಸಿ. ಅಗತ್ಯವಿದ್ದಲ್ಲಿ ಕ್ವಾಲಿಫೈಯರ್ ಅಥವಾ ಉಲ್ಲೇಖಗಳನ್ನು ಸೇರಿಸಿ.
* ಮೌಲ್ಯವು ಹಳೆಯದಾಗಿದ್ದರೂ ಇನ್ನೂ ಸರಿಯಾಗಿದ್ದರೆ (ಜನಗಣತಿ ಡೇಟಾದಂತೆ), ಪೆನ್ಸಿಲ್ ಐಕಾನ್ ಬದಲಿಗೆ ಅದರ ಬಲಭಾಗದಲ್ಲಿರುವ '+' ಐಕಾನ್ ಕ್ಲಿಕ್ ಮಾಡಿ ಮತ್ತು ಹೊಸ ಮೌಲ್ಯವನ್ನು ನಮೂದಿಸಿ.
4. ಹೇಳಿಕೆಯನ್ನು ಪ್ರಕಟಿಸಲು ಚೆಕ್ಮಾರ್ಕ್ [[File:Ic check 36px.svg|20px]] ಬಟನ್ ಕ್ಲಿಕ್ ಮಾಡಿ. ಡೇಟಾಬಾಕ್ಸ್ ತಕ್ಷಣವೇ ನವೀಕರಣಗೊಳ್ಳುತ್ತದೆ ಮತ್ತು ಹೊಸ ಮಾಹಿತಿ ಕಾಣಿಸಿಕೊಳ್ಳುತ್ತದೆ.
=== ಟಿಪ್ಪಣಿಗಳು ===
<references group=a/>
== ಉದಾಹರಣೆಗಳು ==
{{{!}} class="wikitable"
{{!}} {{Databox|item=Q10725594}} {{Databox|item=Q13365715}}
{{!}} {{Databox|item=Q153}}
{{!}} {{Databox|item=Q2513}}
{{!}} {{Databox|item=Q3030}}
{{!}} {{Databox|item=Q7066}}
{{!-}}
{{!}} {{Databox|item=Q192724}}
{{!}} {{Databox|item=Q67}}
{{!}} {{Databox|item=Q143}}
{{!}} {{Databox|item=Q64}}
{{!}} {{Databox|item=Q42}}
{{!}}}
<templatedata>
{
"params": {
"from": {
"description": "ಪುಟಕ್ಕೆ ಲಿಂಕ್ ಮಾಡಲಾದ ವಿಕಿಡೇಟಾ ಐಟಂ ಬದಲಿಗೆ ನಿರ್ದಿಷ್ಟ ವಿಕಿಡೇಟಾ ಐಟಂನಿಂದ (Q123) ಡೇಟಾವನ್ನು ಹಿಂಪಡೆಯಲು ಡೇಟಾಬಾಕ್ಸ್ ಅನ್ನು ಒತ್ತಾಯಿಸುತ್ತದೆ.",
"type": "string"
},
"useImage": {
"description": "ವಿಕಿಡೇಟಾ ಎಂಟಿಟಿಯಿಂದ ಬಳಸಲು ಆದ್ಯತೆಯ ಚಿತ್ರದ ಫೈಲ್ ಹೆಸರು",
"type": "string"
},
"excludeProperties": {
"description": "ಡೇಟಾಬಾಕ್ಸ್ನಿಂದ ತೆಗೆದುಹಾಕಬೇಕಾದ ವಿಕಿಡೇಟಾ ಪ್ರಾಪರ್ಟಿ ಐಡಿಗಳ ಕಾಮಾ ಬೇರ್ಪಡಿಸಿದ ಪಟ್ಟಿ",
"type": "string"
}
}
}
</templatedata>
=== ವಿಕಿಟೆಕ್ಸ್ಟ್ ಡೇಟಾಬಾಕ್ಸ್ ಉದಾಹರಣೆಗಳು ===
ಕೆಳಗಿನ ಉದಾಹರಣೆಗಳು ಎಡಿಟ್ ಸೋರ್ಸ್ ವೀಕ್ಷಣೆಯಲ್ಲಿ ಡೇಟಾಬಾಕ್ಸ್ ಟೆಂಪ್ಲೇಟ್ ಹೇಗೆ ಕಾಣಿಸಬಹುದು ಎಂಬುದನ್ನು ತೋರಿಸುತ್ತವೆ.
* <code><nowiki>{{Databox}}</nowiki></code>
:ಡಿಫಾಲ್ಟ್ ಆಯ್ಕೆ. ಇದು ಪುಟಕ್ಕೆ ಸಂಪರ್ಕಗೊಂಡಿರುವ ವಿಕಿಡೇಟಾ ಐಟಂನಿಂದ ಡೇಟಾವನ್ನು ಹಿಂಪಡೆಯುತ್ತದೆ.
* <code><nowiki>{{Databox|from=Q123}}</nowiki></code>
:ನಿರ್ದಿಷ್ಟಪಡಿಸಿದ ವಿಕಿಡೇಟಾ ಐಟಂನಿಂದ ಡೇಟಾವನ್ನು ಪಡೆಯಲು ಡೇಟಾಬಾಕ್ಸ್ ಅನ್ನು ಒತ್ತಾಯಿಸುತ್ತದೆ.
* <code><nowiki>{{Databox|useImage=filename.jpg}}</nowiki></code>
:ಡೇಟಾಬಾಕ್ಸ್ನಲ್ಲಿ ಪ್ರದರ್ಶಿಸಲು ಇನ್ನೊಂದು ಚಿತ್ರವನ್ನು (P18) ಹಸ್ತಚಾಲಿತವಾಗಿ ನಿರ್ದಿಷ್ಟಪಡಿಸಿ.
* <code><nowiki>{{Databox|excludeProperties=P123}}</nowiki></code>
:ಪ್ರಸ್ತುತ ಡೇಟಾಬಾಕ್ಸ್ನಲ್ಲಿ ತೋರಿಸಬಾರದ ವಿಕಿಡೇಟಾ ಪ್ರಾಪರ್ಟಿಗಳ (PID ಗಳು) ಪಟ್ಟಿಯನ್ನು ನಿರ್ದಿಷ್ಟಪಡಿಸಿ.
* <code><nowiki>{{Databox|useImage=filename.jpg|excludeProperties=P123}}</nowiki></code>
:ಪ್ಯಾರಾಮೀಟರ್ಗಳನ್ನು ಸಂಯೋಜಿಸುವುದು ವಿಷಯದ ಮೇಲೆ ಹೆಚ್ಚಿನ ನಿಯಂತ್ರಣಕ್ಕೆ ಅನುವು ಮಾಡಿಕೊಡುತ್ತದೆ.
== ಇದನ್ನೂ ನೋಡಿ ==
* [[:ru:Template:Универсальная карточка]] - ರಷ್ಯನ್ ವಿಕಿಪೀಡಿಯಾದಲ್ಲಿರುವ ಇದೇ ರೀತಿಯ ಆದರೆ ಹೆಚ್ಚು ಅಭಿವೃದ್ಧಿ ಹೊಂದಿದ ಟೆಂಪ್ಲೇಟ್.
* [[:en:Template:Infobox person/Wikidata]] - ಇಂಗ್ಲಿಷ್ ವಿಕಿಪೀಡಿಯಾದಲ್ಲಿ ಕೇವಲ ವ್ಯಕ್ತಿಗಳಿಗಾಗಿ ಇರುವ ಇದೇ ರೀತಿಯ ಟೆಂಪ್ಲೇಟ್.
* [[:commons:Template:Wikidata Infobox]] - ಕಾಮನ್ಸ್ನ ಸಮಾನ ರೂಪ; ಹೆಚ್ಚಾಗಿ ವರ್ಗಗಳಿಗಾಗಿ (categories) ಬಳಸಲಾಗುತ್ತದೆ.
b4li9xe9cq98tcphm272v46pbz32wvv
325308
325307
2026-08-22T10:31:06Z
A826
6806
೧ revisions imported from [[:w:ಟೆಂಪ್ಲೇಟು:Databox/doc]]
325307
wikitext
text/x-wiki
{{Documentation subpage|[[Template:Databox]]|override=doc}}
{{#ifeq:{{NAMESPACE}}|Template|{{Lua|Module:Databox}}}}
ಈ ಮಾಡ್ಯೂಲ್ ವಿಕಿಡೇಟಾ (Wikidata) ಆಧಾರಿತ ಅತ್ಯಂತ ಸರಳವಾದ ಇನ್ಫೋಬಾಕ್ಸ್ (infobox) ವ್ಯವಸ್ಥೆಯನ್ನು ಒದಗಿಸುತ್ತದೆ.
[[File:Wikidata Reuse Days 2022 - Databox.pdf|thumb|ವಿಕಿಡೇಟಾ ಮರುಬಳಕೆ ದಿನಗಳು 2022 ರಲ್ಲಿ ನೀಡಲಾದ ಡೇಟಾಬಾಕ್ಸ್ನ ಪರಿಚಯಾತ್ಮಕ ಪ್ರಸ್ತುತಿ]]
ಇದು ಸಂಪೂರ್ಣವಾಗಿ ಸ್ವಯಂಚಾಲಿತವಾಗಿದೆ, ಇದನ್ನು ಬಳಸಲು ಯಾವುದೇ ಸಂರಚನೆಯ ಅಗತ್ಯವಿಲ್ಲ ಮತ್ತು ಅಸ್ತಿತ್ವದ ಪ್ರಕಾರಕ್ಕೆ (ವ್ಯಕ್ತಿ, ಸ್ಥಳ...) ಅನುಗುಣವಾಗಿ ಯಾವುದೇ ಬದಲಾವಣೆಗಳನ್ನು ಹೊಂದುವುದಿಲ್ಲ.
== ಇದು ಹೇಗೆ ಕೆಲಸ ಮಾಡುತ್ತದೆ? ==
ಈ ಮಾಡ್ಯೂಲ್ [[Template:Databox|Databox template]] ನ ಬ್ಯಾಕೆಂಡ್ ಕೋಡ್ ಆಗಿದೆ.
ಇದು ಪ್ರಸ್ತುತ ಪುಟಕ್ಕೆ ಲಿಂಕ್ ಮಾಡಲಾದ ವಿಕಿಡೇಟಾ ಐಟಂ ಅಥವಾ 'item' ಪ್ಯಾರಾಮೀಟರ್ನಲ್ಲಿ ಭರ್ತಿ ಮಾಡಲಾದ ಐಟಂ ಐಡಿಯನ್ನು ಬಳಸಿಕೊಂಡು ಸ್ವಯಂಚಾಲಿತವಾಗಿ ಇನ್ಫೋಬಾಕ್ಸ್ ಅನ್ನು ನಿರ್ಮಿಸುತ್ತದೆ.
ಇದರ ಮೂಲ ಅಲ್ಗಾರಿದಮ್ ಹೀಗಿದೆ:
* ಇನ್ಫೋಬಾಕ್ಸ್ ಶೀರ್ಷಿಕೆಗಾಗಿ ಐಟಂನ ಲೇಬಲ್ ಅನ್ನು ಬಳಸಿ, ಅಥವಾ ಯಾವುದೂ ಇಲ್ಲದಿದ್ದರೆ, ಪುಟದ ಶೀರ್ಷಿಕೆಯನ್ನು ಬಳಸಿ.
* ಮುಖ್ಯ ಚಿತ್ರಕ್ಕಾಗಿ {{P|18}} ರ ಮೌಲ್ಯವನ್ನು ಬಳಸಿ.
* ಡೇಟಾ ಟೇಬಲ್ ಶೀರ್ಷಿಕೆಗಾಗಿ {{P|31}} ರ ಮೌಲ್ಯವನ್ನು ಬಳಸಿ.
* ಐಟಂ ಬಳಸುವ ಎಲ್ಲಾ ಪ್ರಾಪರ್ಟಿಗಳನ್ನು (Properties) ತೆಗೆದುಕೊಂಡು, ಅವುಗಳನ್ನು [[MediaWiki:Wikibase-SortedProperties]] ಪ್ರಕಾರ ವಿಂಗಡಿಸಿ, ಮತ್ತು ಪ್ರತಿಯೊಂದಕ್ಕೂ:
** ಪ್ರಾಪರ್ಟಿಯು {{datatype|external-id}}, {{datatype|commonsMedia}} ಅಥವಾ {{datatype|quantity}} ಡೇಟಾ ಪ್ರಕಾರವನ್ನು ಹೊಂದಿದ್ದರೆ, ಏನನ್ನೂ ಪ್ರದರ್ಶಿಸಬೇಡಿ.
** ಪ್ರಾಪರ್ಟಿಯು ಮಾಡ್ಯೂಲ್ನ 'site_excluded_properties' ಅರ್ರೇನಲ್ಲಿದ್ದರೆ, ಏನನ್ನೂ ಪ್ರದರ್ಶಿಸಬೇಡಿ (ಇನ್ಫೋಬಾಕ್ಸ್ಗಳಲ್ಲಿ ಪ್ರದರ್ಶಿಸಲು ಅಷ್ಟು ಪ್ರಸ್ತುತವಲ್ಲದ ಪ್ರಾಪರ್ಟಿಗಳನ್ನು ಫಿಲ್ಟರ್ ಮಾಡಲು ಇದನ್ನು ಮಾಡಲಾಗುತ್ತದೆ).
** ಪ್ರಾಪರ್ಟಿಯು 5 ಕ್ಕಿಂತ ಹೆಚ್ಚು ಮೌಲ್ಯಗಳನ್ನು ಹೊಂದಿದ್ದರೆ ಏನನ್ನೂ ಪ್ರದರ್ಶಿಸಬೇಡಿ (ಇನ್ಫೋಬಾಕ್ಸ್ನಲ್ಲಿ ದೀರ್ಘ ಪಟ್ಟಿಗಳನ್ನು ತಪ್ಪಿಸಲು).
** "ಅತ್ಯುತ್ತಮ" ಶ್ರೇಯಾಂಕವನ್ನು ಹೊಂದಿರುವ ಮೌಲ್ಯಗಳನ್ನು ಪ್ರದರ್ಶಿಸಲು ಡಿಫಾಲ್ಟ್ [[mw:Extension:Wikibase client|Wikibase]] ರೆಂಡರಿಂಗ್ ವ್ಯವಸ್ಥೆಯನ್ನು ಬಳಸಿ.
* {{P|625}} ಗೆ ಮೌಲ್ಯವಿದ್ದರೆ, [[mw:Help:Extension:Kartographer|Kartographer]] ಬಳಸಿ ನಕ್ಷೆಯನ್ನು ಪ್ರದರ್ಶಿಸಿ.
== ಅನುಸ್ಥಾಪನಾ ಸೂಚನೆಗಳು ==
'''ಮಾಡ್ಯೂಲ್ ಕೋಡ್ ಸೇರಿಸಿ'''
1. ಡೇಟಾಬಾಕ್ಸ್ ಮಾಡ್ಯೂಲ್ ಅನ್ನು ನಿಮ್ಮ ವಿಕಿಗೆ ಕಾಪಿ-ಪೇಸ್ಟ್ ಮಾಡಿ
* <code>[[d:Module:Databox#com-module-code|Module:Databox-Code]]</code> ಗೆ ಹೋಗಿ ಮತ್ತು ಕೋಡ್ ಬ್ಲಾಕ್ನಲ್ಲಿರುವ ಎಲ್ಲಾ ವಿಷಯಗಳನ್ನು ಕಾಪಿ ಮಾಡಿ.
* ಈ ವಿಷಯಗಳನ್ನು ನಿಮ್ಮ ಸ್ವಂತ ವಿಕಿಯ <code>Module:Databox</code> ಪುಟಕ್ಕೆ ಪೇಸ್ಟ್ ಮಾಡಿ (ಇನ್ನೂ ಇಲ್ಲದಿದ್ದರೆ, ಒಂದನ್ನು ರಚಿಸಿ).
2. ಹೊಸದಾಗಿ ರಚಿಸಲಾದ ಪುಟದ (Module:Databox) ಸೈಟ್ಲಿಂಕ್ ಅನ್ನು ವಿಕಿಡೇಟಾ ಐಟಂ <code>Module:Databox</code> ([[d:Q53931871|Q53931871]]) ಗೆ ಸೇರಿಸಿ.
'''ಟೆಂಪ್ಲೇಟ್ ಕೋಡ್ ಸೇರಿಸಿ'''
3. ಕೆಳಗಿನ ಟೆಂಪ್ಲೇಟ್ ಕೋಡ್ ಅನ್ನು ನಿಮ್ಮ ಸ್ವಂತ ವಿಕಿ <code>Template:Databox</code> ಪುಟಕ್ಕೆ ಕಾಪಿ-ಪೇಸ್ಟ್ ಮಾಡಿ.
{{#invoke:Databox|databox|useImage={{{useImage|}}}|excludeProperties={{{excludeProperties|}}}}}
4. ಹೊಸದಾಗಿ ರಚಿಸಲಾದ Template:Databox ಪುಟವನ್ನು ವಿಕಿಡೇಟಾ ಐಟಂ <code>Template:Databox</code> ([[d:Q20702632|Q20702632]]) ಗೆ ಸಂಪರ್ಕಿಸಿ.
5. ಟೆಂಪ್ಲೇಟ್ ಅನ್ನು ಪರೀಕ್ಷಿಸಿ
* ವಿಕಿಡೇಟಾ ಐಟಂಗೆ ಸಂಪರ್ಕಗೊಂಡಿರುವ ಲೇಖನವನ್ನು ಎಡಿಟ್ ಮಾಡಿ, ಉದಾಹರಣೆಗೆ ನಿಮ್ಮ ದೇಶದ ರಾಜಧಾನಿ ನಗರ.
* ಎಡಿಟ್ ಸೋರ್ಸ್ (edit source) ವೀಕ್ಷಣೆಗೆ ಹೋಗಿ ಮತ್ತು ಪುಟದ ಮೇಲ್ಭಾಗದಲ್ಲಿ <nowiki>{{Databox}}</nowiki> ಕೋಡ್ ಸೇರಿಸಿ.
* ಪುಟದಲ್ಲಿ ಡೇಟಾಬಾಕ್ಸ್ ಕಾಣಿಸಿಕೊಂಡಿದೆಯೇ ಎಂದು ಪರಿಶೀಲಿಸಲು ಮುನ್ನೋಟ (Preview) ನೋಡಿ, ತದನಂತರ ಬದಲಾವಣೆಗಳನ್ನು ಉಳಿಸಲು ಪ್ರಕಟಿಸಿ.
* ಅಭಿನಂದನೆಗಳು, ನೀವು ನಿಮ್ಮ ಮೊದಲ ಡೇಟಾಬಾಕ್ಸ್ ಅನ್ನು ಸ್ಥಾಪಿಸಿದ್ದೀರಿ!
== ಡೇಟಾಬಾಕ್ಸ್ ಡೇಟಾವನ್ನು ಎಡಿಟ್ ಮಾಡಿ ==
ಕೆಲವೊಮ್ಮೆ ಡೇಟಾ ತಪ್ಪಾಗಿರಬಹುದು ಅಥವಾ ಹಳೆಯದಾಗಿರಬಹುದು ಮತ್ತು ಅದನ್ನು ಬದಲಾಯಿಸುವ ಅಥವಾ ನವೀಕರಿಸುವ ಅಗತ್ಯವಿರುತ್ತದೆ, ಆದರೆ ನೀವು ಅದನ್ನು ಪ್ರಸ್ತುತ ಪುಟದಿಂದ ಮಾಡಲು ಸಾಧ್ಯವಿಲ್ಲ. ಡೇಟಾಬಾಕ್ಸ್ನಲ್ಲಿ ಕಂಡುಬರುವ ಡೇಟಾವನ್ನು ಸ್ಥಳೀಯವಾಗಿ ಸಂಗ್ರಹಿಸಲಾಗಿರುವುದಿಲ್ಲ, ಇದನ್ನು [[d:|Wikidata]] ನಿಂದ ಪಡೆಯಲಾಗುತ್ತದೆ.
'''ಡೇಟಾಬಾಕ್ಸ್ನಲ್ಲಿ ತೋರಿಸಲಾದ ಡೇಟಾವನ್ನು ಬದಲಾಯಿಸಲು ಅಥವಾ ಎಡಿಟ್ ಮಾಡಲು:'''
1. ಡೇಟಾಬಾಕ್ಸ್ನಲ್ಲಿರುವ ಹೇಳಿಕೆಯ (statement) ಪಕ್ಕದಲ್ಲಿರುವ ಪೆನ್ಸಿಲ್ ಐಕಾನ್ [[File:OOjs UI icon edit-ltr-gray.svg|20px]] ಮೇಲೆ ಕ್ಲಿಕ್ ಮಾಡಿ.
2. ಇದು ನಿಮ್ಮನ್ನು ವಿಕಿಡೇಟಾ ಐಟಂನಲ್ಲಿ ಆ ಹೇಳಿಕೆಯನ್ನು ಎಲ್ಲಿ ಸಂಗ್ರಹಿಸಲಾಗಿದೆ ಎಂಬುದಕ್ಕೆ ಕರೆದೊಯ್ಯುತ್ತದೆ.
3. ಸ್ಟೇಟ್ಮೆಂಟ್ ಬಾಕ್ಸ್ನ ಬದಿಯಲ್ಲಿರುವ ಪೆನ್ಸಿಲ್ ಐಕಾನ್ ಮೇಲೆ ಮತ್ತೆ ಕ್ಲಿಕ್ ಮಾಡಿ. ಇದು ವಿಕಿಡೇಟಾದಲ್ಲಿ ಎಡಿಟ್ ಮೋಡ್ ಅನ್ನು ತೆರೆಯುತ್ತದೆ.
* ಇನ್ಪುಟ್ ಫೀಲ್ಡ್ನಲ್ಲಿ ಹೊಸ ಮೌಲ್ಯವನ್ನು ನಮೂದಿಸಿ. ಅಗತ್ಯವಿದ್ದಲ್ಲಿ ಕ್ವಾಲಿಫೈಯರ್ ಅಥವಾ ಉಲ್ಲೇಖಗಳನ್ನು ಸೇರಿಸಿ.
* ಮೌಲ್ಯವು ಹಳೆಯದಾಗಿದ್ದರೂ ಇನ್ನೂ ಸರಿಯಾಗಿದ್ದರೆ (ಜನಗಣತಿ ಡೇಟಾದಂತೆ), ಪೆನ್ಸಿಲ್ ಐಕಾನ್ ಬದಲಿಗೆ ಅದರ ಬಲಭಾಗದಲ್ಲಿರುವ '+' ಐಕಾನ್ ಕ್ಲಿಕ್ ಮಾಡಿ ಮತ್ತು ಹೊಸ ಮೌಲ್ಯವನ್ನು ನಮೂದಿಸಿ.
4. ಹೇಳಿಕೆಯನ್ನು ಪ್ರಕಟಿಸಲು ಚೆಕ್ಮಾರ್ಕ್ [[File:Ic check 36px.svg|20px]] ಬಟನ್ ಕ್ಲಿಕ್ ಮಾಡಿ. ಡೇಟಾಬಾಕ್ಸ್ ತಕ್ಷಣವೇ ನವೀಕರಣಗೊಳ್ಳುತ್ತದೆ ಮತ್ತು ಹೊಸ ಮಾಹಿತಿ ಕಾಣಿಸಿಕೊಳ್ಳುತ್ತದೆ.
=== ಟಿಪ್ಪಣಿಗಳು ===
<references group=a/>
== ಉದಾಹರಣೆಗಳು ==
{{{!}} class="wikitable"
{{!}} {{Databox|item=Q10725594}} {{Databox|item=Q13365715}}
{{!}} {{Databox|item=Q153}}
{{!}} {{Databox|item=Q2513}}
{{!}} {{Databox|item=Q3030}}
{{!}} {{Databox|item=Q7066}}
{{!-}}
{{!}} {{Databox|item=Q192724}}
{{!}} {{Databox|item=Q67}}
{{!}} {{Databox|item=Q143}}
{{!}} {{Databox|item=Q64}}
{{!}} {{Databox|item=Q42}}
{{!}}}
<templatedata>
{
"params": {
"from": {
"description": "ಪುಟಕ್ಕೆ ಲಿಂಕ್ ಮಾಡಲಾದ ವಿಕಿಡೇಟಾ ಐಟಂ ಬದಲಿಗೆ ನಿರ್ದಿಷ್ಟ ವಿಕಿಡೇಟಾ ಐಟಂನಿಂದ (Q123) ಡೇಟಾವನ್ನು ಹಿಂಪಡೆಯಲು ಡೇಟಾಬಾಕ್ಸ್ ಅನ್ನು ಒತ್ತಾಯಿಸುತ್ತದೆ.",
"type": "string"
},
"useImage": {
"description": "ವಿಕಿಡೇಟಾ ಎಂಟಿಟಿಯಿಂದ ಬಳಸಲು ಆದ್ಯತೆಯ ಚಿತ್ರದ ಫೈಲ್ ಹೆಸರು",
"type": "string"
},
"excludeProperties": {
"description": "ಡೇಟಾಬಾಕ್ಸ್ನಿಂದ ತೆಗೆದುಹಾಕಬೇಕಾದ ವಿಕಿಡೇಟಾ ಪ್ರಾಪರ್ಟಿ ಐಡಿಗಳ ಕಾಮಾ ಬೇರ್ಪಡಿಸಿದ ಪಟ್ಟಿ",
"type": "string"
}
}
}
</templatedata>
=== ವಿಕಿಟೆಕ್ಸ್ಟ್ ಡೇಟಾಬಾಕ್ಸ್ ಉದಾಹರಣೆಗಳು ===
ಕೆಳಗಿನ ಉದಾಹರಣೆಗಳು ಎಡಿಟ್ ಸೋರ್ಸ್ ವೀಕ್ಷಣೆಯಲ್ಲಿ ಡೇಟಾಬಾಕ್ಸ್ ಟೆಂಪ್ಲೇಟ್ ಹೇಗೆ ಕಾಣಿಸಬಹುದು ಎಂಬುದನ್ನು ತೋರಿಸುತ್ತವೆ.
* <code><nowiki>{{Databox}}</nowiki></code>
:ಡಿಫಾಲ್ಟ್ ಆಯ್ಕೆ. ಇದು ಪುಟಕ್ಕೆ ಸಂಪರ್ಕಗೊಂಡಿರುವ ವಿಕಿಡೇಟಾ ಐಟಂನಿಂದ ಡೇಟಾವನ್ನು ಹಿಂಪಡೆಯುತ್ತದೆ.
* <code><nowiki>{{Databox|from=Q123}}</nowiki></code>
:ನಿರ್ದಿಷ್ಟಪಡಿಸಿದ ವಿಕಿಡೇಟಾ ಐಟಂನಿಂದ ಡೇಟಾವನ್ನು ಪಡೆಯಲು ಡೇಟಾಬಾಕ್ಸ್ ಅನ್ನು ಒತ್ತಾಯಿಸುತ್ತದೆ.
* <code><nowiki>{{Databox|useImage=filename.jpg}}</nowiki></code>
:ಡೇಟಾಬಾಕ್ಸ್ನಲ್ಲಿ ಪ್ರದರ್ಶಿಸಲು ಇನ್ನೊಂದು ಚಿತ್ರವನ್ನು (P18) ಹಸ್ತಚಾಲಿತವಾಗಿ ನಿರ್ದಿಷ್ಟಪಡಿಸಿ.
* <code><nowiki>{{Databox|excludeProperties=P123}}</nowiki></code>
:ಪ್ರಸ್ತುತ ಡೇಟಾಬಾಕ್ಸ್ನಲ್ಲಿ ತೋರಿಸಬಾರದ ವಿಕಿಡೇಟಾ ಪ್ರಾಪರ್ಟಿಗಳ (PID ಗಳು) ಪಟ್ಟಿಯನ್ನು ನಿರ್ದಿಷ್ಟಪಡಿಸಿ.
* <code><nowiki>{{Databox|useImage=filename.jpg|excludeProperties=P123}}</nowiki></code>
:ಪ್ಯಾರಾಮೀಟರ್ಗಳನ್ನು ಸಂಯೋಜಿಸುವುದು ವಿಷಯದ ಮೇಲೆ ಹೆಚ್ಚಿನ ನಿಯಂತ್ರಣಕ್ಕೆ ಅನುವು ಮಾಡಿಕೊಡುತ್ತದೆ.
== ಇದನ್ನೂ ನೋಡಿ ==
* [[:ru:Template:Универсальная карточка]] - ರಷ್ಯನ್ ವಿಕಿಪೀಡಿಯಾದಲ್ಲಿರುವ ಇದೇ ರೀತಿಯ ಆದರೆ ಹೆಚ್ಚು ಅಭಿವೃದ್ಧಿ ಹೊಂದಿದ ಟೆಂಪ್ಲೇಟ್.
* [[:en:Template:Infobox person/Wikidata]] - ಇಂಗ್ಲಿಷ್ ವಿಕಿಪೀಡಿಯಾದಲ್ಲಿ ಕೇವಲ ವ್ಯಕ್ತಿಗಳಿಗಾಗಿ ಇರುವ ಇದೇ ರೀತಿಯ ಟೆಂಪ್ಲೇಟ್.
* [[:commons:Template:Wikidata Infobox]] - ಕಾಮನ್ಸ್ನ ಸಮಾನ ರೂಪ; ಹೆಚ್ಚಾಗಿ ವರ್ಗಗಳಿಗಾಗಿ (categories) ಬಳಸಲಾಗುತ್ತದೆ.
b4li9xe9cq98tcphm272v46pbz32wvv
ಟೆಂಪ್ಲೇಟು:Wikidata
10
121073
325321
2019-11-12T11:26:02Z
w>Renamed user ijklofjfoifvonofqmoilk
0
೧೭ revisions imported from [[:en:Template:Wikidata]]
325321
wikitext
text/x-wiki
<includeonly>{{safesubst:#invoke:Wd|main}}</includeonly><noinclude>
{{Documentation}}
</noinclude>
aqnmh4azo4jle51xny4knl3b1hl9873
325322
325321
2026-08-22T10:31:20Z
A826
6806
೧ revisions imported from [[:w:ಟೆಂಪ್ಲೇಟು:Wikidata]]
325321
wikitext
text/x-wiki
<includeonly>{{safesubst:#invoke:Wd|main}}</includeonly><noinclude>
{{Documentation}}
</noinclude>
aqnmh4azo4jle51xny4knl3b1hl9873
ಮಾಡ್ಯೂಲ್:Text/data
828
121074
325331
2026-02-10T16:49:18Z
w>A826
0
೧ ಬದಲಾವಣೆ
325331
Scribunto
text/plain
-- Data required by [[Module:Text]].
-- Either Lua string patterns (defined by codepoint) or information about quotes
local data = {}
local LEFT_SQUARE_BRACKET = 91
local RIGHT_SQUARE_BRACKET = 93
local HYPHEN = 45
data.PatternCJK = mw.ustring.char( LEFT_SQUARE_BRACKET,
4352, HYPHEN, 4607,
11904, HYPHEN, 42191,
43072, HYPHEN, 43135,
44032, HYPHEN, 55215,
63744, HYPHEN, 64255,
65072, HYPHEN, 65103,
65381, HYPHEN, 65500,
131072, HYPHEN, 196607,
RIGHT_SQUARE_BRACKET )
data.PatternCombined = mw.ustring.char( LEFT_SQUARE_BRACKET,
0x0300, HYPHEN, 0x036F,
0x1AB0, HYPHEN, 0x1AFF,
0x1DC0, HYPHEN, 0x1DFF,
0xFE20, HYPHEN, 0xFE2F,
RIGHT_SQUARE_BRACKET )
local RangesLatin = { { 7, 687 },
{ 7531, 7578 },
{ 7680, 7935 },
{ 8194, 8250 } }
local PatternLatin = "^["
for i = 1, #RangesLatin do
local range = RangesLatin[ i ]
PatternLatin = PatternLatin .. mw.ustring.char( range[ 1 ], HYPHEN, range[ 2 ] )
end
PatternLatin = PatternLatin .. "]*$"
data.RangesLatin = RangesLatin
data.NumLatinRanges = #RangesLatin
data.PatternLatin = PatternLatin
data.PatternTerminated = mw.ustring.char( LEFT_SQUARE_BRACKET,
12290,
65281,
65294,
65311 )
.. "!%.%?…][\"'%]‹›«»‘’“”]*$"
data.QuoteLang = { af = "bd",
ar = "la",
be = "labd",
bg = "bd",
ca = "la",
cs = "bd",
da = "bd",
de = "bd",
dsb = "bd",
et = "bd",
el = "lald",
en = "ld",
es = "la",
eu = "la",
-- fa = "la",
fi = "rd",
fr = "laSPC",
ga = "ld",
he = "ldla",
hr = "bd",
hsb = "bd",
hu = "bd",
hy = "labd",
id = "rd",
is = "bd",
it = "ld",
ja = "x300C",
ka = "bd",
ko = "ld",
lt = "bd",
lv = "bd",
nl = "ld",
nn = "la",
no = "la",
pl = "bdla",
pt = "lald",
ro = "bdla",
ru = "labd",
sk = "bd",
sl = "bd",
sq = "la",
sr = "bx",
sv = "rd",
th = "ld",
tr = "ld",
uk = "la",
zh = "ld",
["de-ch"] = "la",
["en-gb"] = "lsld",
["en-us"] = "ld",
["fr-ch"] = "la",
["it-ch"] = "la",
["pt-br"] = "ldla",
["zh-tw"] = "x300C",
["zh-cn"] = "ld" }
data.QuoteType = { bd = { { 8222, 8220 }, { 8218, 8217 } },
bdla = { { 8222, 8220 }, { 171, 187 } },
bx = { { 8222, 8221 }, { 8218, 8217 } },
la = { { 171, 187 }, { 8249, 8250 } },
laSPC = { { 171, 187 }, { 8249, 8250 }, true },
labd = { { 171, 187 }, { 8222, 8220 } },
lald = { { 171, 187 }, { 8220, 8221 } },
ld = { { 8220, 8221 }, { 8216, 8217 } },
ldla = { { 8220, 8221 }, { 171, 187 } },
lsld = { { 8216, 8217 }, { 8220, 8221 } },
rd = { { 8221, 8221 }, { 8217, 8217 } },
x300C = { { 0x300C, 0x300D },
{ 0x300E, 0x300F } } }
data.SeekQuote = mw.ustring.char( 34, -- "
39, -- '
171, -- laquo
187, -- raquo
8216, -- lsquo
8217, -- rsquo
8218, -- sbquo
8220, -- ldquo
8221, -- rdquo
8222, -- bdquo
8249, -- lsaquo
8250, -- rsaquo
0x300C, -- CJK
0x300D, -- CJK
0x300E, -- CJK
0x300F ) -- CJK
return data
32zfplthqqurpuluwxl965oirtoogiz
325332
325331
2026-08-22T10:31:21Z
A826
6806
೧ revisions imported from [[:w:ಮಾಡ್ಯೂಲ್:Text/data]]
325331
Scribunto
text/plain
-- Data required by [[Module:Text]].
-- Either Lua string patterns (defined by codepoint) or information about quotes
local data = {}
local LEFT_SQUARE_BRACKET = 91
local RIGHT_SQUARE_BRACKET = 93
local HYPHEN = 45
data.PatternCJK = mw.ustring.char( LEFT_SQUARE_BRACKET,
4352, HYPHEN, 4607,
11904, HYPHEN, 42191,
43072, HYPHEN, 43135,
44032, HYPHEN, 55215,
63744, HYPHEN, 64255,
65072, HYPHEN, 65103,
65381, HYPHEN, 65500,
131072, HYPHEN, 196607,
RIGHT_SQUARE_BRACKET )
data.PatternCombined = mw.ustring.char( LEFT_SQUARE_BRACKET,
0x0300, HYPHEN, 0x036F,
0x1AB0, HYPHEN, 0x1AFF,
0x1DC0, HYPHEN, 0x1DFF,
0xFE20, HYPHEN, 0xFE2F,
RIGHT_SQUARE_BRACKET )
local RangesLatin = { { 7, 687 },
{ 7531, 7578 },
{ 7680, 7935 },
{ 8194, 8250 } }
local PatternLatin = "^["
for i = 1, #RangesLatin do
local range = RangesLatin[ i ]
PatternLatin = PatternLatin .. mw.ustring.char( range[ 1 ], HYPHEN, range[ 2 ] )
end
PatternLatin = PatternLatin .. "]*$"
data.RangesLatin = RangesLatin
data.NumLatinRanges = #RangesLatin
data.PatternLatin = PatternLatin
data.PatternTerminated = mw.ustring.char( LEFT_SQUARE_BRACKET,
12290,
65281,
65294,
65311 )
.. "!%.%?…][\"'%]‹›«»‘’“”]*$"
data.QuoteLang = { af = "bd",
ar = "la",
be = "labd",
bg = "bd",
ca = "la",
cs = "bd",
da = "bd",
de = "bd",
dsb = "bd",
et = "bd",
el = "lald",
en = "ld",
es = "la",
eu = "la",
-- fa = "la",
fi = "rd",
fr = "laSPC",
ga = "ld",
he = "ldla",
hr = "bd",
hsb = "bd",
hu = "bd",
hy = "labd",
id = "rd",
is = "bd",
it = "ld",
ja = "x300C",
ka = "bd",
ko = "ld",
lt = "bd",
lv = "bd",
nl = "ld",
nn = "la",
no = "la",
pl = "bdla",
pt = "lald",
ro = "bdla",
ru = "labd",
sk = "bd",
sl = "bd",
sq = "la",
sr = "bx",
sv = "rd",
th = "ld",
tr = "ld",
uk = "la",
zh = "ld",
["de-ch"] = "la",
["en-gb"] = "lsld",
["en-us"] = "ld",
["fr-ch"] = "la",
["it-ch"] = "la",
["pt-br"] = "ldla",
["zh-tw"] = "x300C",
["zh-cn"] = "ld" }
data.QuoteType = { bd = { { 8222, 8220 }, { 8218, 8217 } },
bdla = { { 8222, 8220 }, { 171, 187 } },
bx = { { 8222, 8221 }, { 8218, 8217 } },
la = { { 171, 187 }, { 8249, 8250 } },
laSPC = { { 171, 187 }, { 8249, 8250 }, true },
labd = { { 171, 187 }, { 8222, 8220 } },
lald = { { 171, 187 }, { 8220, 8221 } },
ld = { { 8220, 8221 }, { 8216, 8217 } },
ldla = { { 8220, 8221 }, { 171, 187 } },
lsld = { { 8216, 8217 }, { 8220, 8221 } },
rd = { { 8221, 8221 }, { 8217, 8217 } },
x300C = { { 0x300C, 0x300D },
{ 0x300E, 0x300F } } }
data.SeekQuote = mw.ustring.char( 34, -- "
39, -- '
171, -- laquo
187, -- raquo
8216, -- lsquo
8217, -- rsquo
8218, -- sbquo
8220, -- ldquo
8221, -- rdquo
8222, -- bdquo
8249, -- lsaquo
8250, -- rsaquo
0x300C, -- CJK
0x300D, -- CJK
0x300E, -- CJK
0x300F ) -- CJK
return data
32zfplthqqurpuluwxl965oirtoogiz
ಮಾಡ್ಯೂಲ್:Datatype
828
121075
325333
2025-12-22T05:44:33Z
w>A826
0
೧ revisions imported from [[:d:Module:Datatype]]
325333
Scribunto
text/plain
local p = {}
local i18n = mw.loadData('Module:i18n/datatype')
function p.resolveDatatype(datatype)
return i18n.keys[string.lower(datatype)]
end
function p.display(datatype, lang)
if not datatype or datatype == '' then
return 'no datatype provided'
end
local fb = require 'Module:Fallback'
datatype = p.resolveDatatype(datatype) or datatype
local data = i18n[datatype]
if not data then
return datatype .. '-' .. fb._langSwitch(i18n.unrecognized, lang)
end
local text = mw.ustring.format('[[Special:MyLanguage/Help:Data_type#%s|%s]]',
datatype, fb._langSwitch(data, lang))
local trailingtext = ''
if data.planned then
local linguistic = require 'Module:Linguistic'
trailingtext = linguistic.inparentheses(fb._langSwitch(i18n.planned, lang), lang)
end
return text .. trailingtext
end
function p.showdatatype(frame)
local datatype = frame.args[1]
if not datatype or datatype == '' then
return nil
end
datatype = string.lower(datatype)
if string.sub(datatype, 1, 9) == 'property:' then
local pid = string.sub(datatype, 11)
datatype = mw.wikibase.getEntity('P' .. pid).datatype
end
local outputtype = frame.args[2]
if outputtype == 'raw' then
return datatype
elseif outputtype == 'abbr' then
if datatype == "wikibase-item" then datatype = "item"
elseif datatype == "wikibase-property" then datatype = "prop"
elseif datatype == "commonsMedia" then datatype = "commons"
elseif datatype == "external-id" then datatype = "ext-id"
end
return datatype
else
local lang = frame.args.lang or frame:callParserFunction('int', 'lang')
return p.display(datatype, lang)
end
end
return p
3il03gxpiir3gyc60sci1y7tzweh0ek
325334
325333
2026-08-22T10:31:21Z
A826
6806
೧ revisions imported from [[:w:ಮಾಡ್ಯೂಲ್:Datatype]]
325333
Scribunto
text/plain
local p = {}
local i18n = mw.loadData('Module:i18n/datatype')
function p.resolveDatatype(datatype)
return i18n.keys[string.lower(datatype)]
end
function p.display(datatype, lang)
if not datatype or datatype == '' then
return 'no datatype provided'
end
local fb = require 'Module:Fallback'
datatype = p.resolveDatatype(datatype) or datatype
local data = i18n[datatype]
if not data then
return datatype .. '-' .. fb._langSwitch(i18n.unrecognized, lang)
end
local text = mw.ustring.format('[[Special:MyLanguage/Help:Data_type#%s|%s]]',
datatype, fb._langSwitch(data, lang))
local trailingtext = ''
if data.planned then
local linguistic = require 'Module:Linguistic'
trailingtext = linguistic.inparentheses(fb._langSwitch(i18n.planned, lang), lang)
end
return text .. trailingtext
end
function p.showdatatype(frame)
local datatype = frame.args[1]
if not datatype or datatype == '' then
return nil
end
datatype = string.lower(datatype)
if string.sub(datatype, 1, 9) == 'property:' then
local pid = string.sub(datatype, 11)
datatype = mw.wikibase.getEntity('P' .. pid).datatype
end
local outputtype = frame.args[2]
if outputtype == 'raw' then
return datatype
elseif outputtype == 'abbr' then
if datatype == "wikibase-item" then datatype = "item"
elseif datatype == "wikibase-property" then datatype = "prop"
elseif datatype == "commonsMedia" then datatype = "commons"
elseif datatype == "external-id" then datatype = "ext-id"
end
return datatype
else
local lang = frame.args.lang or frame:callParserFunction('int', 'lang')
return p.display(datatype, lang)
end
end
return p
3il03gxpiir3gyc60sci1y7tzweh0ek
ಮಾಡ್ಯೂಲ್:I18n/datatype
828
121076
325335
2025-12-22T05:44:33Z
w>A826
0
೧ revisions imported from [[:d:Module:I18n/datatype]]
325335
Scribunto
text/plain
return {
-- typical entry structure:
-- message: the translatewiki message to use
-- planned: set to true to say that the datatype is not yet available
planned = {
ar = 'غير متوفر حالياً',
bg = 'все още недостъпен',
bn = 'এখনো উপলব্ধ নয়',
ca = 'encara no disponible',
cs = 'zatím nedostupný',
de = 'noch nicht verfügbar',
el = 'μη διαθέσιμο ακόμη',
en = 'not available yet',
eo = 'ankoraŭ ne disponebla',
es = 'disponible próximamente',
fr = 'pas encore disponible',
fy = 'noch net beskikber',
he = 'לא זמין עדיין',
hu = 'még nem elérhető',
it = 'non ancora disponibile',
ja = 'まだ利用できません',
ko = '아직 사용할 수 없음',
lt = 'dar nėra',
mk = 'сè уште недостапно',
nb = 'ikke tilgjengelig enda',
nl = 'nog niet beschikbaar',
nn = 'ikkje tilgjengeleg enno',
pa = 'ਹਾਲੀਆ ਨਹੀਂ ਲੱਭਦਾ ਏ',
pl = 'jeszcze nie dostępny',
pnb = 'حالیہ نہیں لبھدا اے',
pt = 'ainda não disponível',
['pt-br'] = 'ainda não disponível',
ru = 'ещё не доступен',
sl = 'ni še na voljo',
sr = 'још није доступно',
sv = 'inte tillgängligt ännu',
uk = 'ще не доступно',
ur = 'ابھی تک دستیاب نہیں',
vi = 'chưa có sẵn',
['zh-hans'] = '尚不可用',
['zh-hant'] = '尚不可用',
},
unrecognized = {
ar = 'نوع البيانات غير سليم وغير موجود في ( [[Module:i18n/datatype]])',
bg = 'невалиден тип на данните (няма в [[Module:i18n/datatype]])',
bn = 'অকার্যকর উপাত্তের ধরণ ([[Module:i18n/datatype]]-এ নেই)',
ca = 'tipus de dades invàlid (no disponible a [[Module:i18n/datatype]])',
cs = 'neplatný datový typ (není v [[Module:i18n/datatype]])',
de = 'unbekannter Datentyp (nicht in [[Module:i18n/datatype]])',
el = 'αδόκιμος τύπος δεδομένων (δεν υπάρχει στο [[Module:i18n/datatype]]',
en = 'invalid datatype (not in [[Module:i18n/datatype]])',
eo = 'malvalida datumtipo (ne en [[Module:i18n/datatype]])',
es = 'tipo de dato inválido (no disponible en [[Module:i18n/datatype]])',
fr = 'type de donnée invalide (non reconnu par [[Module:I18n/datatype]])',
fy = 'ûnjildich datatype (net yn [[Module:I18n/datatype]])',
he = 'סוג נתונים שגוי (לא תחת [[Module:I18n/datatype]])',
hu = 'hibás adattípus (nem szerepel a [[Module:i18n/datatype]] lapon)',
it = 'tipo di data non è presente tra quelli disponibili ([[Module:I18n/datatype]])',
ja = '不正なデータ型 ([[Module:I18n/datatype]]に無い)',
ko = '잘못된 데이터 종류입니다 ([[Module:i18n/datatype]]에 들어있지 않음)',
lt = 'neteisingas duomenų tipas (nėra [[Module:i18n/datatype]])',
mk = 'неважечки податочен тип (не е во [[Module:i18n/datatype]])',
nb = 'ugyldig datatype (finnes ikke i [[Module:I18n/datatype]])',
nl = 'ongeldig datatype (niet in [[Module:I18n/datatype]])',
nn = 'ugild datatype (ikkje i [[Module:i18n/datatype]])',
pl = 'niewłaściwy typ danych (nie w [[Module:I18n/datatype]])',
pt = 'tipo de dado inválido (não consta em [[Module:I18n/datatype]])',
['pt-br'] = 'tipo de dado inválido (não consta em [[Module:I18n/datatype]])',
ru = 'неизвестный тип данных (нет в [[Module:I18n/datatype]])',
sl = 'neveljaven podatkovni tip (ni v [[Module:i18n/datatype]])',
sr = 'врста податка није наведена. ([[Module:I18n/datatype]])',
sv = 'ogiltig datatyp (finns ej i [[Module:I18n/datatype]])',
uk = 'невідомий тип даних (відсутній в [[Module:I18n/datatype]])',
ur = 'غیر معتبر ڈیٹا ٹائپ (غیر موجود [[Module:i18n/datatype]])',
vi = 'kiểu dữ liệu không hợp lệ (không có trong [[Module:i18n/datatype]])',
['zh-hans'] = '无效的数据类型(未于[[Module:i18n/datatype]])',
['zh-hant'] = '無效的資料形態 (不存在於[[Module:i18n/datatype]])',
},
keys = { --table of redirects
commonsMedia = 'commonsMedia',
['entity-schema'] = 'entity-schema',
['external-id'] = 'external-id',
['geo-shape'] = 'geo-shape',
['globe-coordinate'] = 'globe-coordinate',
['math'] = 'math',
monolingualtext = 'monolingualtext',
multilingualtext = 'multilingualtext',
number = 'number',
quantity = 'quantity',
['string'] = 'string',
['tabular-data'] = 'tabular-data',
['time'] = 'time',
url = 'url',
['wikibase-item'] = 'wikibase-item',
['wikibase-property'] = 'wikibase-property',
['wikibase-lexeme'] = 'wikibase-lexeme',
['wikibase-form'] = 'wikibase-form',
['wikibase-sense'] = 'wikibase-sense',
-- redirects
['commons file'] = 'commonsMedia',
commonsfile = 'commonsMedia',
commonsmedia = 'commonsMedia',
coordinate = 'globe-coordinate',
coordinates = 'globe-coordinate',
count = 'number',
date = 'time',
datevalue = 'time',
entityschema = 'entity-schema',
entitySchema = 'entity-schema',
Entityschema = 'entity-schema',
['ext-id'] = 'external-id',
['xid'] = 'external-id',
['externalid'] = 'external-id',
['external id'] = 'external-id',
['external identifier'] = 'external-id',
['identifier'] = 'external-id',
['id'] = 'external-id',
form = 'wikibase-form',
forms = 'wikibase-form',
formula = 'math',
['geo-coordinate'] = 'globe-coordinate',
['geographic coordinate'] = 'globe-coordinate',
['geographic coordinates'] = 'globe-coordinate',
geoshape = 'geo-shape',
geoshapes = 'geo-shape',
geoshapevalue = 'geo-shape',
int = 'number',
integer = 'number',
iri = 'url',
irivalue = 'url',
item = 'wikibase-item',
items = 'wikibase-item',
['mathematical expression'] = 'math',
['celestial'] = 'Celestial coordinates',
['celestial coordinates'] = 'Celestial coordinates',
['calculated'] = 'Calculated property',
['Calculated property'] = 'Calculated property',
['calculated property'] = 'Calculated property',
['Commons data'] = 'geo-shape',
['commons data'] = 'geo-shape',
['Commons-data'] = 'geo-shape',
['Commons-geoshape'] = 'geo-shape',
['Commons dataset'] = 'geo-shape',
lexeme = 'wikibase-lexeme',
lexemes = 'wikibase-lexeme',
media = 'commonsMedia',
mediavalue = 'commonsMedia',
['media file'] = 'commonsMedia',
['monolangtext'] = 'monolingualtext',
['monolingual string'] = 'monolingualtext',
['monolingual text'] = 'monolingualtext',
['monolingual-text'] = 'monolingualtext',
['monolingualtextvalue'] = 'monolingualtext',
multilangtext = 'multilingualtext',
['multilingual string'] = 'multilingualtext',
['multilingual text'] = 'multilingualtext',
['multilingual-text'] = 'multilingualtext',
['multilingualtextvalue'] = 'multilingualtext',
['musical notation'] = 'musical-notation',
['musical-notation'] = 'musical-notation',
notation = 'musical-notation',
notes = 'musical-notation',
['number with units'] = 'quantity',
numbers = 'number',
['positive integer'] = 'number',
properties = 'wikibase-property',
property = 'wikibase-property',
propertyvalue = 'wikibase-property',
quantity = 'quantity',
quantityvalue = 'quantity',
['range of numbers'] = 'number',
score = 'musical-notation',
['shape-expression'] = 'entity-schema',
['shape expression'] = 'entity-schema',
ShEx = 'entity-schema',
shex = 'entity-schema',
sense = 'wikibase-sense',
senses = 'wikibase-sense',
stringvalue = 'string',
tabular = 'tabular-data',
tabulardata = 'tabular-data',
['tabular data'] = 'tabular-data',
text = 'string',
timevalue = 'time',
uri = 'url',
urivalue = 'url',
urlvalue = 'url',
value = 'number',
wikibaseform = 'wikibase-form',
wikibaseitem = 'wikibase-item',
wikibaselexeme = 'wikibase-lexeme',
wikibaseproperty = 'wikibase-property',
wikibasesense = 'wikibase-sense',
},
['commonsMedia'] = {
message = 'datatypes-type-commonsMedia',
},
['entity-schema'] = {
message = 'datatypes-type-entity-schema',
},
['external-id'] = {
message = 'datatypes-type-external-id',
},
['geo-shape'] = {
message = 'datatypes-type-geo-shape',
},
['globe-coordinate'] = {
message = 'datatypes-type-globe-coordinate',
},
['math'] = {
message = 'datatypes-type-math',
},
['monolingualtext'] = {
message = 'datatypes-type-monolingualtext',
},
['multilingualtext'] = {
message = 'datatypes-type-multilingualtext',
planned = true -- meaning not yet available
},
['musical-notation'] = {
message = 'datatypes-type-musical-notation',
},
['Celestial coordinates'] = {
message = 'celestial coordinates',
planned = true
},
['Calculated property'] = {
message = 'calculated property',
planned = true
},
['number'] = {
message = 'datatypes-type-number',
planned = true
},
['quantity'] = {
message = 'datatypes-type-quantity',
},
['string'] = {
message = 'datatypes-type-string',
},
['tabular-data'] = {
message = 'datatypes-type-tabular-data',
},
['time'] = {
message = 'datatypes-type-time',
},
['url'] = {
message = 'datatypes-type-url',
},
['wikibase-item'] = {
message = 'datatypes-type-wikibase-item', -- => no need for local translation, translated through translatewiki
},
['wikibase-lexeme'] = {
message = 'datatypes-type-wikibase-lexeme',
},
['wikibase-form'] = {
message = 'datatypes-type-wikibase-form',
},
['wikibase-sense'] = {
message = 'datatypes-type-wikibase-sense',
},
['wikibase-property'] = {
message = 'datatypes-type-wikibase-property',
},
}
qe2h1gqtoh7bp5xeta12icn9g7oq3s2
325336
325335
2026-08-22T10:31:21Z
A826
6806
೧ revisions imported from [[:w:ಮಾಡ್ಯೂಲ್:I18n/datatype]]
325335
Scribunto
text/plain
return {
-- typical entry structure:
-- message: the translatewiki message to use
-- planned: set to true to say that the datatype is not yet available
planned = {
ar = 'غير متوفر حالياً',
bg = 'все още недостъпен',
bn = 'এখনো উপলব্ধ নয়',
ca = 'encara no disponible',
cs = 'zatím nedostupný',
de = 'noch nicht verfügbar',
el = 'μη διαθέσιμο ακόμη',
en = 'not available yet',
eo = 'ankoraŭ ne disponebla',
es = 'disponible próximamente',
fr = 'pas encore disponible',
fy = 'noch net beskikber',
he = 'לא זמין עדיין',
hu = 'még nem elérhető',
it = 'non ancora disponibile',
ja = 'まだ利用できません',
ko = '아직 사용할 수 없음',
lt = 'dar nėra',
mk = 'сè уште недостапно',
nb = 'ikke tilgjengelig enda',
nl = 'nog niet beschikbaar',
nn = 'ikkje tilgjengeleg enno',
pa = 'ਹਾਲੀਆ ਨਹੀਂ ਲੱਭਦਾ ਏ',
pl = 'jeszcze nie dostępny',
pnb = 'حالیہ نہیں لبھدا اے',
pt = 'ainda não disponível',
['pt-br'] = 'ainda não disponível',
ru = 'ещё не доступен',
sl = 'ni še na voljo',
sr = 'још није доступно',
sv = 'inte tillgängligt ännu',
uk = 'ще не доступно',
ur = 'ابھی تک دستیاب نہیں',
vi = 'chưa có sẵn',
['zh-hans'] = '尚不可用',
['zh-hant'] = '尚不可用',
},
unrecognized = {
ar = 'نوع البيانات غير سليم وغير موجود في ( [[Module:i18n/datatype]])',
bg = 'невалиден тип на данните (няма в [[Module:i18n/datatype]])',
bn = 'অকার্যকর উপাত্তের ধরণ ([[Module:i18n/datatype]]-এ নেই)',
ca = 'tipus de dades invàlid (no disponible a [[Module:i18n/datatype]])',
cs = 'neplatný datový typ (není v [[Module:i18n/datatype]])',
de = 'unbekannter Datentyp (nicht in [[Module:i18n/datatype]])',
el = 'αδόκιμος τύπος δεδομένων (δεν υπάρχει στο [[Module:i18n/datatype]]',
en = 'invalid datatype (not in [[Module:i18n/datatype]])',
eo = 'malvalida datumtipo (ne en [[Module:i18n/datatype]])',
es = 'tipo de dato inválido (no disponible en [[Module:i18n/datatype]])',
fr = 'type de donnée invalide (non reconnu par [[Module:I18n/datatype]])',
fy = 'ûnjildich datatype (net yn [[Module:I18n/datatype]])',
he = 'סוג נתונים שגוי (לא תחת [[Module:I18n/datatype]])',
hu = 'hibás adattípus (nem szerepel a [[Module:i18n/datatype]] lapon)',
it = 'tipo di data non è presente tra quelli disponibili ([[Module:I18n/datatype]])',
ja = '不正なデータ型 ([[Module:I18n/datatype]]に無い)',
ko = '잘못된 데이터 종류입니다 ([[Module:i18n/datatype]]에 들어있지 않음)',
lt = 'neteisingas duomenų tipas (nėra [[Module:i18n/datatype]])',
mk = 'неважечки податочен тип (не е во [[Module:i18n/datatype]])',
nb = 'ugyldig datatype (finnes ikke i [[Module:I18n/datatype]])',
nl = 'ongeldig datatype (niet in [[Module:I18n/datatype]])',
nn = 'ugild datatype (ikkje i [[Module:i18n/datatype]])',
pl = 'niewłaściwy typ danych (nie w [[Module:I18n/datatype]])',
pt = 'tipo de dado inválido (não consta em [[Module:I18n/datatype]])',
['pt-br'] = 'tipo de dado inválido (não consta em [[Module:I18n/datatype]])',
ru = 'неизвестный тип данных (нет в [[Module:I18n/datatype]])',
sl = 'neveljaven podatkovni tip (ni v [[Module:i18n/datatype]])',
sr = 'врста податка није наведена. ([[Module:I18n/datatype]])',
sv = 'ogiltig datatyp (finns ej i [[Module:I18n/datatype]])',
uk = 'невідомий тип даних (відсутній в [[Module:I18n/datatype]])',
ur = 'غیر معتبر ڈیٹا ٹائپ (غیر موجود [[Module:i18n/datatype]])',
vi = 'kiểu dữ liệu không hợp lệ (không có trong [[Module:i18n/datatype]])',
['zh-hans'] = '无效的数据类型(未于[[Module:i18n/datatype]])',
['zh-hant'] = '無效的資料形態 (不存在於[[Module:i18n/datatype]])',
},
keys = { --table of redirects
commonsMedia = 'commonsMedia',
['entity-schema'] = 'entity-schema',
['external-id'] = 'external-id',
['geo-shape'] = 'geo-shape',
['globe-coordinate'] = 'globe-coordinate',
['math'] = 'math',
monolingualtext = 'monolingualtext',
multilingualtext = 'multilingualtext',
number = 'number',
quantity = 'quantity',
['string'] = 'string',
['tabular-data'] = 'tabular-data',
['time'] = 'time',
url = 'url',
['wikibase-item'] = 'wikibase-item',
['wikibase-property'] = 'wikibase-property',
['wikibase-lexeme'] = 'wikibase-lexeme',
['wikibase-form'] = 'wikibase-form',
['wikibase-sense'] = 'wikibase-sense',
-- redirects
['commons file'] = 'commonsMedia',
commonsfile = 'commonsMedia',
commonsmedia = 'commonsMedia',
coordinate = 'globe-coordinate',
coordinates = 'globe-coordinate',
count = 'number',
date = 'time',
datevalue = 'time',
entityschema = 'entity-schema',
entitySchema = 'entity-schema',
Entityschema = 'entity-schema',
['ext-id'] = 'external-id',
['xid'] = 'external-id',
['externalid'] = 'external-id',
['external id'] = 'external-id',
['external identifier'] = 'external-id',
['identifier'] = 'external-id',
['id'] = 'external-id',
form = 'wikibase-form',
forms = 'wikibase-form',
formula = 'math',
['geo-coordinate'] = 'globe-coordinate',
['geographic coordinate'] = 'globe-coordinate',
['geographic coordinates'] = 'globe-coordinate',
geoshape = 'geo-shape',
geoshapes = 'geo-shape',
geoshapevalue = 'geo-shape',
int = 'number',
integer = 'number',
iri = 'url',
irivalue = 'url',
item = 'wikibase-item',
items = 'wikibase-item',
['mathematical expression'] = 'math',
['celestial'] = 'Celestial coordinates',
['celestial coordinates'] = 'Celestial coordinates',
['calculated'] = 'Calculated property',
['Calculated property'] = 'Calculated property',
['calculated property'] = 'Calculated property',
['Commons data'] = 'geo-shape',
['commons data'] = 'geo-shape',
['Commons-data'] = 'geo-shape',
['Commons-geoshape'] = 'geo-shape',
['Commons dataset'] = 'geo-shape',
lexeme = 'wikibase-lexeme',
lexemes = 'wikibase-lexeme',
media = 'commonsMedia',
mediavalue = 'commonsMedia',
['media file'] = 'commonsMedia',
['monolangtext'] = 'monolingualtext',
['monolingual string'] = 'monolingualtext',
['monolingual text'] = 'monolingualtext',
['monolingual-text'] = 'monolingualtext',
['monolingualtextvalue'] = 'monolingualtext',
multilangtext = 'multilingualtext',
['multilingual string'] = 'multilingualtext',
['multilingual text'] = 'multilingualtext',
['multilingual-text'] = 'multilingualtext',
['multilingualtextvalue'] = 'multilingualtext',
['musical notation'] = 'musical-notation',
['musical-notation'] = 'musical-notation',
notation = 'musical-notation',
notes = 'musical-notation',
['number with units'] = 'quantity',
numbers = 'number',
['positive integer'] = 'number',
properties = 'wikibase-property',
property = 'wikibase-property',
propertyvalue = 'wikibase-property',
quantity = 'quantity',
quantityvalue = 'quantity',
['range of numbers'] = 'number',
score = 'musical-notation',
['shape-expression'] = 'entity-schema',
['shape expression'] = 'entity-schema',
ShEx = 'entity-schema',
shex = 'entity-schema',
sense = 'wikibase-sense',
senses = 'wikibase-sense',
stringvalue = 'string',
tabular = 'tabular-data',
tabulardata = 'tabular-data',
['tabular data'] = 'tabular-data',
text = 'string',
timevalue = 'time',
uri = 'url',
urivalue = 'url',
urlvalue = 'url',
value = 'number',
wikibaseform = 'wikibase-form',
wikibaseitem = 'wikibase-item',
wikibaselexeme = 'wikibase-lexeme',
wikibaseproperty = 'wikibase-property',
wikibasesense = 'wikibase-sense',
},
['commonsMedia'] = {
message = 'datatypes-type-commonsMedia',
},
['entity-schema'] = {
message = 'datatypes-type-entity-schema',
},
['external-id'] = {
message = 'datatypes-type-external-id',
},
['geo-shape'] = {
message = 'datatypes-type-geo-shape',
},
['globe-coordinate'] = {
message = 'datatypes-type-globe-coordinate',
},
['math'] = {
message = 'datatypes-type-math',
},
['monolingualtext'] = {
message = 'datatypes-type-monolingualtext',
},
['multilingualtext'] = {
message = 'datatypes-type-multilingualtext',
planned = true -- meaning not yet available
},
['musical-notation'] = {
message = 'datatypes-type-musical-notation',
},
['Celestial coordinates'] = {
message = 'celestial coordinates',
planned = true
},
['Calculated property'] = {
message = 'calculated property',
planned = true
},
['number'] = {
message = 'datatypes-type-number',
planned = true
},
['quantity'] = {
message = 'datatypes-type-quantity',
},
['string'] = {
message = 'datatypes-type-string',
},
['tabular-data'] = {
message = 'datatypes-type-tabular-data',
},
['time'] = {
message = 'datatypes-type-time',
},
['url'] = {
message = 'datatypes-type-url',
},
['wikibase-item'] = {
message = 'datatypes-type-wikibase-item', -- => no need for local translation, translated through translatewiki
},
['wikibase-lexeme'] = {
message = 'datatypes-type-wikibase-lexeme',
},
['wikibase-form'] = {
message = 'datatypes-type-wikibase-form',
},
['wikibase-sense'] = {
message = 'datatypes-type-wikibase-sense',
},
['wikibase-property'] = {
message = 'datatypes-type-wikibase-property',
},
}
qe2h1gqtoh7bp5xeta12icn9g7oq3s2
ಟೆಂಪ್ಲೇಟು:Datatype
10
121077
325339
2025-12-22T05:44:33Z
w>A826
0
೧ revisions imported from [[:d:Template:Datatype]]
325339
wikitext
text/x-wiki
{{#invoke:Datatype|showdatatype|{{{1|}}}|{{{2|}}}}}<noinclude>{{documentation}}</noinclude>
2syab35tmt6mxf1jlqmxvt8tuu14br2
325340
325339
2026-08-22T10:31:22Z
A826
6806
೧ revisions imported from [[:w:ಟೆಂಪ್ಲೇಟು:Datatype]]
325339
wikitext
text/x-wiki
{{#invoke:Datatype|showdatatype|{{{1|}}}|{{{2|}}}}}<noinclude>{{documentation}}</noinclude>
2syab35tmt6mxf1jlqmxvt8tuu14br2