وحدة:Wikidata.Ca/شرح
![]() | هذه صفحة توثيق وحدة:Wikidata.Ca الفرعية، لشرح القالب وتصنيفه، وهي لا تدخل في استخدامه. |
![](https://upload.wikimedia.org/wikipedia/commons/thumb/4/41/Wikidata_Stamp_Rec_Light.svg/100px-Wikidata_Stamp_Rec_Light.svg.png)
This is the documentation of Module:Wikidata.Ca in English.
This module fetches formatted data from Wikidata. It works in local language and it has options for internationalization.
Wondering what does Wikidades mean? See wikt:en:dada#Catalan.
Functions
Basic function:
claim
: returns the value (or values) of a statement or a qualifier formatted with parameters or using a default format depending on the data type.
Other functions:
getLabel
: returns the label of an item, with some optional parameters.getParentValues
: returns labels and parent values of a property, recursively.linkWithParentLabel
: creates a link with the label of a parent property. For example, to link (P405) with the label (P835) from the parent item.yearsOld
: returns the age of a person: difference between (P569) and (P570), when the two properties exist; or difference between (P569) and current date, if there is no P570. Returns the completed years (nn) or range of years (nn/mm) depending on the precision of the dates.editAtWikidata
: returns a pencil icon linked to a declaration on Wikidata. Planned to pop up an editing interface by mw:Wikidata Bridge.
Other utility functions: getSiteLink, lang, numStatements, validProperty, formatNum.
Function claim
Returns the value (or values) of a statement or a qualifier formatted with parameters or using a default format depending on the data type. By default, it refers to the Wikidata item (Qid) associated to the current page.
Full syntax:
{{#invoke:Wikidata.Ca|claim|item= |lang= |property= |qualifier= |value= |list= |tablesort= |formatting= |separator= |conjunction= |editicon= |showerrors= |default= }}
Additional syntax for table format:
{{#invoke:Wikidata.Ca|claim|item= |lang= |property= |qualifier= |qualifier2= |...|qualifierx= |formatting=table |tablesort= |sorting= |rowformat= |rowsubformat1= |...|rowsubformatx= |colformat0= |...|colformatx= |case0= |...|casex= |separator= |conjunction= |editicon= |showerrors= |default= |references= }}
General parameters
item=
(optional) Specifies an item (Qid) other than the associated to current page. Use it with moderation as arbitrary access to Wikidata is expensive. It can be defined in the parent frame of the template. Aliasfrom
.
lang=
(optional) Indicates the code of a given language. It can be defined in the parent frame of the template. By default, it uses the local language of the wiki. If there is no label in this language then it tries in the fall back languages defined in MediaWiki. On the debug console type =mw.dumpObject(mw.language.getFallbacksFor(mw.getContentLanguage():getCode())) to see the fallback languages of your wiki. If the label has not been found in the preferred language, it adds the language code and a label icon to translate it on Wikidata.to translate it on Wikidata.
property=
(required) Property id of the statement (Pid). It is possible to define alternative properties with any separator, for example "P17 or P131", and it gets the first one found. It also accepts a minuscule p, but it is not recommended. It also accepts the property label, for example "property=country" is equivalent to "property=P17" for (P17).
qualifier=
(optional) Qualifier (Pid) of a property value.
value=
(optional) Value preferred to Wikidata one. It can be an optional parameter in a template with format {{{parameter|}}}, so if it exists then it takes the value of the parameter, if it is void then it gets the value of Wikidata.value=NONE
With this special value, it returns a void string. This allows to set a parameter that does not fetch anything from Wikidata, or to show only values provided in the template with{{{parameter|NONE}}}
. It is equivalent to wiki syntax:{{#ifeq:{{{parameter|}}}|NONE|<!-- do nothing -->}}
.
references=
(optional) With any value, recommendedyes
for readability, it shows the references of the value. With a numeric value it is the maximum number of references to fetch for the statement, by default 1. If exist (P854), and either (P1476) or (P248), then it is formatted with (Q5637226) using the local parameters defined in table i18n["cite"] at Module:Wikidata.Ca/i18n. If exist (P1433), and title or stated in, then it is formatted with (Q5624899). Otherwise, it is formatted as text.- If used with formatting=table (see below) you must include a placeholder for references.
list=
(optional):list=true
(default) shows a list of all preferred and normal values (see separator and conjunction below). It never fetches deprecated values.list=false
orlist=no
shows only one value, the best ranked (preferred or normal) or the oldest of those with the best rank.list=lang
for monolingual values, shows values corresponding to the language of the lang parameter. See parameters lang and formatting for monolingualtext.list=notlang
for monolingual values, it does not show values corresponding to the language of the lang parameter.
listrank=bestrank
lists only the best ranked values, either preferred or normal. If list=lang is used then bestrank is ignored. For compatibility with older versions, list=bestrank or list=firstrank are aliases. It is equivalent to list=true if all values have the same rank. It is equivalent to list=false if only one value is best ranked.listmax=<number>
Sets the maximum number of values to be returned. For compatibility with older versions, list=<number> is also valid. Setting listmax=1 is equal to list=false. Setting listmax=0 is equal to list=true.tablesort=0
(optional) sorts the list in ascending order. By default, sorting is by rank (preferred, normal), and by order in Wikidata.
separator=
(optional) Separator to use in lists or tables. For lists, the default is MediaWiki:Comma-separator (in English a comma and a blank space ',%nbsp;'). For tables, the default is a line break <br />. In some specials cases, a <br /> may not work if it is included with strip markers. The alternative is to use the mark of a line feed control character: separator=LF.
conjunction=
(optional) Conjunction to use as a separator between the last two elements of a list. By default, it is equal to 'separator' if it is defined, otherwise it is MediaWiki:And plus MediaWiki:Word-separator (in English ' and '). For tables the default is a line break <br />.
qseparator=
(opcional) Separator for qualifiers to use in lists or tables. For lists, the default is separator. For tables the default is MediaWiki:Comma-separator.
qconjunction=
(opcional) Conjunction for qualifiers. For lists the default is conjunction. For tables, the default is qseparator.
case=
(optional) Grammatical case to be used. As a general case handled by the module:- case=gender: according to (P21) of the element it shows the label (P2521) of the value.
- For other particular cases of the local wiki, see the documentation of Module:Wikidata.Ca/i18n.
itemgender=
(optional) Item where to check (P21) for using the feminine form if necessary. By default it isitem
. It is used in combination with case=gender.
editicon=
(optional) Definition of the pencil iconto show and edit the statement fetched from Wikitada (planned to pop up an editing interface by mw:Wikidata Bridge). Value of editicion is get from invoke call, or from parent frame of the template, or by default from definition of value addpencil in Module:Wikidata.Ca/i18n as wiki setting.
- editicon=true: show the icon. It will not be necessary if this is the default value of the wiki.
- editicon=false or editicon=no: do not show the icon.
- editicon=right: show the icon and align it to the right.
shownovalue=
(optional) Flag for ignoring statements defined as "no value". By default it is shownovalue=true showing message MediaWiki:Wikibase-snakview-snaktypeselector-novalue. With values shownovalue=false or shownovalue=no then the statement is ignored.
showerrors=
(optional) With any value, typically 'yes', it shows error messages, if any. By default it shows the 'default' parameter.
default=
(optional) Text to show for any error if 'showerrors' parameter is not defined.
sandbox=
(opcional) With any value, typically 'yes', it redirects the invokes to Module:Wikidata.Ca/sandbox. The title of the subpage is retrieved from MediaWiki:Sandboxlink-subpage-name, "sandbox" in English, check it in the wiki language if necessary. This parameter can be used as parent from a template. It makes no sense used directly in an invoke or require for testing purposes. To be used only in preview or temporally as the sandbox module should not have any permanent link.
Parameters for formatting
formatting=
(optional). Options for formatting depending on the data value and type:
Data value entity:
formatting=raw
Wikidata id (Qid or Pid) of the value.formatting=label
Label of the value in local language, its fall backs or as raw.formatting=sitelink
Title of the local site page, not linked. If there is no local page then it returns the format raw prefixed with interwiki link "d:".formatting=internallink
Internal link whenever possible: 1) to local wiki page (sitelink), 2) red link to the label if it does not exist as sitelink in another Wikidata item, 3) to Wikidata as last option.formatting=pattern
Format using a pattern with $1 as a parameter to replace. It can include templates or parser functions with a non-expanded format: {{((}}template{{!}}$1{{))}} or {{((}}template{{!}}parameter name{{=}}$1{{))}}, or alike.
- The default format is a piped link with link target as sitelink and link label as label. A link to Wikidata is formatted with light blue color different from the internal blue link.
formatting=ucfirst
Variant of the default piped link with uppercase in first letter of label. In a list, it is used only for the first value.formatting=ucinternallink
Both "ucfirst" and "internallink".
Data value string:
- General:
formatting=pattern
Format using a pattern with $1 as a parameter to replace, for example:formatting=[http://whc.unesco.org/en/list/$1 $1]
. For identifiers statements with an auto-generated link, the pattern can be found in the talk page of the property. It can include templates or parser functions with a non-expanded format (see above for entity).
- Type URL:
formatting=weblink
Format as external link with the website as label: [http://www.example.com example.com], [http://example.com/en/page example.com…].
- Type external-id:
formatting=externalid
Format as external link with the URL pattern from (P1630) in entity Pid ofproperty
.
- Type math formula:
- Returns the content wrapped with tag <math> that generates an image of the formula. See mw:Extension:Math and examples in (P2534).
- Type musical notation
- Returns the content wrapped with tag <score> that generates an image of the score. See mw:Extension:Score and examples in (P6686). Format options:
formatting=sound
(optional) Adds the attribute sound="1" to the tag, embedding an audio player after the score image.
Data value quantity:
- By default it shows the quantity.
formatting=unit
Shows the quantity and the unit. It can show plural units if it is defined at Module:Wikidata.Ca/Units.formatting=unitlinked
Alternative with unit name linked.
formatting=unitcode
Shows the quantity and the code or abbreviation of the unit defined in (P5061). It can be changed locally at Module:Wikidata.Ca/Units. If not found it shows the unit name.formatting=unitcodelinked
Alternative with unit code linked.
formatting=duration
Shows a duration quantity broken into human-readable units: millennia, centuries, decades, years, days, hours, minutes, and seconds. For example, 123456 seconds: 1 day, 10 hours, 17 minutes and 36 seconds. Previously it tries to convert the unit to seconds (using convert=Q11574), otherwise it assumes the quantity is expressed in seconds.formatting=durationhms
Shows duration abbreviated in hours, minutes and seconds. For example, 12345 seconds: 3h 25m 45s. Format of local abbreviations can be defined at Module:Wikidata.Ca/i18n in table "hms".formatting=durationh:m:s
Shows duration hms simplified, as in 3:25:45, or minutes and seconds as in 01:23 or 45:00.formatting=durationm:s
Shows duration in minutes and seconds, even if greater than 60 minutes (i.e. used in duration of songs).
formatting=raw
Shows the quantity without any language format, that is with decimal point and no thousand separators. It is the appropriate format for numerical calculations. See also the function formatNum for applying the format to the final result according to language definitions.formatting=pattern
Format using a pattern with $1 as a parameter to replace.numformat=%width.precision'flag'
Formats according to string.format specifiers for numbers, where width is the total width of the returned value, a point is the decimal separator, precision is the number of decimal places to show, and flag can be: f floating point, e scientific notation, i integer, o octal, h hexadecimal, E i H upper-case, among others. For example, for number 15.656: "%.1f" formats 15.7, "%05i" formats 00015, "%.2e" formats 1.57e+01.convert=Qid
(optional) Convert the quantity to the unit requested by its Qid. Conversions are made according to factors indicated in Qid for properties (P2370) or (P2442), except for temperatures defined with conversion formulas between ºC, ºF and ºK. For example, a value of "74 inch" with convert=Q174728 ( (Q174728)) gives "188 centimeters" according to the conversion "2.54 centimeter" indicated in (Q218593). It is rounded keeping the default precision of the original value according to the number of significant figures. It can be combined with formatting=unitcode. It can also be used with formatting=table, see below.convert=default
(optional) Conversion of units defined in table convert_default at Module:Wikidata.Ca/Units.convert=default2
(optional) Variant that shows two values: the converted quantity and the original quantity in brackets.convert=M
Converts to millions, rounding with no decimals, if the quantity is greater than 100,000,000. Adds M before the unit name or code, for example Meuro, M$.
Data value monolingual (monolingualtext):
formatting=language
Returns the language code of a monolingual value, for example used in (P1448).formatting=text
Returns the text wrapped in a span with lang attribute, if it's different from the local language:<span lang="xx">foreign text</span>
.formatting=pattern
Format using a pattern with $language and $text as parameters to be replaced, for example "formatting=($language) $text".list=lang
Shows the values corresponding to the defined language or the default language. See lang parameter above.list=notlang
Does not show the values corresponding to the defined language or the default language. For example, it may be useful for (P1559) avoiding redundancy in wiki local language.
Data value coordinates (globecoordinate):
formatting=latitude
Returns the latitude in decimal format.formatting=longitude
Returns the longitude in decimal format.formatting=globe
(default) Returns the globe parameter recognized by Template:Coord. It is requested for coordinates of globes other than Earth.formatting=$lat...$lon...$globe
Format using a pattern with $lat, $lon and optionally $globe as parameters to be replaced. It can include templates with non-expanded format, i.ex. {{((}}coord{{!}}$lat{{!}}$lon{{))}}.formatting=dimension
Returns the dimension in meters equivalent to dim parameter of GeoHack.
Data value datetime (labeled time):
- By default it uses the format defined Module:Wikidata.Ca/i18n, in datetime table, depending on the precision. Optionally, for precision of day:
formatting= #time syntax
Accepts any valid format of #time parser function. For example: formatting=d-m-Y (10-09-2024), formatting=[[j xg]] (10 سبتمبر), formatting=Y (2024).
- Adds the calendar when it may be ambiguous: if the date is before 1582-10-15 and it is set to Gregorian, or if it is later than 1582-10-04 and it is set to Julian. See en:Adoption of the Gregorian calendar for further reading.
Parameters of table with property and qualifiers
property | qualifier1 | qualifier2 etc. | |
---|---|---|---|
values 1st statement | $0 | $1 | $2, etc. |
2nd, etc. | $0 | $1 | $2, etc. |
formatting=table
A statement with qualifiers is considered as a table of values shown at right. You can define the format of the rows and each column in the table. Separators for rows by default are line breaks (see separator and conjunction above). If you really want the output in a wikitable you can use separator=</tr><tr> and the corresponding opening and closing tags before and after the invoke. Specific parameters for this format:
Columns:
qualifier1 ... qualifierx=
Qualifiers with consecutive numbers without any limitation. General parameterqualifier
is an alias for qualifier1.qualifierx = Pid1 OR Pid2
Alternatives values for a qualifier, without limitation of successive ORs. It takes the first one found. A typical example is (P585) OR (P580).qualifierx = Pid1/Pid2
From the entity value of property Pid1 it gets the parent value Pid2. This allows to obtain additional data in the table even though defined in a parent element. For example, to get railway lines with its icon: qualifier=P81/P154. It can be combined with the OR option taking priority the OR.qualifierx = /Pid
Equivalent to previous one but without Pid1, it gets another property of same entity. This allows to obtain values defined either in a qualifier or in a property.
colformat0 ... colformatx=
Format to apply to each column, using 0 for the property and 1-x for every qualifier. It accepts the same syntax asformatting
for each data type. See above #Parameters for formatting.case0 ... casex=
Grammatical case to apply to each column. Parametercase
, without numbering, applies to all values. See above #General parameters.convert0 ... convertx=
Conversion of units to apply to each column. See above #Parameters for formatting, data type quantity.whitelist0 ... whitelistx=
List raw values, usually Qids, in a column to show the statement, with any separator.blacklist0 ... blacklistx=
List raw values, usually Qids, in a column to do not show the statement, with any separator.- Using several whitelist, or several blacklist, it works as an OR function. If a whitelist is used in a column and a blacklist in another column then results may be unexpected (see an explanatory table, in Catalan).
selectvalue1 ... selectvaluex=
List raw values, usually Qids, in a column to show its value.ignorevalue1 ... ignorevaluex=
List raw values, usually Qids, in a column to do not show its value.
Rows:
rowformat=
Format of the rows of values for property and qualifiers. The property uses the placeholder $0 and the qualifiers $1 to $x. By default it isrowformat=$0 ($1, ... $x)
. You can include list tags * or # and also templates or parser functions not expanded: {{((}}template{{!}}unnamed parameter{{!}}name{{=}}named parameter{{))}}. If used with parameter "references" (see above) you must include the placeholder $R0 for references.rowsubformat1 ... rowsubformatx=
Previous format to apply to $1-$x defined in rowformat, only if there is any value. For example "rowformat=$0 $1" and "rowsubformat1=($1)" gives "$0 ($1)" or "$0" if $1 is void, avoiding empty parenthesis. A rowsubformat may have several variables $1-$x. Note that substitutions are made consecutively in numeric order, so it may include a posterior $x but not an anterior one as it has been already handled.tablesort=
with values 0 to x, it sorts the table per property (0) or per qualifier (1 to x). Sorting is in ascending order alphabetically, numerically or by date. It accepts multiple sorting keys with any separator, i.e.tablesort=0/2/1
. By default it sorts the property by rank (preferred, normal), and by order in Wikidata.sorting=-1
sorts in descending order. With any other value, or by default, it sorts in ascending order. If tablesort is used with multiple keys, the sorting order is applied to all the keys.list=false
shows only the first row of the table, according to the order indicated or by default.
Function getLabel
Returns the label of an item.
1=
(first positional parameter, required) Wikitada id of the item (Qid or Pid). Alias:item
,from
.lang=
(optional) Language code, as in function claim. See above #General parameters.itemgender=
(optional) Qid to determine the gender form to use for the label, as in function claim. See above #General parameters.linked=
(optional) With any value, except 'no', it returns the label linked either to sitelink page or to Wikidata.label=
(optional) Shows this label instead of one fetched from Wikidata. It makes sense if used with linked=yes.editicon=
(optional) allows to remove the pencil edit icon, as in function claim. See above #General parameters.
Function getParentValues
Returns recursively values of a property labeled with a parent value.
item=
(optional) Specifies an item (Qid) other than the associated to current page. Use it with moderation, as arbitrary access to Wikidata is expensive.property=
(optional) Property id of the statement (Pid). By default it is (P131). Supports a list of alternative values with any separator.label=
(optional) Parent property id to use as label. By default, it is (P31).uptolabelid=
(optional) Last iteration to fetch, using Qid, if previously there is not any 'property' not found. It supports multiple values with any separator.upto=
(optional) Quantity value of maximum number of iterations. By default it is 10 as a protection, large enough for common cases.- upto=label (deprecated): Alternative to
uptolabelid
using a label value, for example "upto=country".
- upto=label (deprecated): Alternative to
uptovalueid=
(optional) Alternative touptolabelid
using Qid of values instead of labels. It supports multiple values with any separator. Alias uptolinkid provisionally for backwards compatibility.showlabelid=
(optional) White list of label Qids to show, with any separator.labelshow=
(deprecated) Alternative toshowlabelid
using label values with a slash as a separator.include_self=true
(optional) Includes current page on the output list.sorting=-1
(optional) Sorts the list of paired values in descending order.last_only=true
(optional) Only shows the last value fetched. For example, with uptolinkid=Qid and last_only=true it will show the value corresponding to label Qid.formatting=
(optional) Format for the property value. By default it is a piped link to local page or Wikidata (see above formatting for data value entity).valuetext=
(optional) Property to use as link label with 'property' value as link target.labelformat=
(optional) Format for the label. By default, it is "label" (see above formatting for data value entity).rowformat=
(optional) Output format for each pair of values, with placeholder $0 for the label and $1 for the value. By default it is "rowformat=$0 = $1", for example "country = [[France]]"separator=
(optional) Separator for each pair of label-value, by default <br />.cascade=true
(optional) Output with indentation. It may be useful if rowformat only uses $1.
Note: labels can be fixed for needs of an infobox in Module:Wikidata.Ca/labels. For example, in Catalan "Municipi del Brasil" is modified to "Municipi" removing the determiner introduced by a preposition.
Function linkWithParentLabel
Creates a link with the label of a parent property.
It accepts most parameters of function claim, except "formatting" that uses the default "internallink". Additionally:
parent=
the parent property id to use as a link label. It accepts alternative values with any separator, as it does the parameter "property" of the function claim.
Function yearsOld
Returns the age of a person calculating the completed years between birth date and death date or current date. If both dates do not have precision of day then it shows a range of years, maximum a decade.
The syntax is: {{#invoke:Wikidata.Ca|yearsOld|formatting= |item= }}
. Parameters item
and formatting
are optional. By default it shows the quantity.
formatting=unit
(optional) Gets the unit from table i18n["years-old"] at Module:Wikidata.Ca/i18n for singular, plural or other plural forms as paucal used in Slavic languages as Russian. See parser function PLURAL at mw:Help:Magic words#Localization.formatting=pattern
(optional) Format using a pattern with $1 as a placeholder for the quantity. A common use case is " ($1 years old)". It does not evaluate the expression in singular, plural or paucal and fetches the unit from (Q24564698). As an alternative you can define a global pattern in table i18n["years-old"] that allows the parameter $1.
Function editAtWikidata
Returns the pencil icon to edit a declaration on Wikidata.
Syntax: {{#invoke:Wikidata.Ca|editAtWikidata|<value>|item= |property= |lang= |editicon= }}
1
(optional), first unnamed parameter. If it exists it will not show any icon. For example if a parameter is informed locally then it has not been fetched from Wikidata and the icon is not needed.property=Pid
(required). Id of the property to link with anchor. It does not check the Pid, other anchors can be used, for example property=identifiers to link to the identifiers section.item=Qid
(optional). Id of the item. It will not be necessary if it is the same as the associated page.lang=code
(optional). Language code. Opening the link to Wikidata will display the page in this language. By default it uses the local wiki language for the main article space or the user language defined in the preferences for other namespaces.editicon=<right/true>
(optional). With value right it aligns to the right. Value true only makes sense if the wiki is set with ["addpencil"]=false at Module:Wikidata.Ca/i18n.
See above #General parameters for more reading about these parameters.
Utility functions
getSiteLink
Returns the title of local page for a given item. Syntax:{{#invoke:Wikidata.Ca|getSiteLink|<Qid>|<wiki>}}
- Without any parameter it returns the current page. With a Qid it returns the local page linked in the Qid item. It returns a void string if there is no local page linked. A second parameter with the wiki code it return the page linked for this wiki (enwiki, frwiki,... cawiktionary, etc.)
lang
Returns the language code as managed by function claim. See #General parameters above. Syntax:{{#invoke:Wikidata.Ca|lang|{{{lang|}}}}}
- Parameter lang is optional.
numStatements
Returns the number of statements of a multi-value property considering only best ranked values. It allows the decide how to handle long lists. With a second unnamed parameter it counts the number of values of a qualifier. Syntax:{{#invoke:Wikidata.Ca|numStatements|<Pid>|item={{{item|}}} }}
{{#invoke:Wikidata.Ca|numStatements|<Pid>|<Qual_id>|item={{{item|}}} }}
- Example: {{#invoke:Wikidata.Ca|numStatements|P47|item=Q1861}} → 0
- For more complex queries, for example with list=true for preferred and normal ranking or with filters as whitelist, it can be used with the same syntax as function claim, without positional parameters.
validProperty
Returns "void" if the property is not found, or it has only statements with values "no value" or "some value" or with deprecated rank. Syntax:{{#invoke:Wikidata.Ca|validProperty|<Pid>|item={{{item|}}}
- It can be used as an alternative to #property. It accepts the same parameter used by this parser function:
from
is an alias foritem
.
formatNum
Formats a quantity according to language definitions. It is equivalent to magic word formatnum with the option to specify a language other than the wiki default. Syntax:{{#invoke:Wikidata.Ca|formatNum|<num>|<lang>}}
- First requested parameter is the number to format. The second optional parameter is the language code (see parameter lang of function claim).
Old function retrieving values of (P1323). Removed and replaced with a simple call {{#invoke:Wikidata.Ca | claim | property=P1323 | formatting=externalid | separator=<br />}}.getTAValue
- For debugging functions see Module:Wikidata.Ca/debug.
Wikidata redirects
A Wikidata element can be redirected to another element, often as a result of a merge. The values of a property can be provisionally a redirect, usually fixed by bot after a week.
When fetching data, it follows redirects: values fetched correspond to the target element of a redirect. If a Qid is used raw, not for fetching its data but for comparison purposes as in a filter, then a Qid redirected may provoke unexpected results. This may affect function claim with parameters whitelist, blacklist, selectvalue or ignorevalue, and function getParentValues with parameters uptolabelid, uptovalueid, showlabelid.
You can validate Qids included in a template, or other page. Use {{#invoke:Wikidata.Ca/debug|validateIds|<page>}}
with the page title to check. For every Qid included in the page it shows: (ok),
(not found) or
(redirect). This function is expensive and for a long list it may raise an error for not enough Lua memory.
Using from another module
All functions (claim, getLabel, getParentValues, linkWithParentLabel, yearsOld, lang) can be used from other modules via require
with the same parameters provided in a table, for example:
- require("Module:Wikidata.Ca").claim{item="Q...", property="P...", ...}
- require("Module:Wikidata.Ca").getLabel({"Q...", ['lang']="en"})
Function claim can return a second value depending of parameter query that may be used on infobox modules for specific treatment. With query=untranslated it returns nil or true for values not translated in requested language. With query=num it returns the number of statements as function numStatements does.
Parameters that accept "true" or "false" values can be defined as boolean type.
Dependencies
- Subpages relative to the main module.
- ../i18n (optional): translations of messages and local formats. If
lang
has a value other than local language then it searches the corresponding subpage, for example ../i18n/eu. If it does not exist then defaults to English. - ../Units (optional): definition of plurals and codes for units. If it does not exist or the unit is not found then it uses the unit name.
- ../labels (optional): exceptions and fixes of labels for an infobox.
- ../debug: may appear occasionally for the track function.
- ../i18n (optional): translations of messages and local formats. If
- Mediawiki messages used in requested or default language:
- Mediawiki:Comma-separator, Mediawiki:And, Mediawiki:Word-separator
- Mediawiki:Wikibase-snakview-snaktypeselector-novalue, Mediawiki:Wikibase-snakview-snaktypeselector-somevalue
- Mediawiki:Wikibase-time-calendar-gregorian, Mediawiki:Wikibase-time-calendar-julian
- Mediawiki:Translate-taction-translate
- Mediawiki:Wikibase-client-data-bridge-bailout-suggestion-go-to-repo-button
- MediaWiki:Sandboxlink-subpage-name
- If necessary, they can be created in Translatewiki. If you have an account in Translatewiki, you can access directly to it activating the following link with the title of the message and the language code:
[[translatewiki:MediaWiki:<message>/<lang>]]
.
أمثلة استعمال
الأمثلة أدناه هي عينات تستعمل بيانات لمقالات مقابلة.
- مثال بسيط:
- {{#invoke:Wikidata.Ca | claim |property=P20}}
في مقالة جان فرانسوا شامبليون تعطينا : الخاصية مفقودة.
- وهي قراءة لل (P20) من ويكي بيانات.
- قراءة بلا روابط:
- {{#invoke:Wikidata.Ca | claim | property=P20 | formatting=label}}
تعطينا: الخاصية مفقودة.
- قيمة معروفة:
- {{#invoke:Wikidata.Ca | claim | property=P20 | value={{{مكان_الوفاة|}}} }}
في قوالب المعلومات
- ستعرض قيمة {{{مكان_الوفاة|}}} إذا عرفت في المقالة، وإلا فإن النتيجة ستكون قراءة من ويكي بيانات : باريس
- قيمة بتنسيق تاريخ:
- {{#invoke:Wikidata.Ca | claim | property=P569}}
تعطينا تاريخ الميلاد بتنسيق التواريخ الافتراضي:
- الخاصية مفقودة.
- التنسيق وفق نمط معين:
- {{#invoke:Wikidata.Ca | claim | property=P214 | formatting=[http://viaf.org/viaf/$1 $1]}}
تعطينا:
- الخاصية مفقودة.
- قيمة واحدة:
- {{#invoke:Wikidata.Ca | claim | property=P18 | list=false | formatting=[[ملف:$1|thumb|upright=.5|صورة توضيحية]]}}
- يعرض أول قيمة (في هذه الحالة صورة) من القيمة المعرفة.
- تنسيق رابط خارجي:
- {{#invoke:Wikidata.Ca | claim | property=P856 | formatting=weblink}}
في مقالة برلين تعطينا:
- الخاصية مفقودة.
- استعمال قالب في النتيجة:
- {{#invoke:Wikidata.Ca | claim | item=Q425440 | property=P267 | formatting={{((}}color{{!}}green{{!}}$1{{))}} }}،
تستعمل {{color}}, تعطينا:
- قائمة قيم:
- {{#invoke:Wikidata.Ca | claim | property=P47}}
في مقالة بايي دو لا لوار تعطينا:
- الخاصية مفقودة.
- لاحظ رابط [[بروتاني (منطقة إدارية)]] يظهر [[بروتاني]]
- قائمة منسقة:
- {{#invoke:Wikidata.Ca | claim | property=P150 | separator=<br /> | conjunction=<br />}}
تعطينا
- الخاصية مفقودة.
- إحداثيات جغرافية:
- {{#invoke:Wikidata.Ca | claim | property=P625 | formatting=latitude}} تعطينا: الخاصية مفقودة.
- {{#invoke:Wikidata.Ca | claim | property=P625 | formatting=longitude}} تعطينا: الخاصية مفقودة.
طالع أيضا
- Wikibase Lua functions : هي الدوال الأساسية التي يمكن العثور عليها في Module:Wikibase.