This is an archive of past discussions. Do not edit the contents of this page. If you wish to start a new discussion or revive an old one, please do so on the current talk page. |
Archive 1 | Archive 2 | Archive 3 | Archive 4 | Archive 5 | Archive 6 | → | Archive 8 |
I've added a new function to the sandbox to get the aliases for an entity. This is an expensive call if arbitrary access is used.
The function getAliases has the qid of a Wikidata entity passed as |qid=
(it defaults to the associated qid of the current article if omitted), and a local parameter passed as the first unnamed parameter. It implements blacklisting and whitelisting with a field name of "alias" by default. Any local parameter passed becomes the return value, subject to the blacklisting of "alias".
It returns the aliases for the Wikidata entity with the usual list options, and nothing is returned if the aliases do not exist.
Examples and test cases are at Module talk:WikidataIB/sandbox/testing #getAliases. It may be useful for infoboxes that have an "alternative names" field. -- RexxS ( talk) 19:51, 14 November 2018 (UTC)
Would it be possible to generate citations (i.e. <ref name="-wd-Q56813023">[transcluded data]</ref>
) using this module? I think this would be useful in infoboxes since Wikidata references are usually different to the sources used directly in articles. The French Wikipedia has something similar but it seems to be somewhat less developed and creates duplicates where the same source is used multiple times. {{
Cite Q}} exists but it's not entirely Lua-based.
Jc86035 (
talk) 15:58, 17 November 2018 (UTC)
I have also noted that French WP automatically creates archive links. It would help reducing the problem of linkrot here, and simplify the referencing work of en.wp editors. -- Ohc ¡digame! 11:22, 18 November 2018 (UTC)
How can the multipliers like "million" been localized? Do I have to translate something for that or create a file in the directory I18n if I want to use it in another language than English?
For example
{{#invoke:WikidataIB |getValue |qid=Q684773 |P1436 |rank=b |fwd=ALL |osd=n |scale=6 |uabbr=y}}
results (independently of the language) into "9.444 million ", see als:ETH-Bibliothek. -- Zuphilip ( talk) 12:17, 31 December 2018 (UTC)
local i18n =
{
...
"multipliers" = {
0 = "",
3 = " thousand",
6 = " million",
9 = " billion",
12 = " trillion",
}
}
@ RexxS: In the short-to-medium term, would it be possible/desirable to enable calling this module from other Lua modules? I've tried making a Lua/Wikidata infobox ( code, test) which calls data from multiple items, and presumably this would be quite difficult in wikitext. I don't really know how this module works so I haven't tried to touch it. I'm not anticipating actually making use of this just yet, but maybe in a few months to a few years.
For context on why I would want to call multiple items: Other music databases tend to indicate music releases, compositions and tracks as separate entities, but Wikidata has lumped them all together through infobox imports. There are a few thousand items which aren't lumped together like this (so this infobox would only work with those items). There is no real consensus for using either method in Wikidata. (Related: draft RfC (by me); most recent discussion.) Presumably this would also be useful for things like going up an administrative subdivision tree. Jc86035 ( talk) 09:39, 30 December 2018 (UTC)
require()
function. So it should not be much of a problem to write a bespoke module that picks up several properties and/or qualifiers and assembles them internally into an infobox (or any other wikitext).{{infobox
| above = {{#invoke:WikidataIB |getLabel |qid={{{qid|}}} }}
| label1 = Language
| data1 = {{#invoke:WikidataIB |getValue |rank=best |P407 |name=language |qid={{{qid|}}} |fetchwikidata={{{fetchwikidata|}}} |onlysourced={{{onlysourced|}}} |{{{lang|}}} }}
| label2 = Artist
| data2 = {{#invoke:WikidataIB |getValue |rank=best |P175 |name=artist |qid={{{qid|}}} |fetchwikidata={{{fetchwikidata|}}} |onlysourced={{{onlysourced|}}} |{{{artist|}}} }}
| label3 = ISWC
| data3 = {{#invoke:WikidataIB |getValue |rank=best |P1827 |name=iswc |qid={{{qid|}}} |fetchwikidata={{{fetchwikidata|}}} |onlysourced={{{onlysourced|}}} |{{{iswc|}}} }}
}}
|fetchwikidata=
, |suppressfields=
and |onlysourced=
control that behaviour.I integrated the module in Template:Infobox_library and now an Lua-error occur when the qual-parameter is used in combination with osd=yes for not sourced statements, e.g.:
{{#invoke:WikidataIB |getValue |qid=Q1200925 |P1436 |rank=b |qual=P585 |fwd=ALL |osd=yes |{{{collection_size|}}} }}
← [edit: was giving an error]
Can someone fix this? Ping User:RexxS (I would expect that for the case that only sourced statements are allowed and the current statement is not sourced around line 1087 we would "continue" the loop with the next possible statement and not just leave out one assignment, but I haven't look closer...) -- Zuphilip ( talk) 07:26, 2 January 2019 (UTC)
{{#invoke:WikidataIB |getValue |qid=Q1200925 |P1436 |rank=b |fwd=ALL |osd=no |{{{collection_size|}}} }}
→ 4,401,625 unit, 72 terabyte, 63,800 linear metre
{{#invoke:WikidataIB |getValue |qid=Q1200925 |P1436 |rank=b |qual=P585 |fwd=ALL |osd=no |{{{collection_size|}}} }}
→ 4,401,625 unit (2020), 72 terabyte (2019), 63,800 linear metre (2019)
{{#invoke:WikidataIB |getValue |qid=Q1200925 |P1436 |rank=b |qual=P585 |fwd=ALL |osd=no |qualsonly=yes |{{{collection_size|}}} }}
→ 2020, 2019, 2019
{{#invoke:WikidataIB |getValue |qid=Q1200925 |P1436 |rank=b |qual=P585 |fwd=ALL |osd=yes |{{{collection_size|}}} }}
→{{#invoke:WikidataIB |getValue |qid=Q1200925 |P1436 |rank=b |qual=P585 |fwd=ALL |osd=yes |qualsonly=yes |{{{collection_size|}}} }}
→Would it be technically possible to automatically not link some common pages (e.g. Painting, Canada) based on a list of articles or a list of QIDs? I think it would be possible but I'm not sure how it would be implemented in this module. Tony1 seems to have asked for something like this on Meta. Jc86035 ( talk) 10:41, 17 November 2018 (UTC)
What links here
button in the sidebar. For me, that facility ought to reflect the true state of linking within articles, and not be hidden within some boolean code that is switched not to show the link even though one exists. --
Ohc
¡digame! 20:07, 20 November 2018 (UTC)
@ Tony1 and Ohconfucius: Is it still desirable to implement this? Would User:Ohconfucius/script/Common Terms.js be an appropriate base for the module code? Jc86035 ( talk) 16:32, 30 December 2018 (UTC)
... American [[psychologist]] and [[writer]] [[William Moulton Marston]] and [[artist]] [[Harry G. Peter]] ...
. Whatever scheme I create, I expect there to be some push-back over either linking or not linking any particular item.@ Tony and Jc86035: I've made a demo of automatic unlinking in Module:WikidataIB/sandbox. This relies on Module:WikidataIB/nolinks for a list of article titles that won't be linked. It should be simple enough to add or remove items from that list, even for someone who has no knowledge of Lua (the items are just like comma-separated values in quotes). Here's a demonstration:
Article | Code | Result |
---|---|---|
Paris (Q90) | {{#invoke:WikidataIB/sandbox |getValue |qid=Q90 |P17 |fwd=ALL |osd=n |rank=b}} |
France |
London (Q84) | {{#invoke:WikidataIB/sandbox |getValue |qid=Q84 |P17 |fwd=ALL |osd=n |rank=b}} |
United Kingdom |
Ouagadougou (Q3777) | {{#invoke:WikidataIB/sandbox |getValue |qid=Q3777 |P17 |fwd=ALL |osd=n |rank=b}} |
Burkina Faso |
The list of items that are not to be linked can be displayed like this:
{{#invoke:WikidataIB/sandbox |showNoLinks}}
→ Australia; Austria; Belgium; Canada; China; Denmark; England; France; Germany; Greece; Hungary; Iceland; India; Israel; Italy; Jamaica; Japan; Luxembourg; Mexico; Netherlands; New Zealand; Northern Ireland; Norway; Poland; Portugal; Republic of Ireland; Russia; Scotland; South Africa; Spain; Sweden; Switzerland; Turkey; UK; USA; United Kingdom; United States; WalesI've only included a few dozen common countries in the list for demonstration purposes, but it can be expanded essentially as large as folks want, and doesn't have to be limited to any particular topic. The module WikidataIB does process dates as needed, but never links them. We didn't fight all those battles in the date-delinking wars just to see date linking return by the back-door! -- RexxS ( talk) 19:13, 1 January 2019 (UTC)
This
edit request to
Module:WikidataIB has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Please change,
local _getSitelink = function(qid, wiki)
qid = (qid or ""):upper()
if qid == "" then return nil end
wiki = wiki or ""
local sitelink
to
local _getSitelink = function(qid, wiki)
qid = (qid or ""):upper()
if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end
if not qid then return nil end
wiki = wiki or ""
local sitelink
It is useful for local wiki in other language to check if the current page in local wiki has sitelink on enwiki or not.
PS. I also need to get all sitelinks of the page, but don't know how. -- Ans ( talk) 14:42, 14 February 2019 (UTC)
local entity = mw.wikibase.getEntity(qid)
if not entity then return i18n"entity-not-found" end
local sitelinks = entity.sitelinks
if not sitelinks then return i18n"sitelinks-not-found" end
for k, v in pairs(sitelinks) do
-- do some processing here
end
"sitelinks" = table#6 {
metatable = table#7
"enwiki" = table#8 {
"badges" = table#9 {
},
"site" = "enwiki",
"title" = "Allison Guyot",
},
},
Hi. As it seems like Wikidata doesn't support Alt Text yet (please correct me if I'm wrong), is it possible to set ImageLegend as alt text on this module? So that infobox images from wikidata show some alt text (even though it may not be entirely in context)? Kind regards, Reh man 11:57, 7 March 2019 (UTC)
After importing to tewiki, the module page has the following problems 1) Documentation does not get transcluded (Whereas for Module:Wikidata, there is no such error) 2) Hidden category: Pages with script errors is added. 3) The pages/templates/modules being used, when trying to edit shows some pages of English and some modules which do not exist in enwiki. 4) Category included in Telugu shows that the template size is exceeded.Is it that Telugu script requiring more bytes per character/glyph, is causing the limits to be exceeded? Request help, as we plan to increase usage of wikidata. Arjunaraoc ( talk) 09:51, 4 May 2019 (UTC)
Module:Calendar has been nominated for deletion. You are invited to comment on the discussion at the module's entry on the Templates for discussion page. * Pppery * it has begun... 21:09, 28 May 2019 (UTC)
iPadOS is in Category:Pages with script errors due to "Lua error in Module:WikidataIB at line 476: attempt to index field 'datavalue' (a nil value)" which can only be seen by parsing the HTML source. It looks the cause is the fact that the article has an incomplete topic's main category (P910) with no datavalue. However, yet another test in the module might be in order to avoid the error? Johnuniq ( talk) 08:06, 9 June 2019 (UTC)
local tmcid = prop910.mainsnak.datavalue.value.id
tolocal tmcid = prop910.mainsnak.datavalue and prop910.mainsnak.datavalue.value.id
I'm guessing that the module maintainers might be unaware of this? The WMDE developers have been working on mw:Wikidata Bridge, which will allow some Wikidata statements to be edited directly through infoboxes and other templates. There's currently a semi-interactive prototype. I think it would be useful for the module maintainers to provide feedback, if there are any issues that haven't already been addressed.
There's an early draft of a documentation page that might help explain how the software's supposed to be enabled inside template code. Jc86035 ( talk) 08:31, 3 July 2019 (UTC)
<span>...</span>
in that function. Cheers --
RexxS (
talk) 23:21, 3 July 2019 (UTC)The use of #invoke:String2 | sentence to convert #invoke:WikidataIB also has the effect of converting the image filename to lowercase, so causing mis-formatting.
{{#invoke:String2 | sentence | {{#invoke:WikidataIB |getValue |P136 |name=genre |fetchwikidata=ALL |onlysourced=false}} }}
Roman à clef, satirical fiction, fable, dystopian fiction
i.e. File:OOjs UI icon edit-ltr-progressive.svg not File:Oojs_ui_icon_edit-ltr-progressive.svg
As there a way to fix this? It's showing up throughout infoboxes currently. T.Shafee(Evo&Evo) talk 04:58, 20 June 2019 (UTC)
String2|ucfirst
in cases where you can't be sure that the text won't contain other necessary upper case characters (the sentence function forces all of the characters beyond the first into lower case). Thanks for spotting this. --
RexxS (
talk) 09:31, 20 June 2019 (UTC)String2 | sentence
but String2 | ucfirst
instead if we want the first letter capitalised. --
RexxS (
talk) 17:02, 7 August 2019 (UTC)@ RexxS: noticed your recent edit mentioned date formatting. Do you think you might ever implement "automatic date formatting" like CS1 templates now do when date format maintenance templates are present? -- ferret ( talk) 16:37, 7 August 2019 (UTC)
| df = mdy
parameter to a Wikidata-aware infobox to get US-format dates, as long as the infobox coder has used something like {{#invoke:WikidataIB | ... |df={{{df|}}} ... }}}
when coding each Wikidata call that might return a date. I'll take a harder look at
Module:Citation and see if there are any tricks to reduce the cost. Cheers --
RexxS (
talk) 16:52, 7 August 2019 (UTC){{
Use mdy dates}}
. The extra overhead from the tests was swamped by the poorly optimised Lua already in there, but it's nowhere near the limits anyway. it looks like it's feasible to add to WikidataIB, so I'll try and work on it in the WikidataIB/sandbox while I'm at the hackathon at Wikimania next week. Cheers --
RexxS (
talk) 20:36, 7 August 2019 (UTC)
Recent code change returns incorrect disambiguated sitelink for example the code below returns
{{#invoke:WikidataIB|getValue|P102|fetchwikidata=ALL|name=party|maxvals=1|onlysourced=false|qid=Q6294|noicon=yes}}
→
Democratic Party
instead of
{{#invoke:WikidataIB|getValue|P102|fetchwikidata=ALL|name=party|maxvals=1|onlysourced=false|qid=Q6294|noicon=yes}}
→
Democratic Party
An example of a testcase from another wiki can be found
here (with the sandbox using the current version of the module).--
Lam-ang (
talk) 14:30, 8 August 2019 (UTC)
{{#invoke:WikidataIB |getValue |P102 |fwd=ALL |name=party |maxvals=1 |osd=f |qid=Q6294 |noicon=y}}
→
Democratic PartyWould it be possible to make the getValue function be accessible from module calls? -- Gonnym ( talk) 15:54, 9 August 2019 (UTC)
local getValue = require("Module:WikidataIB/sandbox")._getValue
getValue
as a function in your module. It takes a single parameter, a table of arguments that are the parameters used in getValue as in the documentation. You might construct the table like this:
args = { "P31", fwd="ALL", osd="no" }
str = getValue(args) or ""
Could this new function also be made accessible from module calls? -- Gonnym ( talk) 17:59, 12 August 2019 (UTC)
Is it possible to display references for properties obtained from Wikidata? It seems a waste to have the references there unless they can be used on Wikipedia. If this is possible, please point me to the appropriate documentation. Thanks — Martin ( MSGJ · talk) 07:20, 4 October 2019 (UTC)
Most infobox invocations don't set qid, which makes it default to the associated Wikidata entry of the current page. There are cases when a child infobox must use a different Wikidata entry; this is done by setting qid=CHILD_ENTITY_ID in the child infobox. However, sometimes the child infobox does not yet have a corresponding Wikidata entry, so there's no CHILD_ENTITY_ID to use. Leaving qid empty in this case is wrong, as the child infobox gets erroneously populated by values from the wrong Wikidata entry. We can specify fetchwikidata=NONE to prevent it from fetching anything, but it will still display an "[edit on Wikidata]" link to the wrong Wikidata entry.
Consider Gennadiy Borisov, an article about an amateur astronomer. His one-man personal observatory is not notable enough to warrant a separate article, so {{infobox observatory}} is embedded inside {{infobox person}}. The observatory does not have a Wikidata entry either, so there's no qid to set. Setting fetchwikidata=NONE does not remove the erroneous "[edit on Wikidata]" link to Gennady Borisov (Q67389917) under the observatory data. Plus, if {{infobox person}} ever gets its own Wikidata link, there will be two links to the same Wikidata entry. Mike Peel has solved the problem for {{infobox observatory}} by making it hide the "[edit on Wikidata]" link when fetchwikidata=NONE (see diff). However, the problem has to be solved in the general case.
I propose a new setting, qid=none, to completely disable Wikidata for a specific infobox invocation. With qid=none, getValue will return the second unnamed parameter (even if it's empty), {{EditOnWikidata}} will return an empty string, Module:Wikidata's ViewSomething will return an empty string, and so on. — UnladenSwallow ( talk) 20:23, 8 October 2019 (UTC)
qid=none
in the module, it would function exactly as fetchwikidata=NONE
and the template would still display [edit on Wikidata]. That is all down to how the template is coded and there is no "general case", sorry. --
RexxS (
talk) 03:00, 12 October 2019 (UTC)This is an archive of past discussions. Do not edit the contents of this page. If you wish to start a new discussion or revive an old one, please do so on the current talk page. |
Archive 1 | Archive 2 | Archive 3 | Archive 4 | Archive 5 | Archive 6 | → | Archive 8 |
I've added a new function to the sandbox to get the aliases for an entity. This is an expensive call if arbitrary access is used.
The function getAliases has the qid of a Wikidata entity passed as |qid=
(it defaults to the associated qid of the current article if omitted), and a local parameter passed as the first unnamed parameter. It implements blacklisting and whitelisting with a field name of "alias" by default. Any local parameter passed becomes the return value, subject to the blacklisting of "alias".
It returns the aliases for the Wikidata entity with the usual list options, and nothing is returned if the aliases do not exist.
Examples and test cases are at Module talk:WikidataIB/sandbox/testing #getAliases. It may be useful for infoboxes that have an "alternative names" field. -- RexxS ( talk) 19:51, 14 November 2018 (UTC)
Would it be possible to generate citations (i.e. <ref name="-wd-Q56813023">[transcluded data]</ref>
) using this module? I think this would be useful in infoboxes since Wikidata references are usually different to the sources used directly in articles. The French Wikipedia has something similar but it seems to be somewhat less developed and creates duplicates where the same source is used multiple times. {{
Cite Q}} exists but it's not entirely Lua-based.
Jc86035 (
talk) 15:58, 17 November 2018 (UTC)
I have also noted that French WP automatically creates archive links. It would help reducing the problem of linkrot here, and simplify the referencing work of en.wp editors. -- Ohc ¡digame! 11:22, 18 November 2018 (UTC)
How can the multipliers like "million" been localized? Do I have to translate something for that or create a file in the directory I18n if I want to use it in another language than English?
For example
{{#invoke:WikidataIB |getValue |qid=Q684773 |P1436 |rank=b |fwd=ALL |osd=n |scale=6 |uabbr=y}}
results (independently of the language) into "9.444 million ", see als:ETH-Bibliothek. -- Zuphilip ( talk) 12:17, 31 December 2018 (UTC)
local i18n =
{
...
"multipliers" = {
0 = "",
3 = " thousand",
6 = " million",
9 = " billion",
12 = " trillion",
}
}
@ RexxS: In the short-to-medium term, would it be possible/desirable to enable calling this module from other Lua modules? I've tried making a Lua/Wikidata infobox ( code, test) which calls data from multiple items, and presumably this would be quite difficult in wikitext. I don't really know how this module works so I haven't tried to touch it. I'm not anticipating actually making use of this just yet, but maybe in a few months to a few years.
For context on why I would want to call multiple items: Other music databases tend to indicate music releases, compositions and tracks as separate entities, but Wikidata has lumped them all together through infobox imports. There are a few thousand items which aren't lumped together like this (so this infobox would only work with those items). There is no real consensus for using either method in Wikidata. (Related: draft RfC (by me); most recent discussion.) Presumably this would also be useful for things like going up an administrative subdivision tree. Jc86035 ( talk) 09:39, 30 December 2018 (UTC)
require()
function. So it should not be much of a problem to write a bespoke module that picks up several properties and/or qualifiers and assembles them internally into an infobox (or any other wikitext).{{infobox
| above = {{#invoke:WikidataIB |getLabel |qid={{{qid|}}} }}
| label1 = Language
| data1 = {{#invoke:WikidataIB |getValue |rank=best |P407 |name=language |qid={{{qid|}}} |fetchwikidata={{{fetchwikidata|}}} |onlysourced={{{onlysourced|}}} |{{{lang|}}} }}
| label2 = Artist
| data2 = {{#invoke:WikidataIB |getValue |rank=best |P175 |name=artist |qid={{{qid|}}} |fetchwikidata={{{fetchwikidata|}}} |onlysourced={{{onlysourced|}}} |{{{artist|}}} }}
| label3 = ISWC
| data3 = {{#invoke:WikidataIB |getValue |rank=best |P1827 |name=iswc |qid={{{qid|}}} |fetchwikidata={{{fetchwikidata|}}} |onlysourced={{{onlysourced|}}} |{{{iswc|}}} }}
}}
|fetchwikidata=
, |suppressfields=
and |onlysourced=
control that behaviour.I integrated the module in Template:Infobox_library and now an Lua-error occur when the qual-parameter is used in combination with osd=yes for not sourced statements, e.g.:
{{#invoke:WikidataIB |getValue |qid=Q1200925 |P1436 |rank=b |qual=P585 |fwd=ALL |osd=yes |{{{collection_size|}}} }}
← [edit: was giving an error]
Can someone fix this? Ping User:RexxS (I would expect that for the case that only sourced statements are allowed and the current statement is not sourced around line 1087 we would "continue" the loop with the next possible statement and not just leave out one assignment, but I haven't look closer...) -- Zuphilip ( talk) 07:26, 2 January 2019 (UTC)
{{#invoke:WikidataIB |getValue |qid=Q1200925 |P1436 |rank=b |fwd=ALL |osd=no |{{{collection_size|}}} }}
→ 4,401,625 unit, 72 terabyte, 63,800 linear metre
{{#invoke:WikidataIB |getValue |qid=Q1200925 |P1436 |rank=b |qual=P585 |fwd=ALL |osd=no |{{{collection_size|}}} }}
→ 4,401,625 unit (2020), 72 terabyte (2019), 63,800 linear metre (2019)
{{#invoke:WikidataIB |getValue |qid=Q1200925 |P1436 |rank=b |qual=P585 |fwd=ALL |osd=no |qualsonly=yes |{{{collection_size|}}} }}
→ 2020, 2019, 2019
{{#invoke:WikidataIB |getValue |qid=Q1200925 |P1436 |rank=b |qual=P585 |fwd=ALL |osd=yes |{{{collection_size|}}} }}
→{{#invoke:WikidataIB |getValue |qid=Q1200925 |P1436 |rank=b |qual=P585 |fwd=ALL |osd=yes |qualsonly=yes |{{{collection_size|}}} }}
→Would it be technically possible to automatically not link some common pages (e.g. Painting, Canada) based on a list of articles or a list of QIDs? I think it would be possible but I'm not sure how it would be implemented in this module. Tony1 seems to have asked for something like this on Meta. Jc86035 ( talk) 10:41, 17 November 2018 (UTC)
What links here
button in the sidebar. For me, that facility ought to reflect the true state of linking within articles, and not be hidden within some boolean code that is switched not to show the link even though one exists. --
Ohc
¡digame! 20:07, 20 November 2018 (UTC)
@ Tony1 and Ohconfucius: Is it still desirable to implement this? Would User:Ohconfucius/script/Common Terms.js be an appropriate base for the module code? Jc86035 ( talk) 16:32, 30 December 2018 (UTC)
... American [[psychologist]] and [[writer]] [[William Moulton Marston]] and [[artist]] [[Harry G. Peter]] ...
. Whatever scheme I create, I expect there to be some push-back over either linking or not linking any particular item.@ Tony and Jc86035: I've made a demo of automatic unlinking in Module:WikidataIB/sandbox. This relies on Module:WikidataIB/nolinks for a list of article titles that won't be linked. It should be simple enough to add or remove items from that list, even for someone who has no knowledge of Lua (the items are just like comma-separated values in quotes). Here's a demonstration:
Article | Code | Result |
---|---|---|
Paris (Q90) | {{#invoke:WikidataIB/sandbox |getValue |qid=Q90 |P17 |fwd=ALL |osd=n |rank=b}} |
France |
London (Q84) | {{#invoke:WikidataIB/sandbox |getValue |qid=Q84 |P17 |fwd=ALL |osd=n |rank=b}} |
United Kingdom |
Ouagadougou (Q3777) | {{#invoke:WikidataIB/sandbox |getValue |qid=Q3777 |P17 |fwd=ALL |osd=n |rank=b}} |
Burkina Faso |
The list of items that are not to be linked can be displayed like this:
{{#invoke:WikidataIB/sandbox |showNoLinks}}
→ Australia; Austria; Belgium; Canada; China; Denmark; England; France; Germany; Greece; Hungary; Iceland; India; Israel; Italy; Jamaica; Japan; Luxembourg; Mexico; Netherlands; New Zealand; Northern Ireland; Norway; Poland; Portugal; Republic of Ireland; Russia; Scotland; South Africa; Spain; Sweden; Switzerland; Turkey; UK; USA; United Kingdom; United States; WalesI've only included a few dozen common countries in the list for demonstration purposes, but it can be expanded essentially as large as folks want, and doesn't have to be limited to any particular topic. The module WikidataIB does process dates as needed, but never links them. We didn't fight all those battles in the date-delinking wars just to see date linking return by the back-door! -- RexxS ( talk) 19:13, 1 January 2019 (UTC)
This
edit request to
Module:WikidataIB has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Please change,
local _getSitelink = function(qid, wiki)
qid = (qid or ""):upper()
if qid == "" then return nil end
wiki = wiki or ""
local sitelink
to
local _getSitelink = function(qid, wiki)
qid = (qid or ""):upper()
if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end
if not qid then return nil end
wiki = wiki or ""
local sitelink
It is useful for local wiki in other language to check if the current page in local wiki has sitelink on enwiki or not.
PS. I also need to get all sitelinks of the page, but don't know how. -- Ans ( talk) 14:42, 14 February 2019 (UTC)
local entity = mw.wikibase.getEntity(qid)
if not entity then return i18n"entity-not-found" end
local sitelinks = entity.sitelinks
if not sitelinks then return i18n"sitelinks-not-found" end
for k, v in pairs(sitelinks) do
-- do some processing here
end
"sitelinks" = table#6 {
metatable = table#7
"enwiki" = table#8 {
"badges" = table#9 {
},
"site" = "enwiki",
"title" = "Allison Guyot",
},
},
Hi. As it seems like Wikidata doesn't support Alt Text yet (please correct me if I'm wrong), is it possible to set ImageLegend as alt text on this module? So that infobox images from wikidata show some alt text (even though it may not be entirely in context)? Kind regards, Reh man 11:57, 7 March 2019 (UTC)
After importing to tewiki, the module page has the following problems 1) Documentation does not get transcluded (Whereas for Module:Wikidata, there is no such error) 2) Hidden category: Pages with script errors is added. 3) The pages/templates/modules being used, when trying to edit shows some pages of English and some modules which do not exist in enwiki. 4) Category included in Telugu shows that the template size is exceeded.Is it that Telugu script requiring more bytes per character/glyph, is causing the limits to be exceeded? Request help, as we plan to increase usage of wikidata. Arjunaraoc ( talk) 09:51, 4 May 2019 (UTC)
Module:Calendar has been nominated for deletion. You are invited to comment on the discussion at the module's entry on the Templates for discussion page. * Pppery * it has begun... 21:09, 28 May 2019 (UTC)
iPadOS is in Category:Pages with script errors due to "Lua error in Module:WikidataIB at line 476: attempt to index field 'datavalue' (a nil value)" which can only be seen by parsing the HTML source. It looks the cause is the fact that the article has an incomplete topic's main category (P910) with no datavalue. However, yet another test in the module might be in order to avoid the error? Johnuniq ( talk) 08:06, 9 June 2019 (UTC)
local tmcid = prop910.mainsnak.datavalue.value.id
tolocal tmcid = prop910.mainsnak.datavalue and prop910.mainsnak.datavalue.value.id
I'm guessing that the module maintainers might be unaware of this? The WMDE developers have been working on mw:Wikidata Bridge, which will allow some Wikidata statements to be edited directly through infoboxes and other templates. There's currently a semi-interactive prototype. I think it would be useful for the module maintainers to provide feedback, if there are any issues that haven't already been addressed.
There's an early draft of a documentation page that might help explain how the software's supposed to be enabled inside template code. Jc86035 ( talk) 08:31, 3 July 2019 (UTC)
<span>...</span>
in that function. Cheers --
RexxS (
talk) 23:21, 3 July 2019 (UTC)The use of #invoke:String2 | sentence to convert #invoke:WikidataIB also has the effect of converting the image filename to lowercase, so causing mis-formatting.
{{#invoke:String2 | sentence | {{#invoke:WikidataIB |getValue |P136 |name=genre |fetchwikidata=ALL |onlysourced=false}} }}
Roman à clef, satirical fiction, fable, dystopian fiction
i.e. File:OOjs UI icon edit-ltr-progressive.svg not File:Oojs_ui_icon_edit-ltr-progressive.svg
As there a way to fix this? It's showing up throughout infoboxes currently. T.Shafee(Evo&Evo) talk 04:58, 20 June 2019 (UTC)
String2|ucfirst
in cases where you can't be sure that the text won't contain other necessary upper case characters (the sentence function forces all of the characters beyond the first into lower case). Thanks for spotting this. --
RexxS (
talk) 09:31, 20 June 2019 (UTC)String2 | sentence
but String2 | ucfirst
instead if we want the first letter capitalised. --
RexxS (
talk) 17:02, 7 August 2019 (UTC)@ RexxS: noticed your recent edit mentioned date formatting. Do you think you might ever implement "automatic date formatting" like CS1 templates now do when date format maintenance templates are present? -- ferret ( talk) 16:37, 7 August 2019 (UTC)
| df = mdy
parameter to a Wikidata-aware infobox to get US-format dates, as long as the infobox coder has used something like {{#invoke:WikidataIB | ... |df={{{df|}}} ... }}}
when coding each Wikidata call that might return a date. I'll take a harder look at
Module:Citation and see if there are any tricks to reduce the cost. Cheers --
RexxS (
talk) 16:52, 7 August 2019 (UTC){{
Use mdy dates}}
. The extra overhead from the tests was swamped by the poorly optimised Lua already in there, but it's nowhere near the limits anyway. it looks like it's feasible to add to WikidataIB, so I'll try and work on it in the WikidataIB/sandbox while I'm at the hackathon at Wikimania next week. Cheers --
RexxS (
talk) 20:36, 7 August 2019 (UTC)
Recent code change returns incorrect disambiguated sitelink for example the code below returns
{{#invoke:WikidataIB|getValue|P102|fetchwikidata=ALL|name=party|maxvals=1|onlysourced=false|qid=Q6294|noicon=yes}}
→
Democratic Party
instead of
{{#invoke:WikidataIB|getValue|P102|fetchwikidata=ALL|name=party|maxvals=1|onlysourced=false|qid=Q6294|noicon=yes}}
→
Democratic Party
An example of a testcase from another wiki can be found
here (with the sandbox using the current version of the module).--
Lam-ang (
talk) 14:30, 8 August 2019 (UTC)
{{#invoke:WikidataIB |getValue |P102 |fwd=ALL |name=party |maxvals=1 |osd=f |qid=Q6294 |noicon=y}}
→
Democratic PartyWould it be possible to make the getValue function be accessible from module calls? -- Gonnym ( talk) 15:54, 9 August 2019 (UTC)
local getValue = require("Module:WikidataIB/sandbox")._getValue
getValue
as a function in your module. It takes a single parameter, a table of arguments that are the parameters used in getValue as in the documentation. You might construct the table like this:
args = { "P31", fwd="ALL", osd="no" }
str = getValue(args) or ""
Could this new function also be made accessible from module calls? -- Gonnym ( talk) 17:59, 12 August 2019 (UTC)
Is it possible to display references for properties obtained from Wikidata? It seems a waste to have the references there unless they can be used on Wikipedia. If this is possible, please point me to the appropriate documentation. Thanks — Martin ( MSGJ · talk) 07:20, 4 October 2019 (UTC)
Most infobox invocations don't set qid, which makes it default to the associated Wikidata entry of the current page. There are cases when a child infobox must use a different Wikidata entry; this is done by setting qid=CHILD_ENTITY_ID in the child infobox. However, sometimes the child infobox does not yet have a corresponding Wikidata entry, so there's no CHILD_ENTITY_ID to use. Leaving qid empty in this case is wrong, as the child infobox gets erroneously populated by values from the wrong Wikidata entry. We can specify fetchwikidata=NONE to prevent it from fetching anything, but it will still display an "[edit on Wikidata]" link to the wrong Wikidata entry.
Consider Gennadiy Borisov, an article about an amateur astronomer. His one-man personal observatory is not notable enough to warrant a separate article, so {{infobox observatory}} is embedded inside {{infobox person}}. The observatory does not have a Wikidata entry either, so there's no qid to set. Setting fetchwikidata=NONE does not remove the erroneous "[edit on Wikidata]" link to Gennady Borisov (Q67389917) under the observatory data. Plus, if {{infobox person}} ever gets its own Wikidata link, there will be two links to the same Wikidata entry. Mike Peel has solved the problem for {{infobox observatory}} by making it hide the "[edit on Wikidata]" link when fetchwikidata=NONE (see diff). However, the problem has to be solved in the general case.
I propose a new setting, qid=none, to completely disable Wikidata for a specific infobox invocation. With qid=none, getValue will return the second unnamed parameter (even if it's empty), {{EditOnWikidata}} will return an empty string, Module:Wikidata's ViewSomething will return an empty string, and so on. — UnladenSwallow ( talk) 20:23, 8 October 2019 (UTC)
qid=none
in the module, it would function exactly as fetchwikidata=NONE
and the template would still display [edit on Wikidata]. That is all down to how the template is coded and there is no "general case", sorry. --
RexxS (
talk) 03:00, 12 October 2019 (UTC)