Module talk:Wd/Archive 1
This is an archive of past discussions about Module:Wd. 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 |
Bug
I tried to use the template on the Sandbox, and it had a bug. It said Code Error. The command "command1" does not work David Dylan (talk) 23:04, 22 January 2017 (UTC)
- The problem appears to be that previewing
{{#invoke:wd|label}}
gives error "The time allocated for running scripts has expired." The documentation at {{wikidata}} says that{{wikidata|label}}
should work, but it gives the same error. If you see some other error, please post the wikitext that was used and a copy of the resulting message. Johnuniq (talk) 00:23, 23 January 2017 (UTC) - The problem is the following code:
function p._label(args, _) -- ... while _:processFlag(nextArg) do nextArg = mw.text.trim(args[nextIndex] or "") nextIndex = nextIndex + 1 end -- ... end
- The
processFlag
function returns true ifnextArg
is an empty string, and that gives an infinite loop. A cleaner way of processing the arguments is needed. - While finding this, I noticed
frame = frame:getParent() or frame
- in
p.main(frame)
. Possibly the intention is that a module could callmain
and pass a table of arguments, but if that occurred, the above would give a run time error becausegetParent
would very likely be nil, so calling it would fail. Using Module:Arguments might be easiest, although I find it confusing—see Module talk:Arguments#Using ipairs. Johnuniq (talk) 01:26, 23 January 2017 (UTC)- Thank you for reporting this bug. I've created a fix for it. The problem was introduced when I started allowing empty flags, without thinking about what this would do with the call to
processFlag
. Needless to say, it was not thoroughly tested. - Regarding
frame = frame:getParent() or frame
: ifframe:getParent()
returns nil, then theor
will assign the currentframe
instead, so I don't think this is an issue. I've copied this piece from another module. Nevertheless, I will have a look at Module:Arguments as you suggested. Thank you. Thayts ••• 21:15, 2 February 2017 (UTC)- The point is that another module might call
main(args)
in this module, and the other module would passargs
which is a table of arguments to specify what is wanted. Because it is just a standard table, it will have nogetParent
member so when this module tries to executegetParent()
it will be trying to call a nil value, and that will result in a crash. Module:Arguments does a bunch of tricky stuff so it works with a frame or a table. Unfortunately it requires rather unappealing procedures. Johnuniq (talk) 05:00, 3 February 2017 (UTC)- I see. The
main
function is not meant to be called by other modules, however, but by templates. Modules should call the functions beginning with underscores_
directly. Thayts ••• 05:59, 3 February 2017 (UTC)- OK, I was just guessing about the intention of using
frame:getParent() or frame
. If it is assumedmain(frame)
is called as the result of using{{#invoke:...}}
(either directly or via a template), there is no wayframe:getParent()
can be nil. The nil result only occurs if a module callsgetParent
twice (that is, if a module attempts to get the parent of the parent). I would have to set up a sandbox with a test to prove that but I believe I convinced myself that is how it works when starting on Lua. Johnuniq (talk) 07:01, 3 February 2017 (UTC)- Without the
getParent
I have had situations where it didn't work. But the module has changed a lot since then so I'm not sure if it is really necessary. I think I will test a bit again without it. - By the way, even if the parent of the parent is nil, then the
or frame
will always assure that that nil value is never assigned. Thayts ••• 16:04, 3 February 2017 (UTC)- I haven't looked at frame/parent stuff for a while so I made some tests. See User talk:Johnuniq/temp which displays the results of calling a template which invokes a module, and directly invoking the module.
frame:getParent()
is only nil when trying to get the parent of the parent. Johnuniq (talk) 05:54, 4 February 2017 (UTC)- Your example helped me understand how it works. So yeah, I definitely need the
getParent
. Themain
function is just nothing more than a necessary evil, so that things like templates can actually call the other functions. If you are able to call one of the other functions directly, then you should. Only usemain
if you have to. The only use case I currently see is the {{wikidata}} template, for which one would expect that arguments passed to that template are the actual arguments that will be used. Since a regular template does not take any arguments from any parents either, I'd like to keep it simple and mimic that behaviour, not worrying about arguments passed by other parents. Thayts ••• 15:58, 5 February 2017 (UTC)
- Your example helped me understand how it works. So yeah, I definitely need the
- I haven't looked at frame/parent stuff for a while so I made some tests. See User talk:Johnuniq/temp which displays the results of calling a template which invokes a module, and directly invoking the module.
- Without the
- OK, I was just guessing about the intention of using
- I see. The
- The point is that another module might call
- Thank you for reporting this bug. I've created a fix for it. The problem was introduced when I started allowing empty flags, without thinking about what this would do with the call to
Reference names
Hi there. Is there a way to define the names (as in <ref name="blah" />) for the references imported from Wikidata, so that we can avoid having duplicate refs in articles where they have been locally defined and defined on Wikidata? Thanks. Mike Peel (talk) 15:08, 29 January 2017 (UTC)
- Hi Mike Peel. No, not at the moment. However, references that have been imported from Wikidata using this module more than once on the same page do have a common name and will not be duplicated. Thayts ••• 21:23, 2 February 2017 (UTC)
- Hi @Thayts: I've been testing this at Juana Rosa Aguirre, and it seems to be working nicely. However, in most cases the reference will already exist in the article, and it's not good to have duplicate refs. I don't suppose something like short name (P1813) could be used to define the names of the refs so that we can avoid those duplications? Thanks. Mike Peel (talk) 21:40, 3 February 2017 (UTC)
- The problem with that is that there is no reliable way to say which reference imported from Wikidata should get that name. A claim in Wikidata can have more than one reference, even stored in arbitrary order, namely. The names this module is currently assigning to references are hash values that are (or are supposed to be) unique per set of properties that make up one reference. You could perhaps propose to make it possible to replace a particular hash value by a custom value in this module's output. You could also do it the other way around: hovering over the footnote number of a reference returned by this module to see its name (in this module's case it starts with "wikidata" followed by a hash value) and then assigning that name to the already existing reference. Yet this still isn't reliable, since details of references on Wikidata are subject to change and will cause the hash value to change too as a result. What is reliable is to replace the already existing references with the ones imported from Wikidata using
{{wikidata|references|Pxxx}}
. Would that work for you? Thayts ••• 16:54, 5 February 2017 (UTC)
- The problem with that is that there is no reliable way to say which reference imported from Wikidata should get that name. A claim in Wikidata can have more than one reference, even stored in arbitrary order, namely. The names this module is currently assigning to references are hash values that are (or are supposed to be) unique per set of properties that make up one reference. You could perhaps propose to make it possible to replace a particular hash value by a custom value in this module's output. You could also do it the other way around: hovering over the footnote number of a reference returned by this module to see its name (in this module's case it starts with "wikidata" followed by a hash value) and then assigning that name to the already existing reference. Yet this still isn't reliable, since details of references on Wikidata are subject to change and will cause the hash value to change too as a result. What is reliable is to replace the already existing references with the ones imported from Wikidata using
- Hi @Thayts: I've been testing this at Juana Rosa Aguirre, and it seems to be working nicely. However, in most cases the reference will already exist in the article, and it's not good to have duplicate refs. I don't suppose something like short name (P1813) could be used to define the names of the refs so that we can avoid those duplications? Thanks. Mike Peel (talk) 21:40, 3 February 2017 (UTC)
Substing {{Wikidata}}
How would one go about using subst: functionality with {{Wikidata}}?--Pharos (talk) 04:44, 10 April 2017 (UTC)
- See Template:Convert for what is needed in the template. Johnuniq (talk) 05:52, 10 April 2017 (UTC)
- {{Convert}} uses subst technically, yes, but what I want to do is actually substitute the output in plain wikitext, like have "Douglas Adams" be viewable under 'edit source' on User:Pharos/sandbox.--Pharos (talk) 15:13, 10 April 2017 (UTC)
- user:Pharos, that's what he meant too... diff. --Jeremyb (talk) 18:06, 10 April 2017 (UTC)
- Oh, thanks for that diff which shows that
{{subst:wikidata|property|Q55|P1549}}
→ Dutch (and two other examples). It seems it is possible to subst {{wikidata}} but I assumed from the OP that something bad happened if you tried. Convert used to be broken when substituted before the magic{{{♥|safesubst:}}}
was inserted into the template. Historians can see the addition in the history of {{Convert/sandboxlua}} which followed this VPT request. Johnuniq (talk) 01:45, 11 April 2017 (UTC)
- Oh, thanks for that diff which shows that
- user:Pharos, that's what he meant too... diff. --Jeremyb (talk) 18:06, 10 April 2017 (UTC)
- {{Convert}} uses subst technically, yes, but what I want to do is actually substitute the output in plain wikitext, like have "Douglas Adams" be viewable under 'edit source' on User:Pharos/sandbox.--Pharos (talk) 15:13, 10 April 2017 (UTC)
Merge duplicate refs?
E.g. at Liverpool Maritime Mercantile City, the references for the criteria in the infobox are duplicated three times, since there are three entries for the property on Wikidata each with the same reference. Can the three be merged together rather than appearing separately, please? Thanks. Mike Peel (talk) 00:18, 1 May 2017 (UTC)
- @Mike Peel: Nice catch! I've created a fix for it. Thanks, Thayts ••• 12:55, 1 May 2017 (UTC)
- That's perfect, thanks! Mike Peel (talk) 19:19, 1 May 2017 (UTC)
Returning just the unit of measurement?
@Thayts: Using the example provided in the documentation, is it possible to return just volt
instead of 230 volt
or 230 volt
? This would be helpful for the template Wikidata revenue I'm working on. Thanks, --eh bien mon prince (talk) 02:11, 27 August 2017 (UTC)
- @Underlying lk: I've added the
unit
flag which gives you exactly what you need. :) Thayts ••• 13:23, 28 August 2017 (UTC)- @Thayts: That's great, thanks. Now I'm trying to get the output to go from
United States dollar 1.5 billion
to$ 1.5 billion
. The easiest way is probably to reach United States dollar (Q4917) and fetch currency symbol description (P489) - would it be possible to return the Q-identifier of the unit?--eh bien mon prince (talk) 13:50, 28 August 2017 (UTC)- @Underlying lk: The
raw
flag now also works in combination with theunit
flag: {{wd|property| {{wd|property|unit|raw|Q312|P2139}} |P489}}
→ dollar sign- Thayts ••• 14:31, 28 August 2017 (UTC)
- Awesome, thanks again.--eh bien mon prince (talk) 14:43, 28 August 2017 (UTC)
- @Underlying lk: The
- @Thayts: That's great, thanks. Now I'm trying to get the output to go from
Is it possible to include vertical bar in format text?
I'm now trying to shorten the very lengthy template Module:Infobox gene by using this Wd template, at my personal space. This is very useful. Thank for your great code! My question is as follows. When I try to include vertical bar "|" in format-defining text, it doesn't work well. Even when I add escape "\", it is simply recognized as a separator (sample diff). If it worked well in that diff, I could get three "RNA expression pattern" graph images just like that in the infobox at the right, but it didn't work. Is there any special way to include vertical bar? --Was a bee (talk) 03:03, 3 September 2017 (UTC)
- @Was a bee: Try using {{!}}. Thanks. Mike Peel (talk) 10:56, 3 September 2017 (UTC)
- @Mike Peel: Oh, That works! Thank you very much! --Was a bee (talk) 14:43, 3 September 2017 (UTC)
- @Was a bee: Thanks for the compliment! Thayts ••• 15:30, 3 September 2017 (UTC)
Using {{Cite Q}}?
@Thayts: In cases where the reference is stated in (P248) pointing to a separate Wikidata entry with bibliographic information, would it be possible to fetch the reference info from that separate Q-number? Something like {{Cite Q}} does, e.g., Keith Christiansen; Elizabeth Cropper; Alessandro Zuccari; et al. (2001). "Orazio and Artemisia Gentileschi". New York City. Metropolitan Museum of Art. JSTOR 1358795. Wikidata Q29017598.. Is it possible to detect when only a Q-number is returned, and auto-call Cite Q in those cases? Thanks. Mike Peel (talk) 23:12, 7 July 2017 (UTC)
- @Mike Peel: I've implemented a call to {{Cite Q}}. It is only used if stated in (P248) is the only bit of information in the reference statement. {{Cite Q}} seems to be in beta itself and I think in the future both calls to {{Cite Q}} and {{Cite web}} should be replaced by a call to {{Citation}}. Thayts ••• 20:11, 8 July 2017 (UTC)
- @Thayts: That's fantastic, thanks! There are some errors coming up, but I think those are issues with the cite Q template so I'll report them on that talk page. I'm not fussed about the citation style so much as getting the data shown, but I'm sure other editors will start discussions on those at some point in the future. ;-) Thanks. Mike Peel (talk) 20:58, 8 July 2017 (UTC)
- @Mike Peel: I've made some improvements. Next to stated in (P248), properties like page(s) (P304) and chapter (P792) may now also be present and will be taken along in the call to {{Cite Q}}. Thayts ••• 21:39, 12 July 2017 (UTC)
- @Thayts: That's fantastic, thanks! There are some errors coming up, but I think those are issues with the cite Q template so I'll report them on that talk page. I'm not fussed about the citation style so much as getting the data shown, but I'm sure other editors will start discussions on those at some point in the future. ;-) Thanks. Mike Peel (talk) 20:58, 8 July 2017 (UTC)
@Mike Peel and Thayts: Instead of hard-coding the template names for {{Cite web}} and {{Cite Q}} into Module:Wd/i18n, would it not be better to just use Wikidata for this? For example using mw.wikibase.sitelink() on Template:Cite web (Q5637226) and Template:Cite Q (Q22321052). Then there is less to localize. 50.53.1.33 (talk) 17:16, 5 September 2017 (UTC)
- That's a nice suggestion. However, the parameters may be called differently on other wiki's as well and would still need to be localized. Thayts ••• 19:07, 5 September 2017 (UTC)
- I was not suggesting there would be nothing to localize—just less. I do not like maintaining multiple sets of the same data. When possible, I find it better if there is one origin for data and everything uses that. 50.53.1.33 (talk) 21:36, 5 September 2017 (UTC)
- Yes I agree. Therefore, I've implemented it as you suggested. Thayts ••• 15:00, 9 September 2017 (UTC)
- I was not suggesting there would be nothing to localize—just less. I do not like maintaining multiple sets of the same data. When possible, I find it better if there is one origin for data and everything uses that. 50.53.1.33 (talk) 21:36, 5 September 2017 (UTC)
Aliases and format
Hello again! I’m sorry to bother you, but I would be grateful if you could think about these 2 things.
1. Alias fetch command (d:Help:Aliases). For example, {{wikidata|alias}}
and {{wikidata|aliases}}
like "property" and "properties" commands.
2. Processing the output from "format" as wikitext. If evaluating "format" text as wikitext just after the replace of %p by value, I suppose it would make possible to use template, magicword or #if-text in "format" text.
I don't even know whether these things are possible or not, whether Lua thing or Mediawiki thing. If I am pointless, please forget about this! Thanks! --Was a bee (talk) 10:35, 17 September 2017 (UTC)
- I think my explanation about second part was not enough. So I put example. Although this is just an example, if getting data from d:Q21117967#P680 by the following code, it works very well.
{{wikidata|properties|Q21117967|P680|format=• %p|sep =<br/>}}
- • misfolded protein binding
• protein binding
• Hsp70 protein binding
• chaperone binding
- But if editor wants to modify the retrieved each values with template (for example {{Fixcaps}}), result is correct, but sad.
{{wikidata|properties|Q21117967|P680|format=• \{\{Fixcaps{{!}}%p\}\}|sep =<br/>}}
- • {{Fixcaps|misfolded protein binding}}
• {{Fixcaps|protein binding}}
• {{Fixcaps|Hsp70 protein binding}}
• {{Fixcaps|chaperone binding}} - --Was a bee (talk) 10:50, 17 September 2017 (UTC)
- Hi Was a bee! Not a problem at all, I'm glad to help out wherever I can. :)
- About your request number 1: I have added the
alias
/aliases
command now. That was a nice suggestion. - Request number 2 is a nice suggestion as well. It is possible, but I'm still figuring out what the best way to do this is. Expect another update soon!
- Thayts ••• 19:52, 20 September 2017 (UTC)
- @Thayts: I tested your new aliase command and that works nicely! It helps a lot. Thank you so much! On part '2, although I personally can't even imagine what kind of technology makes it possible, but I wait your coding! --Was a bee (talk) 02:45, 23 September 2017 (UTC)
- @Was a bee: Request number 2 has also been fulfilled now. You can see your example now works as expected. :) Thayts ••• 16:09, 29 September 2017 (UTC)
- @Thayts: I tested your new aliase command and that works nicely! It helps a lot. Thank you so much! On part '2, although I personally can't even imagine what kind of technology makes it possible, but I wait your coding! --Was a bee (talk) 02:45, 23 September 2017 (UTC)
- @Thayts: Sorry to intrude, but since this last edit was implemented I'm unable to use wikidata quantities in parser functions; for an example, try pasting
{{#ifexpr: {{Wikidata|property|raw|P3362}} < 0 | yes | no}}
in the ZiL article.--eh bien mon prince (talk) 16:58, 29 September 2017 (UTC)- @Underlying lk: Yes, unfortunately it is a breaking change for some use cases. But I believe encoding the output by default is something I should have done from the start. In cases where this is undesired, you can actually prevent it by using the new
plain
flag:{{#ifexpr: {{Wikidata|property|raw|plain|P3362}} < 0 | yes | no}}
. Does that help? Thayts ••• 17:03, 29 September 2017 (UTC)- It does, thank you!--eh bien mon prince (talk) 17:11, 29 September 2017 (UTC)
- @Underlying lk: You did give me something to improve. If there is a single dash as with negative numbers, then this will normally have no effect. Only if there are four dashes at the start of a line
----
, a horizontal rule will be placed. I have edited the module again so that it matches those four dashes exactly. In case of your template, you could now remove theplain
flags again, or you could just leave them in there to be safe. Thayts ••• 17:40, 29 September 2017 (UTC)
- @Underlying lk: You did give me something to improve. If there is a single dash as with negative numbers, then this will normally have no effect. Only if there are four dashes at the start of a line
- It does, thank you!--eh bien mon prince (talk) 17:11, 29 September 2017 (UTC)
- @Underlying lk: Yes, unfortunately it is a breaking change for some use cases. But I believe encoding the output by default is something I should have done from the start. In cases where this is undesired, you can actually prevent it by using the new
@Was a bee & @Underlying lk: I have reverted the change for request number 2 since there were more problems than I anticipated (e.g. raw value comparison stopped working). I will have to think this over more thoroughly... Thayts ••• 19:27, 29 September 2017 (UTC)
Edit links on references
@Thayts: This change seems to cause some issues whenever the same reference is invoked more than once, as in the Transneft#References article.--eh bien mon prince (talk) 21:56, 8 October 2017 (UTC)
- I see. Thanks for intervening, I'll see what I can do! Thayts ••• 16:16, 9 October 2017 (UTC)
Pages in references
@Thayts: Any chance of showing page numbers (P304) in references, please? Thanks. Mike Peel (talk) 21:30, 29 September 2017 (UTC)
- @Mike Peel: They should be shown already. Do you have an example where that's not the case? Thayts ••• 21:35, 29 September 2017 (UTC)
- @Thayts: Try {{wikidata|property|references|normal+|Q82941|P1174}} which should also return a page number in the reference. Thanks. Mike Peel (talk) 21:40, 29 September 2017 (UTC)
- @Mike Peel: Initially, I was following the page at https://www.wikidata.org/wiki/Help:Sources to determine valid parameters for a web reference. However, I have simply added "pages" so it should work now.
- (The "pages" parameter no longer works in {{Cite Q}}, though?) Thayts ••• 09:58, 30 September 2017 (UTC)
- Thanks, that's working nicely now. :-) With Cite Q, does this edit fix it? Thanks. Mike Peel (talk) 14:47, 30 September 2017 (UTC)
- I think so, yes. Thank you. Thayts ••• 16:28, 9 October 2017 (UTC)
- Thanks, that's working nicely now. :-) With Cite Q, does this edit fix it? Thanks. Mike Peel (talk) 14:47, 30 September 2017 (UTC)
- @Thayts: Try {{wikidata|property|references|normal+|Q82941|P1174}} which should also return a page number in the reference. Thanks. Mike Peel (talk) 21:40, 29 September 2017 (UTC)
Recent edits
@Pppery: A lot of edits to Module:Wd are occurring. I see some also in Module:Wd/sandbox. Shouldn't pretty well all the edits be in the sandbox? The script errors tracking category (articles) is showing hundreds of pages, and I think that is from the recent edit which Thayts fixed (I'm currently purging the category so genuine errors can be found). At any rate, the module has 5811 transclusions so tweaks definitely should happen in the sandbox to avoid unnecessary overhead regardless of whether another glitch might occur. If wanted, I would be happy to remove the many global variables which are currently in the module. Johnuniq (talk) 04:41, 12 October 2017 (UTC)
P of Q
Not really sure whether this is the right place to ask, but here goes: I'd like a (simple) template that returns Wikidata claims given a Q number and a P number. For instance, the publisher of A Haunted House and Other Short Stories (A Haunted House and Other Short Stories (Q4004168)) is Hogarth Press. The property number of "publisher" is P123. For the sake of this example, let's call the proposed template {{Wikidata/P of Q}} (other names are possible), then:
- {{Wikidata/P of Q|P123|Q4004168}}
or
- {{Wikidata/P of Q|publisher|Q4004168}}
would return:
Then, additionally, if no Q number is given, the template takes the Q number of the page on which it is, thus if the {{Wikidata/P of Q}} template is placed on the A Haunted House and Other Short Stories page, with only the first parameter (the P parameter) added, thus:
- {{Wikidata/P of Q|P123}}
or
- {{Wikidata/P of Q|publisher}}
it gives the same return as mentioned above.
I suppose this could be done with the current {{Wikidata}} template, with the correct parameters — maybe such simplified template already exists, and I just didn't find it. Could someone help out here? Tx. --Francis Schonken (talk) 09:06, 5 November 2017 (UTC)
Oops, just looked above #Substing_.7B.7BWikidata.7D.7D, seems like I can find at least part of the answer there. --Francis Schonken (talk) 09:16, 5 November 2017 (UTC)
Propose to continue talk about this at Template talk:Wikidata/P of Q. --Francis Schonken (talk) 09:26, 5 November 2017 (UTC)
- @Francis Schonken: This is exactly what can be achieved with the {{Wikidata}} template as follows:
- {{Wikidata|property|Q4004168|P123}}
- returns:
- Hogarth Press
- or have it linked:
- {{Wikidata|property|linked|Q4004168|P123}}
- returns:
- Included on the page you can simply do:
- {{Wikidata|property|P123}}
- or:
- {{Wikidata|property|linked|P123}}
- Thayts ••• 13:26, 5 November 2017 (UTC)
- Thanks! --Francis Schonken (talk) 13:34, 5 November 2017 (UTC)
References for 11×58mmR bullet diameter {{wd|property|raw|P2386|P518=Q174583}}?
Hi! Can you help slovenian wikipedians with template usage?
- We have just copied your Template:Wikidata (into sl:Predloga:Wd) and sl:Modul:Wikidata. With just a few small changes, it works great. But ... there is always but ;) .. How can I get reference from Wikidata item 11×58mmR (11x58mmR (Q17560835)) -> diameter (P2386): bullet diameter or neck diameter or shoulder diameter? --Pinky sl (talk) 12:59, 5 November 2017 (UTC)
- @Pinky sl: I suppose you mean sl:Modul:Wd. Please refer to the documentation. For example, to get the shoulder (Q29841352) diameter, use:
- {{Wd|property|Q17560835|P2386|P518=Q29841352}}
- output:
- 13.61 millimetre
- Thayts ••• 13:40, 5 November 2017 (UTC)
- The problem is not to extract quantity 13.61 millimetre for shoulder diameter (with or without unit). The problem is to get its reference (title - Cartridges of the World; creator - Frank Barnes; date of publication - 1972; ... -Pinky sl (talk) 15:18, 5 November 2017 (UTC)
- @Pinky sl: This module/template determines if a reference is valid based on the Wikidata guideline on sources and only includes it when that's the case. A reference on Wikidata is valid if it contains at least the property stated in (P248) or reference URL (P854). In this case, you can replace the whole reference with one that has a single stated in (P248) equal to Cartridges of the World (Q5047440). I've done this with the shoulder diameter as an example:
- {{Wd|property|references|Q17560835|P2386|P518=Q29841352}}
- output:
- 13.61 millimetre[1]
- Thayts ••• 15:30, 5 November 2017 (UTC)
- Thank you ... it works now. Is it possible:
- to get reference for raw value (without unit) - my solution is like this {{Wd|property|raw|Q17560835|P2386|P518=Q29841352}}{{Wd|references|Q17560835|P2386|P518=Q29841352}} 13.61[1]
- to get label Cartridges of the World in other language not just the current wiki's language? -Pinky sl (talk) 15:56, 5 November 2017 (UTC)
- @Pinky sl:
- Yes: {{Wd|property|raw|references|Q17560835|P2386|P518=Q29841352}} → 13.61[1]
- No, that is currently not possible.
- (I'm sorry about my first reply, I didn't see the section title entirely.) Thayts ••• 16:09, 5 November 2017 (UTC)
- Thank you ... it works now. Is it possible:
- @Pinky sl: This module/template determines if a reference is valid based on the Wikidata guideline on sources and only includes it when that's the case. A reference on Wikidata is valid if it contains at least the property stated in (P248) or reference URL (P854). In this case, you can replace the whole reference with one that has a single stated in (P248) equal to Cartridges of the World (Q5047440). I've done this with the shoulder diameter as an example:
- The problem is not to extract quantity 13.61 millimetre for shoulder diameter (with or without unit). The problem is to get its reference (title - Cartridges of the World; creator - Frank Barnes; date of publication - 1972; ... -Pinky sl (talk) 15:18, 5 November 2017 (UTC)
- @Pinky sl: I suppose you mean sl:Modul:Wd. Please refer to the documentation. For example, to get the shoulder (Q29841352) diameter, use:
- Thank you for your help. Now I have to figure it out how to get the same output, because our reference looks something like this: "Cartridges of the World; stran: 178", without author and OCLC. --Pinky sl (talk) 17:21, 5 November 2017 (UTC)
- This module/template uses {{Cite Q}} to retrieve that information. If that template is not available on your wiki, then it will only show what is in the reference indeed. You could add author etc. manually to the references on Wikidata, which should work in that case (although you will be duplicating information in Wikidata then). Thayts ••• 18:13, 5 November 2017 (UTC)
- I thought that was the case. I will create {{Cite Q}}, I do not like to duplicate data. So thank you again. --Pinky sl (talk) 19:06, 5 November 2017 (UTC)
- This module/template uses {{Cite Q}} to retrieve that information. If that template is not available on your wiki, then it will only show what is in the reference indeed. You could add author etc. manually to the references on Wikidata, which should work in that case (although you will be duplicating information in Wikidata then). Thayts ••• 18:13, 5 November 2017 (UTC)
- ^ a b c Frank C. Barnes (1972), Cartridges of the World, p. 178, OCLC 70173636, Wikidata Q5047440
Unit symbols
@Thayts: I'm thinking about using unit symbols instead of unit labels (singular form of the label not appropriate for direct use + too long for infoboxes). Could you take a look: [1]? (It could be made optional and further optimized by saving wikidata calls via local array with the most common units.) --Nk (talk) 11:46, 12 January 2018 (UTC)
- @Nk: Yeah, I've been thinking about it as well. But the problem I saw was that you cannot know from the unit's Wikidata item if the symbol should normally be added in front of the value or behind it, and if there should be a space between it or not. And that might also differ per language. So I'm not confident enough yet that this can be done the right way in all cases. Thayts ••• 20:23, 12 January 2018 (UTC)
Badges
How can we pipe in badges from wikidata. Capankajsmilyo (talk) 07:57, 13 March 2018 (UTC)
- @Capankajsmilyo: Voilà: Template:Wikidata#General class. Thayts ••• 10:26, 18 March 2018 (UTC)
- @Thayts: Thanks, but it only gives text name of badge, can we have star instead of featured and plus instead of Good? Capankajsmilyo (talk) 11:28, 18 March 2018 (UTC)
- Not sure if I should put that in the module, also because the logic is internationalized for use on different Wikipedia's. However, you could create a template that selects the right icon based on the returned value. Thayts ••• 12:47, 18 March 2018 (UTC)
- @Thayts: Thanks, but it only gives text name of badge, can we have star instead of featured and plus instead of Good? Capankajsmilyo (talk) 11:28, 18 March 2018 (UTC)
raw date format?
This returns a date in a format that does not accord with MOS:DATE:
{{wikidata|property|raw|Q19858624|P577}}
→ 2015-04-29 (P577 is publication date for: A higher level classification of all living organisms (Q19858624))
Is there a reason that month and day values in raw returns are rendered as single digit when less than 10? Technically this occurs because parseDate()
returns numbers, not strings for year, month, day so leading zeros in the source from the wikidata raw time data are lost. If leading zeros are not omitted for a specific reason, one might rewrite line 1035:
value = value .. "-" .. (((m<10) and '0') or '') .. m
and line 1038:
value = value .. "-" .. (((d<10) and '0') or '') .. d
—Trappist the monk (talk) 19:06, 23 March 2018 (UTC)
- @Trappist the monk: I wasn't aware of MOS:DATE or that the current format would cause any problems. I think your solution is simplest to implement, but maybe we need to do the same for the year (although the MOS says yyyy-mm-dd should only be used with Gregorian dates; not sure what to do with Julian dates). Also, if the precision is for example "month" then in this case "2015-04" would be returned (if the leading zero is added). Is that sufficient, or should the digits for the day also be filled like "2015-04-00" in your opinion? (This is also how Wikidata returns it in string format, but I'm not sure if this is considered a valid date.) Thayts ••• 22:07, 23 March 2018 (UTC)
- Perhaps I should do it like decades, centuries and millenniums, and return "2015-04-01" in that case. Thayts ••• 22:32, 23 March 2018 (UTC)
- I'm presently wondering about a request to migrate the cs1|2 module suite and
{{cite Q}}
to Wikidata which rewrites dates according to the user's interface language setting before they are passed to the template and module. Changing the interface away from English causes the date validation code to emit errors. For example, 29 April 2015 becomes 29 abr 2015 when the interface is changed to Spanish (made stranger by abbreviating the month name; why?) Example at d:Wikidata:Sandbox.
- I'm presently wondering about a request to migrate the cs1|2 module suite and
-
- I'm not really sure what the answer is. MOS doesn't like YYYY-MM dates because they can be too easily confused with YYYY–YY. There was a time when cs1|2 considered adopting parts of EDTF to handle machine generated dates (citoid was the machine we were thinking about). ISO BIS 8601:2016 part 2 (still underdevelopment) suggests a method for handling uncertain or unspecified date parts (2014-04-XX is one way it might be done). At cs1|2 we did an experiment with a similar form that would correctly render incomplete dates. Something similar could be done here. Alternately, I suppose that the date precision from the raw wikidata timestamp could be applied so: 2015-04-29/11, 2015-04/10, and 2015/9. Yet another alternately, the function could return precision as a second value:
value, precision = value .. calendar, precision
- where
value
for month precision dates would be YYYY-MM-00 (just like wikidata) or maybe, for compatibility with existing use (if there is any), return YYYY-MM. Users can choose to ignore the second return. - —Trappist the monk (talk) 00:55, 24 March 2018 (UTC)
- If it is relevant for the citation module at all, then it should accept some format for dates of lesser precision than days. Currently it doesn't accept "2014-04-XX", nor "2014-04-00", nor "2014-04". However, from "2014-04" it can be deduced that only the month of the year is known (provided that such a date format returned by this module will always mean YYYY-MM). Returning multiple values, either concatenated or separately, would be another possibility indeed, but that requires to do some deducing too. Returning them separately is certainly not compatible with templates that can only receive one value. I could of course work around that if necessary, returning single, concatenated values when called by a template and multiple otherwise, but that would require an overhaul of the current module. This is something we can discuss about, but for now I have made a change so that day-precision dates are always returned as YYYY-MM-DD as you suggested. Thayts ••• 12:37, 24 March 2018 (UTC)
- Point. I was thinking 'module' so didn't think 'template' when I suggested multiple return values (and I was pressed for time).
-
- Yeah, cs1|2 does not accept incomplete ymd dates any longer. That experiment did not gain sufficient traction (the form was YYYY-MM-uu from the edtf preliminary standard). cs1|2 could probably support YYyy-MM dates where the values in yy and MM are, in combination, clearly unambiguous. But, since MOS prohibits the YYYY-MM date form, it is easier to simply reject that date style.
-
- I have implemented a stopgap 'fix' to the wikidata version of d:Template:cite Q that uses code suggested to me at d:Help_talk:Dates#How to get raw date/time value. I had been hoping for a more generic solution; something that would be usable regardless of where the template existed; perhaps something like
{{#raw_property:R...|from=...}}
. That functionality, I would think, should be available. Apparently not. - —Trappist the monk (talk) 13:27, 24 March 2018 (UTC)
- I have implemented a stopgap 'fix' to the wikidata version of d:Template:cite Q that uses code suggested to me at d:Help_talk:Dates#How to get raw date/time value. I had been hoping for a more generic solution; something that would be usable regardless of where the template existed; perhaps something like
- If it is relevant for the citation module at all, then it should accept some format for dates of lesser precision than days. Currently it doesn't accept "2014-04-XX", nor "2014-04-00", nor "2014-04". However, from "2014-04" it can be deduced that only the month of the year is known (provided that such a date format returned by this module will always mean YYYY-MM). Returning multiple values, either concatenated or separately, would be another possibility indeed, but that requires to do some deducing too. Returning them separately is certainly not compatible with templates that can only receive one value. I could of course work around that if necessary, returning single, concatenated values when called by a template and multiple otherwise, but that would require an overhaul of the current module. This is something we can discuss about, but for now I have made a change so that day-precision dates are always returned as YYYY-MM-DD as you suggested. Thayts ••• 12:37, 24 March 2018 (UTC)
- I'm not really sure what the answer is. MOS doesn't like YYYY-MM dates because they can be too easily confused with YYYY–YY. There was a time when cs1|2 considered adopting parts of EDTF to handle machine generated dates (citoid was the machine we were thinking about). ISO BIS 8601:2016 part 2 (still underdevelopment) suggests a method for handling uncertain or unspecified date parts (2014-04-XX is one way it might be done). At cs1|2 we did an experiment with a similar form that would correctly render incomplete dates. Something similar could be done here. Alternately, I suppose that the date precision from the raw wikidata timestamp could be applied so: 2015-04-29/11, 2015-04/10, and 2015/9. Yet another alternately, the function could return precision as a second value:
Code for i18n
@Thayts: On 9 May 2017 local arg = ...
was introduced. Do you have a reason to use that off-wiki? I believe it would never do anything useful in a Scribunto module (arg
would always be nil). Is the code used anywhere? That is, does Module:Wd ever get "included by other module" which passes the title in arg
?
The background to my question is that a discussion at VPT is questioning the use of red-linked /i18n pages. I haven't looked at whether this module is part of that but it is the earliest form of the code that I have seen, and its procedure was copied to Module:Wikidata in October 2017. In this October 2017 comment I mentioned "two really puzzling aspects of the code"—that is, two things which I believe would never work.
It is irritating to edit an article at enwiki and see a red-linked /i18n page. I was hoping to investigate whether there was some workaround that might disable that for enwiki while leaving it available for other projects. I'll look at that later but first I would like to understand the above. Johnuniq (talk) 03:36, 28 June 2018 (UTC)
- @Johnuniq: First of all, the split between the module's logic and the i18n submodule was made to make it easy to copy over the logic to other wikis and to keep it updated without the need to tweak it for locality all the time. Since the module on other wikis might have a different title, especially in the namespace part 'Module:' (which is written differently in different languages), I was looking for a way to determine the local title (so that this doesn't need to be hardcoded and tweaked either). This is needed to actually locate the i18n submodule (the title "/i18n" is indeed a hardcoded convention).
- For template inclusions this is easy, since you can get it from the frame. The problem is indeed when the module is included by another module, which I wanted to be possible (not sure if there is any module doing that with Module:Wd right now, but that doesn't really matter). In that case, the title contained by the frame will be the title of the module that is including Module:Wd, and so not actually the title of the included module "Module:Wd" which is needed to construct "Module:Wd/i18n". After some googling I found out that there is a triple-dot argument
...
that on Wikipedia, for reasons unknown to me, contains the title of the called module (this was the only solution I could find after also consulting the Wikipedia Lua community). But it only contains that title when the module is included by another module. Here is an example, where module number 2 includes module number 1 and callstest(frame)
in module number 1:
{{#invoke:Sandbox/Thayts/1|test}} |
... => nilframe:getTitle() => Module:Sandbox/Thayts/1
|
{{#invoke:Sandbox/Thayts/2|test}} |
... => Module:Sandbox/Thayts/1frame:getTitle() => Module:Sandbox/Thayts/2
|
- As you can see on the bottom row, the
...
contains the title of the module that was included, which differs from the title of the module that was including it. I hope this clarifies things. - Regarding the red links, I'm not sure what causes it in the Infobox module and if it the
...
is part of the cause at all. Obviously, a /i18n submodule should only be called if there actually is one. Thayts ••• 10:52, 30 June 2018 (UTC)- Amazing! Thanks for the comprehensive reply. It is reasonable as
...
provides the command-line arguments in a stand-alone Lua program (that is, not a module running in Scribunto), and those arguments include the name of the program being run. I do not see...
documented anywhere as being available in Scribunto to get the name of a module called by another module withrequire
. I will have to think some more and may ask for information somewhere. - Re "Module:" possibly being different at other projects, it's not relevant but in case you were not aware, "Module:" works everywhere, for example bn:Module:Convert and bn:Module:ট্র্যাক তালিকায়ন.
- In a couple of days I hope also to think about the /i18n issue and see whether some trick might be used to disable the red link at enwiki (perhaps do not look for a subpage if the start of the
...
name is "Module:"?). Johnuniq (talk) 11:57, 30 June 2018 (UTC)- You're welcome. I do remember that I expected
...
to be a table and that it turned out to be a string instead (actually the string I needed). I did not know about the English namespace working on other wikis, good to know! Still, the name of the module might differ from "Wd", so it's good to leave it in there. Thayts ••• 12:35, 30 June 2018 (UTC)- Some checking shows a slightly different picture from what I said earlier. In stand-alone Lua 5.1, the global variable
arg
is a table containing the command-line arguments and a little bit more. The name of the script being run isarg[0]
and any arguments are inarg[1]
,arg[2]
, etc. If used outside a function,...
unpacksarg
which would generatearg[1]
,arg[2]
, etc (but would omit the name of the script inarg[0]
).It looks like the place where Scribunto sets
arg
is package.lua (that applies when one module usesrequire
to access a second module). That setsarg[1]
to the name of the second module.Using
local arg = ...
puts globalarg[1]
into localarg
which gets the desired result. Using...
is convenient because it will give nil (if globalarg
is nil) orarg[1]
.@Anomie: Is what I've said correct? Can we rely on
arg
being nil (if a module is directly called with #invoke) or being a table witharg[1]
being the name of therequire
d module? Johnuniq (talk) 07:24, 1 July 2018 (UTC)- @Johnuniq: You seem to be right. I've replaced
...
witharg[1]
and it does contain the same string:
- @Johnuniq: You seem to be right. I've replaced
- Some checking shows a slightly different picture from what I said earlier. In stand-alone Lua 5.1, the global variable
- You're welcome. I do remember that I expected
- Amazing! Thanks for the comprehensive reply. It is reasonable as
{{#invoke:Sandbox/Thayts/1|test}} |
Lua error in Module:Sandbox/Thayts/1 at line 3: attempt to index global 'arg' (a nil value). |
{{#invoke:Sandbox/Thayts/2|test}} |
arg[1] => Module:Sandbox/Thayts/1frame:getTitle() => Module:Sandbox/Thayts/2
|
- As the error shows, you would need to do an extra check to see if the global
arg
is set, so...
is indeed more convenient to use. Thanks for checking this out! Thayts ••• 07:58, 1 July 2018 (UTC) - @Johnuniq: As far as existing behavior goes, you're effectively correct.
_G.arg
will be nil from an#invoke
and...
will be empty, and fromrequire()
_G.arg
will be a table having one element (the module name loaded) and...
will be a list as described.If you want to get technical, note that
...
doesn't actually unpack_G.arg
. It's just that the two contain the same values.I'm also not sure why Scribunto's package library sets
_G.arg
inrequire()
, it doesn't seem that standard Lua 5.1's package library does that. I guess it's because Scribunto's package library was originally copied from a compat-5.1 library for 5.0 and 5.0 doesn't seem to have any other way to pass the module name parameter in a 5.1-like manner. Anomie⚔ 14:49, 1 July 2018 (UTC)
- As the error shows, you would need to do an extra check to see if the global
Property
I've struck through "{{Property}}, used to add a Wikidata property link in text" because clearly {{Property}} is something else entirely, but I have no idea what it should list here; I assume there is some template for that purpose. - Jmabel | Talk 23:43, 13 June 2018 (UTC)
- @Jmabel: Two templates can do that: {{Wikidata entity link}} (which requires the leading "P") and {{Wikidata property link}} (which works with or without the "P" and has additional display options). Also, {{Property}} is now a redirect to the second template (similar to d:Template:Property). I updated the list at Template:Wd/doc § See also. -- Zyxw (talk) 19:43, 1 August 2018 (UTC)
label in "references" with no slovenian language available
Hi from Slovenian Wikipedia! Can you help me with a problem?
- Example: {{#invoke:wd|properties|qualifier|references|normal+|Q55|P1082|P585}} displays 17,942,942 (1 January 2024),[1] 17,590,672 (1 January 2022),[2] 17,407,585 (1 January 2020),[2] 17,282,163 (1 January 2019),[2] 17,181,084 (1 January 2018),[2] 17,081,507 (1 January 2017),[3] 17,000,000 (21 March 2016),[4] 16,829,289 (26 August 2014),[5] 16,779,575 (2013),[6] 10,026,773 (1950)[6]
- Problem: The publisher "Statistics Netherlands (Q167086)" does not have a label in Slovenian language, so text "publisher: Statistics Netherlands" is not displayed in Slovenian articles. Is it possible to display the label in any available language? You can see how it works at sl:Uporabnik:Pinky sl/PeskovnikW
--Pinky sl (talk) 19:22, 4 January 2019 (UTC)
- ^ "Bevolking; kerncijfers (1950-2024)". Retrieved 22 August 2024.
- ^ a b c d "Bevolking; kerncijfers, 1950-2022".
- ^ "Bevolking; kerncijfers, 1950-2022". Retrieved 18 March 2023.
- ^ "Nederland telt 17 miljoen inwoners". 21 March 2016.
- ^ "CBS StatLine - Bevolking; kerncijfers". Archived from the original on 3 September 2014. Retrieved 26 August 2014.
- ^ a b "CBS StatLine - Bevolking; kerncijfers". Statistics Netherlands. Archived from the original on 27 August 2015. Retrieved 22 August 2015.
- Hi, you can set a Slovenian label yourself at https://www.wikidata.org/wiki/Q167086?setlang=sl&uselang=sl. That label should then be displayed. Thayts ••• 12:20, 5 January 2019 (UTC)
- Thanks for your answer. Yes, I can set it. But I am in charge for importing data from Wikidata into our infoboxes. I am preparing the first infobox that will be filled completely from wd. And references are important. I cannot set all the missing sl labels; and labels keeps updating. And it is not just about publishers. --Pinky sl (talk) 07:44, 6 January 2019 (UTC)
- Well, do you have a suggestion what should be displayed if a Slovenian label is not available? We could perhaps use English as default, but there is also no guarantee that an English label is always available. Thayts ••• 12:45, 6 January 2019 (UTC)
- I guess, the best way to do this is: if local language label is not available, then substitute language shoud be used (maybe this can be set in /i18). If there is no local or substitute language, you can display just link to Wikidata object - example: Q167086? with an error category. It is better that way then leave it empty.
[[:d:' .. entityId .. '|' .. entityId .. ']]<span style="border-bottom: 1px dotted; cursor: help; white-space: nowrap" title="No label ..... . You can help us to translate it to local language.">?</span>' .. categoryLinksToEntitiesWithMissingLabel
Pinky sl (talk) 15:59, 6 January 2019 (UTC)- It is possible and I've played around with it in a sandbox, but I'm still figuring out what the best default would be if I would be implementing this. Thayts ••• 10:42, 18 January 2019 (UTC)
- Well, do you have a suggestion what should be displayed if a Slovenian label is not available? We could perhaps use English as default, but there is also no guarantee that an English label is always available. Thayts ••• 12:45, 6 January 2019 (UTC)
Most recent claim regardless of rank
Hi @Thayts:, I have another question: is there a way to return the claim with the most recent point in time (P585), even when a less recent claim has a higher rank? For instance, using population (P1082) on Basel (Q78) returns the population as of 2022-12-31, even though there are population figures for 2018 stored in the entity page. Is there a way to get the latest figures, without having to change all the ranks? Thank you for your excellent work, as always.--eh bien mon prince (talk) 21:29, 30 January 2019 (UTC)
- @Thayts:, when you have the time, this issue is more current than ever after the deletion of several wrappers of {{Infobox settlement}}.--eh bien mon prince (talk) 03:27, 19 March 2019 (UTC)
- Although I think the ranking system is most suitable for this and it is simply the data in Wikidata that is not up to date, I do see this can have added value. However, to make this as generic as possible I would like to add a sort function, but that's not trivial to implement. But I will see what I can do. Thayts ••• 11:40, 24 March 2019 (UTC)
Returning the top-level administrative division
@Thayts:I'm trying to use this template to fill the subdivision_type
fields of {{Infobox settlement}}, but I have trouble
with it because of the way located in the administrative territorial entity (P131) works up backwards from the lowest level division to the top.
So {{wikidata|property|P131}} is the lowest level division, {{wikidata|property|eid={{wikidata|property|raw|P131}}|P131}} is the second lowest, and so on. But is there a way to reliably retrieve the top-level division for the entity (or second-level, etc.), no matter how many divisions are below it?
For instance, the template would need to find the top level division Ticino (Q12724) on both Brè (Q3646180) and Lugano District (Q660612), without changing the syntax. Can this be achieved? --eh bien mon prince (talk) 20:30, 16 January 2019 (UTC)
- I don't think there is, unless there is a library feature for it that I don't know of. Note however that Ticino (Q12724) is not the top level division, because it itself is located in the administrative territorial entity (P131) of Switzerland (Q39). Thayts ••• 10:40, 18 January 2019 (UTC)
- It would of course be possible to implement this with a dedicated command or so, but then when do you stop while working the way up? Also, an entity can have multiple located in the administrative territorial entity (P131) properties, so which do you choose? Thayts ••• 10:44, 18 January 2019 (UTC)
- Thanks for the reply. This is some sort of 'solution' I adopted. Basically, called on a page like Lugano District, it checks whether the entity in located in the administrative territorial entity (P131) is an instance of (P31) canton of Switzerland (Q23058), and if it's not, it moves up to the next administrative level. But it is extremely wasteful in terms of resources, and it cannot be scaled up to more than two or three administrative levels.
{{#ifeq: {{wikidata|property|raw|eid={{wikidata|property|raw|P131}}|P31}} | Q23058 | {{wikidata|property|raw|P131}} | {{#ifeq: {{wikidata|property|raw|eid={{wikidata|property|raw|eid={{wikidata|property|raw|P131}}|P131}}|P31}} | Q23058 | {{wikidata|property|raw|eid={{wikidata|property|raw|P131}}|P131}} | {{wikidata|property|raw|eid={{wikidata|property|raw|eid={{wikidata|property|raw|P131}}|P131}}|P131}} }} }}
- --eh bien mon prince (talk) 03:22, 19 January 2019 (UTC)
- As I'd like to keep this module as generic as possible, I think this doesn't fit the module very well because is hard to implement in a generic way. What's still a possibility though is to create a template that uses this module and that is specifically designed for the task at hand. Thayts ••• 11:44, 24 March 2019 (UTC)
- --eh bien mon prince (talk) 03:22, 19 January 2019 (UTC)
ucfirst
ucfirst don't work : how can I capitalize the first letter in {{ucfirst:<ul>{{wikidata|properties|normal+|current|linked|Q870899|P1885|P1013=Q2577114|format=<br>%p[%r][<ul><li>%q</li></ul>]}}</ul>}} :
?
In french, the result is :
- cathédrale Saint Pierre
- cathédrale Saint Paul
and I want not cathédrale but Cathédrale (c->C) :
- Cathédrale Saint Pierre
- Cathédrale Saint Paul
cdt, Speltdecca (talk) 17:55, 8 June 2019 (UTC)
- @Speltdecca: Transforming formatted text is currently not possible with this module. However, using CSS you can make each list item appear to start with a capital like this:
<ul>{{wikidata|properties|normal+|current|linked|Q870899|P1885|P1013=Q2577114|format=<li style="text-transform:capitalize">%p[%r]</li>}}</ul>
- or
<ul style="text-transform:capitalize">{{wikidata|properties|normal+|current|linked|Q870899|P1885|P1013=Q2577114|format=<li>%p[%r]</li>}}</ul>
- You'll only notice that each item doesn't actually start with a capital when you copy it and paste it elsewhere, but I hope this is acceptable for you. Thayts ••• 15:35, 18 July 2019 (UTC)
Template-protected edit request on 11 October 2019
This edit request to Module:Wd has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
As this module is now edit protected and I can't edit it myself anymore, please copy and implement the current contents of the sandbox to here. This is a small uncontroversial change as the code comparison shows, which replaces a hacky solution to get the global site ID with a call to a recently added dedicated function. I have added 4 testcases with a call to the badges
function, which is the only function that relies on the site ID. The testcases show the same results for the current version of the module and the sandbox version. Thayts ••• 08:58, 11 October 2019 (UTC)
- @Thayts: I have temporarily disabled the edit request while we sort something out. Do you want the Wikipedia:Template editor right? If so, please confirm you have examined that page and understand the requirements. In particular, while edit warring is always undesirable, it is particularly prohibited when using an advanced right. So, for example, if you edited this module using the TE right and someone reverted you (they would need the TE right to do that), there must be no further edits until the issue is sorted out on a talk page. I'll be away and won't see any reply for the best part of a day but I don't see a reason why you wouldn't just be given the right so you can continue to edit this module. In principle, requests should be made here but I'm happy to skip that if you don't mind waiting until I return. Or, re-activate the edit request if you want. Johnuniq (talk) 09:25, 11 October 2019 (UTC)
- @Johnuniq: Thank you, I would very much like to receive the right. I have read the page and understand my obligations. I'm also familiar with the edit warring policy and understand to avoid it and go into discussion first. Thank you for your confidence! Thayts ••• 10:05, 11 October 2019 (UTC)
- Done — Martin (MSGJ · talk) 10:50, 11 October 2019 (UTC)
- @Johnuniq: Thank you, I would very much like to receive the right. I have read the page and understand my obligations. I'm also familiar with the edit warring policy and understand to avoid it and go into discussion first. Thank you for your confidence! Thayts ••• 10:05, 11 October 2019 (UTC)
Wikidata Bridge
(Reposted from Module talk:WikidataIB § Wikidata Bridge.)
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:32, 3 July 2019 (UTC)
- @Jc86035: Thanks for telling. I was indeed unaware of this, but it is a great initiative that brings a lot of convenience! It would be easy to implement in this module too. Please keep us posted! By the way, will it also be possible to edit e.g. qualifier values? Thayts ••• 15:59, 18 July 2019 (UTC)
- @Thayts: I don't think there is a definite answer yet. There has been a fair amount of discussion at mw:Talk:Wikidata Bridge about what the software is actually going to be like, so you might want to follow the discussions on that page if you're interested in the software's development. Jc86035 (talk) 16:04, 18 July 2019 (UTC)
- Note that WikidataBridge might allow editing of entries in ways that will not be shown due to formatting done by this module. Jeblad (talk) 01:39, 6 November 2019 (UTC)
Date parameter
You may be interested to add a date parameter like the one we have implemented in bgwiki [2]. Use cases are flags, countries, etc. at specific past dates. --Nk (talk) 07:10, 17 September 2019 (UTC)
- @Nk: Thanks for the suggestion. However, you can already achieve this by filtering on qualifier by supplying an (exact) date like
{{#invoke:wd|property|Qxxx|Pxxx|P580=yyyy-mm-dd}}
. Or do you want to be able to supply a less exact date that falls within the start-end time range? Thayts ••• 07:20, 14 October 2019 (UTC)- @Thayts: I want to supply a date and match it against the entire start/end range. It works like that: [3]. --Nk (talk) 11:54, 14 October 2019 (UTC)
- @Nk: Done; it has been implemented. Thayts ••• 17:14, 9 November 2019 (UTC)
- @Thayts: I want to supply a date and match it against the entire start/end range. It works like that: [3]. --Nk (talk) 11:54, 14 October 2019 (UTC)
Errors after recent edit
@Thayts: Something in the edit of 11:10, 9 November 2019 broke a few articles. I don't have time to investigate further atm. For example, see Shovana Narayan#External links where {{Scholia}}
is generating The ID "{{{ID}}}" is unknown to the system. Please use a valid entity ID. Johnuniq (talk) 03:10, 10 November 2019 (UTC)
- I think I fixed the problem with this edit at {{Scholia}}. I don't know how the change to the module revealed that, however it seems ok. Johnuniq (talk) 09:21, 10 November 2019 (UTC)
- (I've moved this discussion to a new section) @Johnuniq: That edit indeed introduced a generic check on the existence of an entity to mitigate error conditions with the
title
anddescription
commands. I was not aware that it would introduce a new error condition, yet I found that this condition already existed for the claim commands and the edit made the module's behaviour therefore more consistent (but not completely). However, I think that an invalid ID should not result in an error, so I made another edit to check its validity and prevent the error condition. The template should have given valid input nonetheless, so thanks for fixing that. Thayts ••• 20:56, 11 November 2019 (UTC)
- (I've moved this discussion to a new section) @Johnuniq: That edit indeed introduced a generic check on the existence of an entity to mitigate error conditions with the
- The reported error comes from Wikibase because it is given an incorrect identifier. Same error as in #Failing verification. Jeblad (talk) 00:42, 12 November 2019 (UTC)
Failing verification
Somewhere in the code path for rendering reference there are probably one or more missing verification of existence of some substructure. In short a nil-value is passed where you are assuming a table, most likely because the table is empty in the statement, and it is thus removed. Always check whether the table exist, or fallback to an empty table. Also make sure that the code holds for empty tables, the code isn't totally consistent on empty structures. Or at least it wasn't.
I don't have any example, as all examples have been promptly fixed by changing statements. Jeblad (talk) 01:33, 6 November 2019 (UTC)
- @Jeblad: A concrete example would help. Thayts ••• 21:26, 11 November 2019 (UTC)
- As I said; “I don't have any example, as all examples have been promptly fixed by changing statements.” But fixed, users work around the issue by changing the references. Jeblad (talk) 00:43, 12 November 2019 (UTC)
- Can't you recall a page where the problem was seen and a rough time when that occurred? Perhaps then the edit which fixed the issue might be found and any underlying problem identified. Johnuniq (talk) 00:49, 12 November 2019 (UTC)
- As I said; “I don't have any example, as all examples have been promptly fixed by changing statements.” But fixed, users work around the issue by changing the references. Jeblad (talk) 00:43, 12 November 2019 (UTC)
Use of underscore
Use of undersore (local _ = Config.new()
) as a variable name breaks several tools for Lua, as it is assumed to be used for unassigned values. Or breaks, some of them silently fails as statements involving an underscore are simply neglected. (Not sure if complete code paths involving a neglected statement are neglected.) Jeblad (talk) 01:24, 6 November 2019 (UTC)
- @Jeblad: The underscore is currently used in a very limited and controlled way, within a local scope. It's not used with Lua tools, so I don't think there is an issue really. Thayts ••• 21:25, 11 November 2019 (UTC)
- Yes, but it is true that Lua convention is to use underscore to mean an unused variable. The code in the module is very clean and sophisticated but I was going to suggest that the global variables be cleaned up. I'll post a list and have a look at that later if wanted. Johnuniq (talk) 23:31, 11 November 2019 (UTC)
- The statement “I don't think there is an issue really” does not hold when the issue breaks code verification. I would say “fix it”. Jeblad (talk) 00:52, 12 November 2019 (UTC)
- That would be more convincing if there were an explanation about what breaking code verification refers to: what is the tool and how it is used? Johnuniq (talk) 02:47, 12 November 2019 (UTC)
- Don't fix it if it isn't broken I would say, and it doesn't seem to be broken. However, if we're going to make a list of improvements anyway then I don't mind to put it on there. It's a good thing there are testcases now (although they cannot cover everything like defaulting to the current page's entity ID), so we should be more confident to make such changes.
- By the way, the module is performing quite poorly (i.e. slow) so I will also be seeing what can be done about that. Thayts ••• 08:04, 12 November 2019 (UTC)
- The statement “I don't think there is an issue really” does not hold when the issue breaks code verification. I would say “fix it”. Jeblad (talk) 00:52, 12 November 2019 (UTC)
- Yes, but it is true that Lua convention is to use underscore to mean an unused variable. The code in the module is very clean and sophisticated but I was going to suggest that the global variables be cleaned up. I'll post a list and have a look at that later if wanted. Johnuniq (talk) 23:31, 11 November 2019 (UTC)
- Any reference to a variable name consisting of a single underscore will lead to all errors involving this name being rejected. This happens with most of the tools for static analysis for Lua. If you don't want to fix it, fine, but then don't expect anyone to use time trying to track down errors within this module. Jeblad (talk) 00:56, 19 November 2019 (UTC)
- @Jeblad: Ok, I get what you mean: there might be errors that we don't know about because there might be tools running on this Wikipedia that suppress them. I'm also not necessarily against fixing it, so I just did that. Thanks for your input! Thayts ••• 21:58, 20 November 2019 (UTC)
- @Thayts: Thanks, although I don't see why Jeblad is unwilling to identify the tool. Please check my recent edits to Module:Wd/sandbox. They are just style changes. Let me know if anything is a problem or unwanted. Once you have had a chance to examine the edits, I have some more minor points to discuss if wanted. Johnuniq (talk) 04:29, 21 November 2019 (UTC)
- An example from Lua users:
The variable consisting of only an underscore "_" is commonly used as a placeholder when you want to ignore the variable
[4] and more Note: This resembles the use of "_" in Haskell, Erlang, Ocaml, and Prolog languages, where "_" takes the special meaning of anonymous (ignored) variables in pattern matches. In Lua, "_" is only a convention with no inherent special meaning though. Semantic editors that normally flag unused variables may avoid doing so for variables named "_"(e.g. LuaInspect is such a case) [LuaLint and LuaCheck also comes to mind, but there are several others…].
- I guess it is fairly obvious why this naming scheme is a bad idea. Jeblad (talk) 13:28, 21 November 2019 (UTC)
- Thanks but no one needs convincing about the Lua convention, and thanks for the LuaInspect link. Johnuniq (talk) 03:07, 22 November 2019 (UTC)
- @Johnuniq: Looks fine to me, I've published it. Thayts ••• 12:59, 23 November 2019 (UTC)
- An example from Lua users:
- @Thayts: Thanks, although I don't see why Jeblad is unwilling to identify the tool. Please check my recent edits to Module:Wd/sandbox. They are just style changes. Let me know if anything is a problem or unwanted. Once you have had a chance to examine the edits, I have some more minor points to discuss if wanted. Johnuniq (talk) 04:29, 21 November 2019 (UTC)
- @Jeblad: Ok, I get what you mean: there might be errors that we don't know about because there might be tools running on this Wikipedia that suppress them. I'm also not necessarily against fixing it, so I just did that. Thanks for your input! Thayts ••• 21:58, 20 November 2019 (UTC)
- Any reference to a variable name consisting of a single underscore will lead to all errors involving this name being rejected. This happens with most of the tools for static analysis for Lua. If you don't want to fix it, fine, but then don't expect anyone to use time trying to track down errors within this module. Jeblad (talk) 00:56, 19 November 2019 (UTC)
Can this template produce links in the form d:Q12345#P360
I have a requirement on pages such as Wikipedia:WikiProject Women in Red/Missing articles by occupation/Conductors to provide a link for the user to the P360 property for the page's item. Can this template produce a link in the form d:Q76380272#P360? thx --Tagishsimon (talk) 13:19, 24 November 2019 (UTC)
- Not out of the box, but you could construct it like this (and e.g. make a template out of it):
{{#if:{{wd|label|raw}}|[[d:{{wd|label|raw}}#P360]]}}
Thayts ••• 08:10, 25 November 2019 (UTC)- Thank you, Thayts; that'll do very nicely indeed. Very grateful. --Tagishsimon (talk) 12:42, 25 November 2019 (UTC)
The ID of the given page
How do I get the page ID for a given page? I'm trying to convert a usage of {{#invoke:Wikidata|pageId}} but can't seem to find in the doc here. The usage is in {{Birth date}} where it seems just to check if the item exists, so if there is a different check that gives the same result, that could also work. --Gonnym (talk) 19:11, 2 January 2020 (UTC)
- I see that {{Q}} uses
{{#invoke:Wikibase|id}}
which gives "Q123" on a page with that id, but unwisely gives "no entity" rather than an empty string if none. Johnuniq (talk) 22:51, 2 January 2020 (UTC)- Thanks for that. While I appreciate all the work that has gone into this module, I have to say, that for a module that is intended to replace Module:Wikidata, the lack of editor-friendly functions and clear documentation makes this module really hard to use. I found that this module has {{#invoke:wd|label|raw|linked}} that returns the ID, but why can't it provide direct access to the wikibase version? --Gonnym (talk) 09:51, 5 January 2020 (UTC)
- @Gonnym: Thanks for the feedback. Note that this is just another module that was not intended to replace Module:Wikidata. Indeed, {{wd|label|raw}} is the way to get the ID. I will look into improving the documentation. But what do you mean with the Wikibase version? Thayts ••• 08:16, 6 January 2020 (UTC)
- Hey Thayts, thanks for the reply and again, thanks for the hard work. Module:Wikidata is marked as deprecated and notes that it should be replaced with this and the infobox module version. A template I was fixing used the mw.wikibase.getEntityObject() result which I couldn't replicate here (it gives name and id in a linked version). --Gonnym (talk) 08:23, 6 January 2020 (UTC)
- @Gonnym: Have you tried it without the 'linked' flag as I suggested? {{wd|label|raw}} Thayts ••• 17:28, 6 January 2020 (UTC)
- Yeah, that gives me just the QID, unlinked. I need the name + QID linked in the same link. --Gonnym (talk) 17:37, 6 January 2020 (UTC)
- So with a link to Wikidata? This module provides some basic functions, but you can make many combinations like
[[:d:{{wd|label|raw}}|{{wd|label}} ({{wd|label|raw}})]]
. It is recommended to also perform a check to see if an entity exists like so:{{#if:{{wd|label|raw}}|[[:d:{{wd|label|raw}}|{{wd|label}} ({{wd|label|raw}})]]}}
. Hope that helps! Thayts ••• 19:04, 6 January 2020 (UTC)
- So with a link to Wikidata? This module provides some basic functions, but you can make many combinations like
- Yeah, that gives me just the QID, unlinked. I need the name + QID linked in the same link. --Gonnym (talk) 17:37, 6 January 2020 (UTC)
- @Gonnym: Have you tried it without the 'linked' flag as I suggested? {{wd|label|raw}} Thayts ••• 17:28, 6 January 2020 (UTC)
- Hey Thayts, thanks for the reply and again, thanks for the hard work. Module:Wikidata is marked as deprecated and notes that it should be replaced with this and the infobox module version. A template I was fixing used the mw.wikibase.getEntityObject() result which I couldn't replicate here (it gives name and id in a linked version). --Gonnym (talk) 08:23, 6 January 2020 (UTC)
- @Gonnym: Thanks for the feedback. Note that this is just another module that was not intended to replace Module:Wikidata. Indeed, {{wd|label|raw}} is the way to get the ID. I will look into improving the documentation. But what do you mean with the Wikibase version? Thayts ••• 08:16, 6 January 2020 (UTC)
- Thanks for that. While I appreciate all the work that has gone into this module, I have to say, that for a module that is intended to replace Module:Wikidata, the lack of editor-friendly functions and clear documentation makes this module really hard to use. I found that this module has {{#invoke:wd|label|raw|linked}} that returns the ID, but why can't it provide direct access to the wikibase version? --Gonnym (talk) 09:51, 5 January 2020 (UTC)
Example on math
I wanted to add an example for math like this one. However, the documentation on how to add new samples to the module documentation was somehow scary. Can someone help me? I think adding
to would help to better understand the example.
--Physikerwelt (talk) 15:28, 2 January 2020 (UTC)
- @Physikerwelt: Yes, it's a bit complicated. I've added a new example, does that look like what you wanted? Thayts ••• 18:51, 6 January 2020 (UTC)
- @Thayts: Thank you soo much. This way the formula is easier to understand.--Physikerwelt (talk) 16:22, 12 January 2020 (UTC)
Add link to Wikibase for math formulae
I suggest to add the qID attribute to the math tag generated by the wd for properties with data type math. I implemented for a similar datatzype content math on the drmf wiki. I suggest to change the current code
return mw.getCurrentFrame():extensionTag("math", datavalue)
to
return mw.getCurrentFrame():extensionTag{
name="math",
content= datavalue,
args={qid=mw.wikibase.getEntityIdForCurrentPage()} //here I am not sure if this is correct. I guess it will not pick up the item id if the property is specified.
}
The qid attribute will be picked up by the mw:Extension:Math which will generate a hyperlink to specialpage which will show additional information regarding the formula including its source on wikidata. --Physikerwelt (talk) 18:19, 13 January 2020 (UTC)
Search by page title instead of item id
Is there a way to search by page title instead of item id? I know we can get Wikidata information for Q1, but is it possible to get do it for "Universe"?
For example, I want the template to return the Wikidata badge for Suillus luteus, when it has been used on my sandbox. However, I don't want to use the item id for this purpose. Is there any way, other than Wikidata item id, to do this? Thanks. Ahmadtalk 12:07, 23 January 2020 (UTC)
- @Ahmad252: I've added the named argument
page=
which gives you what you need! Thayts ••• 17:27, 1 February 2020 (UTC)- Thank you, Thayts. That's really a big help. Ahmadtalk 17:54, 1 February 2020 (UTC)
Small change to make it easier to port to other sites
This edit request to Module:Wd has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
While updating the copy of this module at no:Modul:Wd, I came across a small issue. The test for whether a single value or multiple values should be returned, depends on whether the claim command ends with "s", but since the claim commands can be translated at the top of the module, this test generally fails for non-English languages. To make it easier to port the module to other sites, I would therefore suggest this slightly more verbose version of the test. – Danmichaelo (talk) 16:12, 13 April 2020 (UTC)
- @Danmichaelo: Done. I've never cared about internationalizing the command names (and to add them to Module:Wd/i18n), but I think it's a good edit. Thayts ••• 22:41, 18 April 2020 (UTC)
Maxvals & inverted
Hi, I have two question :
First question :
{{#invoke:wd|properties|normal+|Q55|P1082}} display :"17,942,942, 17,590,672, 17,407,585, 17,282,163, 17,181,084, 17,081,507, 17,000,000, 16,829,289, 16,779,575, 10,026,773",
how can I display just three first number for to have just : "17,181,084, 16,829,289, 16,779,575" ?
I have unsuccessfully tested "maxvals" and "numval" :
{{#invoke:wd|properties|normal+|Q55|P1082|maxvals=3}} (display ever :"17,942,942, 17,590,672, 17,407,585, 17,282,163, 17,181,084, 17,081,507, 17,000,000, 16,829,289, 16,779,575, 10,026,773")
and
{{#invoke:wd|properties|normal+|Q55|P1082|numval=3}} (display ever :"17,942,942, 17,590,672, 17,407,585, 17,282,163, 17,181,084, 17,081,507, 17,000,000, 16,829,289, 16,779,575, 10,026,773")
Second question :
{{#invoke:wd|properties|normal+|Q55|P1082}} display :"17,942,942, 17,590,672, 17,407,585, 17,282,163, 17,181,084, 17,081,507, 17,000,000, 16,829,289, 16,779,575, 10,026,773",
how can I to reverse the chronological order for to display : "17,132,854 17,000,000, 10,026,773, 16,779,575, 16,829,289, 17,181,084" ?
I have unsuccessfully tested "sorttype = inverted" :
{{#invoke:wd|properties|normal+|Q55|P1082|sorttype = inverted}} (display ever :"17,942,942, 17,590,672, 17,407,585, 17,282,163, 17,181,084, 17,081,507, 17,000,000, 16,829,289, 16,779,575, 10,026,773")
My project is to do this table on page https://fr.wikipedia.org/wiki/Épidémie_de_maladie_à_coronavirus_de_2020_en_France#Localisation_des_cas to https://en.wikipedia.org/wiki/2020_coronavirus_outbreak_in_France.
Thanks, --Viruscorona2020 (talk) 05:09, 10 March 2020 (UTC)--Viruscorona2020 (talk) 05:05, 10 March 2020 (UTC)
- Both are currently not possible, although you can create a template that achieves the first like this:
{{#titleparts:{{#invoke:wd|properties|normal+|Q55|P1082|sep%s=/|sep=}}|1|1}}, {{#titleparts:{{#invoke:wd|properties|normal+|Q55|P1082|sep%s=/|sep=}}|1|2}}, {{#titleparts:{{#invoke:wd|properties|normal+|Q55|P1082|sep%s=/|sep=}}|1|3}}
- ↓
- 17,942,942, 17,590,672, 17,407,585
- I'm actually working on a sort function, but not sure when that'll be done as it's quite complicated. Thayts ••• 18:39, 14 March 2020 (UTC)
- @Thayts: Hi! I just wanted to say thank your for this powerful and awesome module, and I really hope you get that sorting function sorted out soon. Having it would make it possible to efficiently use the latest data for the pandemic (thus allowing international collaboration and saving so much volunteer effort) and being able to autogenerate graphs (with Module:Graph) about the pandemic (and so many other graphs, of course). I understand that doing the functionality properly may be complicated, but isn't there a chance to do a not-so-proper solution for the time being (one that only sorts per point-in-time, for example, rather than any arbitrary qualifier)? Thanks, really. Sophivorus (talk) 19:22, 18 April 2020 (UTC)
- Actually I was able to produce a reasonable graph, so sorry for my rash comment. Still sorting would be great, cheers! Sophivorus (talk) 22:10, 18 April 2020 (UTC)
- Great! Yes, it would indeed be great, but it's far from trivial to implement because of the many different datatypes that I suddenly need to take into account and the data model that is currently string-based. But I'll see if I will continue work on that soon again. Thayts ••• 22:49, 18 April 2020 (UTC)
- Actually I was able to produce a reasonable graph, so sorry for my rash comment. Still sorting would be great, cheers! Sophivorus (talk) 22:10, 18 April 2020 (UTC)
- @Thayts: Hi! I just wanted to say thank your for this powerful and awesome module, and I really hope you get that sorting function sorted out soon. Having it would make it possible to efficiently use the latest data for the pandemic (thus allowing international collaboration and saving so much volunteer effort) and being able to autogenerate graphs (with Module:Graph) about the pandemic (and so many other graphs, of course). I understand that doing the functionality properly may be complicated, but isn't there a chance to do a not-so-proper solution for the time being (one that only sorts per point-in-time, for example, rather than any arbitrary qualifier)? Thanks, really. Sophivorus (talk) 19:22, 18 April 2020 (UTC)
Merge i18n and aliasesP
Hi! First of all let me say this module is awesome, super thanks to the developers! I just ported it to the Spanish Wikipedia and it's going great. The thing that surprised me the most, though, was the separation between Module:Wd/i18n and Module:Wd/aliasesP. It seems unnecessary to me and even counterproductive for easy and effective localization. So I'm thinking about merging them as my first contribution to this module (I'm an experienced developer and have some experience with modules too). However, before I do anything, I'd like to ask more experienced contributors if there's some reason for keeping them separated that maybe I'm not seeing. Thanks! Sophivorus (talk) 11:25, 15 April 2020 (UTC)
- @Sophivorus: Thanks! The separation exists because they serve different purposes. Module:Wd/aliasesP used to be integrated in Module:Wd, but then I wanted to make use of the aliases list in Module:Wd/i18n too so I took it out of the main module. Module:Wd/aliasesP is not dependent on locale, so it doesn't really fit in an internationalization submodule. That's why I made it a separate submodule. Thayts ••• 22:47, 18 April 2020 (UTC)
- Actually, I figured we don't need to have the aliasesP in a separate submodule. So I've made an update to include it in the main module again and requested to delete Module:Wd/aliasesP. Thayts ••• 10:49, 19 April 2020 (UTC)
Not most recent value if point-in-time is missing for one of the values
{{wd|properties|Q180445|P1240|P585}}
-> 2, 3
gave 2,3, i.e. two values. I want the most recent value, 3, which is from point-in-time 2019, and is the last in the list. I have tried the current, normal, normal+, best and single options but none of them helps. Probably because the older and first value in the list does not have a point-in-time (P585). My only solution is to apply {{last word}}, which gives 3. But that is an ugly solution - the most recently entered value is to my understanding typically but not always the last in the list, and should be the default if there is no timing info. However, your module gives the correct date if I enter
{{#invoke:wd|qualifier|normal+|single|Q180445|P1240|P585}}}
-> September 2019.
(I would prefer a y or yyyy option to only get the year. Now I have to apply {{last word}} to get the year.) I need value and date separated from each other, since the value is visualized graphically, and need to be sure that correct date is shown for correct value. [edited afterwards]
Tomastvivlaren (talk) 02:07, 23 November 2019 (UTC)
- We're always dependent on the quality of the data in Wikidata for accuracy. We can make assumptions, but those are often also inaccurate. Assuming that the claim that was added last is the most up-to-date, for example, does not always hold if historic information was added later. Instead, Wikidata offers tools that allow us to select the most relevant information. In this case the rank tool can be used to mark 3 as the preferred claim. This module sorts claims based on this rank, from preferred to deprecated, so you will see that
{{wd|property|Q180445|P1240}}
[-> 2 ] returns the preferred value. - The qualifier command gives the date value that you want since that is the only matching qualifier it could find. If claim 2 also had a qualifier of the same type, then that would also be returned. You could even use the (raw) qualifier value to select the claim that you want, but that is not a reliable solution since claim 2 could be assigned the qualifier in the future. Instead, the best way to go is to set the preferred rank in Wikidata which I just did.
- Regarding the date, you could also do this:
{{#time:Y|{{wd|qualifier|raw|Q180445|P1240|P585}}}}
[ -> 2019 ]. If you want to get the value together with the year (and{{wd|property|qualifier|Q180445|P1240|P585}}
[ -> 2 ], which also returns the month, is not good enough), then you could make two separate calls to construct value+qualifier. However, it's then depending on the rank and the presence of the qualifier if it is selected from the same claim as the value, so it would be best to keep it in a single call (like the{{wd|property|qualifier|...
I just gave). And then an option to get only the year would indeed come in handy. I'll put it on my to-do list. Thayts ••• 12:36, 23 November 2019 (UTC) [I added the current code response in your answer, within brackets]
- Thankyou user:Thayts for prompt reply. However, then a bot should change the ranking to preferred value on thousands of Wikidata Items, or add point-in-time to the old values. If I restore the ranking for this item, the problem seems to return. You have not considered an option that allows the user to omit values without point-in-time - or to default prioritize those values that have a point-in-time? At Swedish Wikipedia, I just found out that the Swedish sv:module:Wikidata2 offers such an option, and solves my problem for now. At other wikipedias, where Wikidata2 is not installed, I really would like to use your module. (It is a petty that different Wikipedias cannot agree on a standardized set of modules, and that every Wikipedia has its own local culture regarding what module that people expect us to use.) Tomastvivlaren (talk) 23:42, 23 November 2019 (UTC)
- @Tomastvivlaren and Thayts: Hello! I have been trying to solkve exactly the same issue. For Covid-19 related articles it would be very useful to get the current, most recent property using the Wd module. Properties like P1120 (death counts) are updated every day for hundreds of items via the quickstatements tool, which does not support prefferred rank. It would be great for standardizing sources in the covid-19 situation if we could retrieve the latest (or highest) modification. TiagoLubiana (talk) 11:35, 27 April 2020 (UTC)
Seeking newest value, rather than current value
It looks like the configuration flags currently prioritize future, then current, then past values for values that have a start time/end time qualifier. But I'm trying to fetch the most recent result for a value that instead has a point in time qualifier. Is there any way to do that, and if not, could that functionality be added? {{u|Sdkb}} talk 06:59, 31 July 2020 (UTC)
- I'm working on a more generic function to sort on any qualifier (or the property value itself), with which this can also be achieved. I'll let you know once it's available. Thayts ••• 18:37, 8 August 2020 (UTC)
- Thayts, thanks, that sounds great; please do give me a ping when it's ready! {{u|Sdkb}} talk 18:45, 8 August 2020 (UTC)
Unable to fetch reference properly
For Q7227384, I'm trying to fetch the reference for the most recent (preferred rank) value of "employees" with the qualifier "applies to part, aspect, or form" equal to "faculty member" (i.e., I'm trying to fetch the reference for the current number of faculty members, as opposed to administrative staff). I was able to get the number of faculty via {{wikidata|property|normal+|current|P1128|P518=Q5428874|page=Pomona College}}
, but trying to use {{wikidata|reference|normal+|current|P1128|P518=Q5428874|page=Pomona College}}
returns all the references for the faculty count (although not the ones for administrative staff), not just the most recent, preferred rank one. I think this may be a bug, since the documentation here says that using "reference" rather than "references" should only return a single value. Help, anyone? {{u|Sdkb}} talk 04:37, 14 August 2020 (UTC)
- Sdkb,
reference
only returns a single value per claim. To access only one claim, use thesingle
flag like so: {{wikidata|reference|normal+|current|single|P1128|P518=Q5428874|page=Pomona College}}
- This was indeed not properly documented, so I've improved that. Thayts ••• 08:32, 14 August 2020 (UTC)
- Thayts, that works; thanks! {{u|Sdkb}} talk 08:41, 14 August 2020 (UTC)
When importing into local wiki, error getGlobalSiteID nil value
Can anyone head me in the right direction to fix the error on this module when I import it into my own wiki?
Lua error in Module:Wd at line 196: attempt to call field 'getSiteGlobalId' (a nil value).
The line in question has this code:
cfg.siteID = mw.wikibase.getGlobalSiteId()
I have wikibase installed and seemingly working. In my LocalSettings.php I have the following definition for all of my local language wikis:
$wgWBClientSettings['siteGlobalID'] = $wikiId;
Where $wikiId resolves to the language identifier "en", "es", "it", "fr", "de", "pt", etc. My Wikibase is working and I can set interwiki language links just fine.
Why could the LUA script for this module be choking at this point?
I don't have any experience with LUA, I know PHP and Javascript, jQuery, some Java and C++, .NET... But I'm seeing there is a LUA console for debugging purposes when editing the module page. So I tried logging some values on my local wiki:
mw.log(mw.wikibase)
tells me that mw.wikibase is a table
mw.logObject(mw.wikibase)
tells me that in fact the function getGlobalSiteID doesn't exist:
["getEntityUrl"] = function#12,
["getLabel"] = function#13,
Whereas if I log the same on the wikipedia module page, I see:
["getEntityUrl"] = function#12,
["getGlobalSiteId"] = function#13,
["getLabel"] = function#14,
Doing a little more research, I see that the getGlobalSiteId function should be defined by the Wikibase client Lua module, see [5]https://www.mediawiki.org/wiki/Extension:Wikibase_Client/Lua#mw.wikibase.getGlobalSiteId.
I wonder then why my Wikibase doesn't have this definition?
Lwangaman (talk) 15:00, 2 September 2020 (UTC)
- @Lwangaman:
getGlobalSiteId
is a fairly recent addition to Wikibase, added in version 1.35. What version of Wikibase are you running? Thayts ••• 16:21, 2 September 2020 (UTC)
- @Thayts: Okay I see, I'm using 1.34. I'll look into updating my wiki to 1.35... Probably a smart move going forward seeing I'm still at the start. Lwangaman (talk) 17:04, 2 September 2020 (UTC)
- 🙂 Good luck! Thayts ••• 17:16, 2 September 2020 (UTC)
Multilingual Templates and Modules
Hi! Are you aware of mw:Multilingual Templates and Modules? As a fellow Wikimedian and module developer, I strongly recommend you take a look. And by the way, thanks for this amazing module! Sophivorus (talk) 22:27, 2 September 2020 (UTC)
Making author names imported from Wikidata references display as "Last, First" rather than "First Last"
You are invited to join the discussion at wikidata:Wikidata:Project chat § "Last, First" for references rather than "First Last". {{u|Sdkb}} talk 03:45, 20 September 2020 (UTC)
Fewer decimals in areal
Hi. Does anyone knows if its possible to use {{Wikidata}} to lower the outcome of the decimals in areal? For example: If you use {{Wikidata|property|P2046}} in Avondale, Arizona you will get the outcome of "117.380821 square kilometre", but thats a lot of decimals. If someone knows how to lower it to two decimals (or without decimals at all), I will be greatful. Thanks. --- Løken (talk) 12:21, 6 November 2020 (UTC)
- Currently there's no option for this, but I'll include it in the upcoming update. Thayts ••• 23:45, 13 November 2020 (UTC)
- @Thayts: Thanks. It is fixed on no.wp. (diff) --- Løken (talk) 00:55, 14 November 2020 (UTC)
Improved citation formatting
I wish {{wikidata|references}}
produced more normal-looking citations. For example, I just used this template at Wikifonia#Termination, which used d:Q7999853#P576 like this:
{{wikidata|references|Q7999853|P576}}
References
- ^ Wikifonia (30 December 2013). "Dear Wikifonia fans, the Wikifonia site is not available anymore". Retrieved 1 December 2020.
- ^ Lukasiwicz (25 December 2013). "What happened to Wikifonia?". Retrieved 1 December 2020.
- ^ Wikifonia (30 December 2013). "Dear visitor,The Wikifonia site is not available anymore". Retrieved 31 December 2013.
- ^ photoman (30 December 2013). "Wikifonia - is down; but is it "out"?". Retrieved 2 December 2020.
Note especially the "author name string" spelled out. No human would produce a citation like that. I with {{wikidata|references}}
would produce this kind of citation:
{{citation |author=Lukasiwicz |date=25 December 2013 |title=What happened to Wikifonia? |url=https://www.saxontheweb.net/threads/what-happened-to-wikifonia.198166/post-2154479 |access-date=1 December 2020}} ''Additional parameters here''
Lukasiwicz (25 December 2013), What happened to Wikifonia?, retrieved 1 December 2020 Additional parameters here
Daask (talk) 14:55, 2 December 2020 (UTC)
- I did not know of the existence of author name string (P2093) until now, I will take it into account in the upcoming update. Thayts ••• 19:35, 2 December 2020 (UTC)
Entity label in a specific language
How to get Wikidata entity label in a specific language? Soshial (talk) 16:56, 29 November 2020 (UTC)
- It is currently not possible to select a different language than the wiki's language. Thayts ••• 19:31, 2 December 2020 (UTC)
- Thanks for the answer! Is there a corresponding phabricator issue/enhancement to vote for? Soshial (talk) 12:03, 3 December 2020 (UTC)
The "edit" (pen shaped) argument does not work properly
Hi, and thanks, I recently changed Google Chrome article at its Infobox part to fetch its "latest release" data by this template from its wikidata item. But it has a serious problem, when we click at the "pen shaped" link to edit its wikidata item, the link is redirected to the page https://www.wikidata.org/wiki/Q777?uselang=en#P348 and scrolls to "software version identifier" and at the top of it, and not scrolled to the correct position, that is at version "88.0.4324.39", for example. And this scenario also occurs for all of the "pen shaped" links in Google Chrome's Infobox, meaning that all of them are scrolled at the top of "software version identifier", and not scrolled correctly at the true "version" position. And this problem is a serious one.
Would anyone have any idea about this bug, and can it be corrected? Thanks again, Hooman Mallahzadeh (talk) 14:09, 20 December 2020 (UTC)
- Hi, it does work as intended as it brings you to the property block that was requested. It does seem like it's now also possible to jump to individual properties. I'll add an option for this in the next release. Thayts ••• 17:14, 23 December 2020 (UTC)
Return property value by unit
Is it possible to sort out by a specific unit? Soshial (talk) 13:14, 15 January 2021 (UTC)
- Please could you provide an example? — Martin (MSGJ · talk) 23:30, 15 January 2021 (UTC)
Fetch link and transclude linked page
I'm attempting to transclude all linked pages under a property, and I'm hoping there's a way to use wd to achieve this.
I'm trying to do something like this:
{{#invoke:wd|properties|linked|Q151973|P26|format=\{\{:%p\}\}<br>}}
To give me this:
{{:Elizabeth Taylor}}
{{:Sybil Christopher}}
{{:Suzy Miller}}
{{:Elizabeth Taylor}}
{{:Sally Burton}}
But I want it to actually transclude those pages in this order.
Is something like this possible? El Dubs (talk) 07:49, 18 January 2021 (UTC)
- That's unfortunately not possible, unless you substitute the result like this:
- {{subst:#invoke:wd|properties|Q151973|P26|format=\{\{:%p\}\}<br>}}
- Thayts ••• 21:48, 18 January 2021 (UTC)
References
Is references
supposed to return all the references, because it seems to be returning just the first one? Example:
{{#invoke:wd|property|references|Q3395654|P2043}}
-> 40.1 kilometre[1][2]
— Martin (MSGJ · talk) 21:18, 19 January 2021 (UTC)
References
- ^ https://environment.data.gov.uk/catchment-planning/WaterBody/GB108048001440.
{{cite web}}
: Missing or empty|title=
(help) - ^ https://environment.data.gov.uk/catchment-planning/WaterBody/GB108048002000.
{{cite web}}
: Missing or empty|title=
(help)
- There is actually only one reference for that statement, but it has two reference URLs. This module only picks the first one, as it assumes there will be a maximum of one reference URL per reference. What could be done is to split the reference into two on Wikidata. Thayts ••• 19:23, 20 January 2021 (UTC)
- Perfect, thanks! — Martin (MSGJ · talk) 10:30, 21 January 2021 (UTC)
Red link
When using linked option, the module will not return a link if the article does not exist. Is there any option to create a red link in this case? If not, could this option be considered? Best regards — Martin (MSGJ · talk) 20:51, 7 January 2021 (UTC)
- I suppose I could just get the raw label and put [[ ]] around it. But the problem with that approach is it might link to a completely different article, so an ifexist check is needed. I would like to draw the attention of this module's maintainers to the logic employed at Template:Wikidata fallback link, which will product a redlink if the article indicated by the label does not yet exist. Could some of that logic be employed here? — Martin (MSGJ · talk) 10:17, 8 January 2021 (UTC)
- If you create a link out of a label, then there is no guarantee that it will be red. If it happens to be equal to an existing article's name, then it might link to an irrelevant article. Thayts ••• 21:44, 18 January 2021 (UTC)
- Exactly - that's why I mentioned the logic in Template:Wikidata fallback link — Martin (MSGJ · talk) 10:31, 21 January 2021 (UTC)
- If you create a link out of a label, then there is no guarantee that it will be red. If it happens to be equal to an existing article's name, then it might link to an irrelevant article. Thayts ••• 21:44, 18 January 2021 (UTC)
Use P1343 as reference
I would like to use described by source (P1343) and format it as an inline reference. Is this possible? — Martin (MSGJ · talk) 22:37, 1 February 2021 (UTC)
- This has been answered at Template talk:Cite Q#Use P1343 as reference — Martin (MSGJ · talk) 20:55, 2 February 2021 (UTC)
Use abbreviated unit
Is there any way to use an abbreviated unit? For example:
{{#invoke:wd|properties|references|qualifiers|Q15217395|P2929|P462}}
→ 10 nautical mile (white),[1] 7 nautical mile (red)[1]
It would be nice to use nmi instead of "nautical mile". There is unit symbol (P5061) which could be used to obtain the correct symbol from Wikidata — Martin (MSGJ · talk) 21:00, 2 February 2021 (UTC)
- Not currently, but I'm having plans to introduce it in the next update. Thayts ••• 17:42, 10 February 2021 (UTC)
References
Reference naming/duplication redux
I see in the archive that Mike Peel brought up reference naming for this template a while back. I've been encountering a similar issue, so I wanted to raise it again to see if we can figure something out.
Reference reuse is working fine when sourcing the same fact from Wikidata twice (say, in both the infobox and the lead), since we can just use {{wikidata|references|Pxxx}}
twice and they'll be merged. However, it isn't working when the same reference is used both from Wikidata to support one fact and in the article to support another. In this case, even if the display is exactly the same, the references remain separate. Moreover, it wouldn't be advisable to replace the article-based reference with the Wikidata-based one, since the Wikidata one could switch to a new reference that doesn't support the second fact. (Let me know if the above is confusing and I can provide an example.)
Would we be able to figure out any way so that the software can identify references that display the same and merge them, even if one comes from Wikidata and the other does not? {{u|Sdkb}} talk 20:59, 10 February 2021 (UTC)
- Hmm, experimenting a bit, this goes a little beyond just Wikidata.
<ref name="Name1">Foobar</ref><ref name="Name2">Foobar</ref>
display as two references ([1][2]), not one as they should, so the problem seems to be that the name difference alone throws off the software. I created a phab task. Even if we could have a working{{wikidata|references|P4700|refname=Name1}}
, we wouldn't want to reuse<ref name="Name1"/>
for instances where a difference fact is being supported, since the Wikidata reference could change. {{u|Sdkb}} talk 21:06, 10 February 2021 (UTC)- They display as two references because the name attribute is different. They only get merged if the name attribute is equal. I believe this is quite fundamental to the way references work in Mediawiki. If you want this module to use the same name attribute for any reference with the same contents that is defined in the article itself, then I guess the only thing that could be done is to get the article text (something that I've just figured out how to do as mentioned in the Dates don't respect MDY tag section) and scan for references. However, this is quite cumbersome and if the references are off by a few characters or show stuff in a different order, this is not going to work. On the other hand, if the references use the {{Citation}} template then we might be able to match on parameter values, but this still goes wrong quickly if a parameter has been set that this module doesn't recognise. Thayts ••• 23:11, 10 February 2021 (UTC)
As I suggested on Template talk:Cite Q, if the reference is described by a Wikidata item, for example:
67 metre[3]
which uses Reeds PBO Small Craft Almanac 2014 (Q25198336), then the most appropriate name for this reference is Q25198336. Then if this reference is used again in the article, the same name can be used to group them together. — Martin (MSGJ · talk) 12:20, 11 February 2021 (UTC)
- That would be possible indeed. However, {{Cite Q}} has more parameters than just the QID, for example "pages", "chapter" and "access-date". Module:Wd gives different names to such references that have the same QID but different parameters (because they are not completely the same). If you wouldn't do that, then only one would become prominent (and on some wikis even cause conflict errors) which might not be applicable to all instances. Also, this only works for references for which {{Cite Q}} can be used. Module:Wd also uses {{Cite web}} for references that contain a URL. Thayts ••• 18:27, 11 February 2021 (UTC)
- MSGJ, you seem to be talking about something different. Here's an example of what I'm trying to fix: at this revision of Scripps College, the academic staff count in the infobox has been converted to draw from Wikidata, with the code (slightly simplified)
{{wikidata|property|references|normal+|current|single|P1128|P518=Q5428874}}
, generatingAcademic staff: 136[4]
. However, the Common Data Set is also used to support Scripps' student body size in the body of the article, using the more typical code<ref name=CommonDataSet19-20>{{cite web|url=http://www.scrippscollege.edu/assessir/wp-content/uploads/sites/30/2019-2020-CDS_FINAL-4.pdf|title=Scripps College Common Data Set 2019-2020 |publisher=Scripps College}}</ref>
, generating.[5] These references are exactly the same, but they are not merged because the ref names are different (this is the bug I created a phab ticket for). We want to keep them separate in the code because, although they are using the same source, they are supporting different facts, and if the Wikidata reference is updated, it might switch to something that supports only the faculty count, not the student body size. However, we want them to be merged in the display for the reader because they are currently the same source. I'm pretty sure there's no way to do that until the phab ticket is resolved. {{u|Sdkb}} talk 20:02, 11 February 2021 (UTC)
- MSGJ, you seem to be talking about something different. Here's an example of what I'm trying to fix: at this revision of Scripps College, the academic staff count in the infobox has been converted to draw from Wikidata, with the code (slightly simplified)
References
- ^ Foobar
- ^ Foobar
- ^ Reeds PBO Small Craft Almanac 2014. p. 41. ISBN 978-1-4081-9330-3. OL 32692860M. Wikidata Q25198336.
- ^ "Scripps College Common Data Set 2019-2020" (PDF). Scripps College.
- ^ "Scripps College Common Data Set 2019-2020" (PDF). Scripps College.
Get language code
How can I get the language code for the value of a statement?
--Lectrician1 (talk) 20:32, 12 February 2021 (UTC)
- Currently you can't. This will be supported in the upcoming update, though. Thayts ••• 22:26, 12 February 2021 (UTC)
Dates don't respect MDY tag
I've noticed that dates retrieved from Wikidata don't respect {{use mdy dates}} tags on articles. Could this be fixed? {{u|Sdkb}} talk 02:45, 21 December 2020 (UTC)
- Wait, I just noticed the mdy configuration flag. That helps somewhat, but it'd still be better to respect the tags so that the configuration flag isn't needed every time. {{u|Sdkb}} talk 04:16, 21 December 2020 (UTC)
- Hi, I have no idea how tags on pages can be read by the module, unfortunately. Unless there is a property inside the linked Wikidata item that tells the preferred date order, I don't think this is possible to automate. Thayts ••• 17:17, 23 December 2020 (UTC)
- In some case it might be possible to deduce the best default date format from the country (P17) if defined ... — Martin (MSGJ · talk) 16:35, 13 January 2021 (UTC)
- @MSGJ and Thayts: Do we know how {{Citation}} is reading the mdy/dmy tags? We'd presumably want this to do it the same way. {{u|Sdkb}} talk 20:25, 10 February 2021 (UTC)
- Sdkb, I was not aware of that module being able to do so, nor of the existence of
mw.title.getCurrentTitle():getContent()
that it uses to get the actual article text. I'll further look into this. Thayts ••• 23:03, 10 February 2021 (UTC)- I've mentioned at VPT here, as there's some wider applicability to being able to respect date formats outside just citations. {{u|Sdkb}} talk 03:03, 15 February 2021 (UTC)
- Sdkb, I was not aware of that module being able to do so, nor of the existence of
- @MSGJ and Thayts: Do we know how {{Citation}} is reading the mdy/dmy tags? We'd presumably want this to do it the same way. {{u|Sdkb}} talk 20:25, 10 February 2021 (UTC)
- In some case it might be possible to deduce the best default date format from the country (P17) if defined ... — Martin (MSGJ · talk) 16:35, 13 January 2021 (UTC)
- Hi, I have no idea how tags on pages can be read by the module, unfortunately. Unless there is a property inside the linked Wikidata item that tells the preferred date order, I don't think this is possible to automate. Thayts ••• 17:17, 23 December 2020 (UTC)
Capitalise first letter
What's the easiest way to capitalise the first letter of a word obtained from Wikidata? I think ucfirst will not work on a link or if references are appended. Thanks — Martin (MSGJ · talk) 19:18, 23 January 2021 (UTC)
- It's indeed not possible to capitalise the first letter, unless you make it appear capitalised using CSS. Please see the previous discussion about this. Thayts ••• 17:36, 10 February 2021 (UTC)
- Module:String2 has a "smart" ucfirst function that finds the first item in a list and capitalises it. It also works with piped links.
{{#invoke:String2| ucfirst | human X chromosome }}
→ Human X chromosome{{#invoke:String2| ucfirst | [[chromosome]] }}
→ Chromosome{{#invoke:String2| ucfirst | [[Chromosome|human X chromosome]] }}
→ Human X chromosome{{#invoke:String2| ucfirst | {{ubl | human | cat | dog }} }}
→- Human
- cat
- dog
{{#invoke:String2| ucfirst | {{ubl | [[human]] | [[cat]] | [[dog]] }} }}
→- Hope that helps. --RexxS (talk) 21:46, 20 February 2021 (UTC)
Equivalent calls from within other modules
@Thayts: I was asked today how to call Module:Wd from other modules, so I made a brief demo at Module:Sandbox/RexxS/Wd and put some comparisons with the corresponding {{Wikidata}} calls on its talk page at Module talk:Sandbox/RexxS/Wd. I don't want to mess with your documentation, but I think those simple examples would prove useful to budding coders. Please feel free to take them and use them any way you want - absolutely no attribution required. Cheers --RexxS (talk) 21:56, 20 February 2021 (UTC)
- Thanks RexxS, I'll take a look! Thayts ••• 10:16, 21 February 2021 (UTC)
Get a person's date of birth from Wikidata
Good morning. Sorry if I write here, I don't know if it is the best place to ask the following question: How do I get from Wikidata the date of birth of a person expressed in day and month without the year (DD-MM)? Which template is the most suitable for obtaining this type of data? it's possible? Many thanks to anyone who would answer the courtesy and helpfulness. --Fierodelveneto (talk) 10:17, 23 April 2021 (UTC)
- At enwiki, getting a date of birth from Wikidata is controversial although some templates do it. It's controversial because the result rarely has a reliable source and is easily broken by hard-to-find vandalism. However, if you can get a valid date, you can use #time (mw:Help:Extension:ParserFunctions) to change it to your desired format. For example,
{{#time:d-m|1 April 1982}}
→ 01-04
- In general, WP:VPT might be a better place for questions like this. Johnuniq (talk) 10:45, 23 April 2021 (UTC)
- @Johnuniq: Hello! Thank you for your answer. So you can use it in the {{WikidataOi}} template with the P569 property? Could you give me an example applied with the parser function? Thank you very much! --Fierodelveneto (talk) 14:43, 23 April 2021 (UTC)
- @Fierodelveneto: For example,
{{#time:d-m|{{wikidataoi|property|raw|Q6279|P569|fetch=true}}}}
→ 20-11- Thayts ••• 21:13, 23 April 2021 (UTC)
- @Johnuniq: Hello! Thank you for your answer. So you can use it in the {{WikidataOi}} template with the P569 property? Could you give me an example applied with the parser function? Thank you very much! --Fierodelveneto (talk) 14:43, 23 April 2021 (UTC)
Titles from other wikipedias
@Thayts:, this is my first time looking at this, and I'm a bit overwhelmed. Is there a way I can extract the title of a linked Wikipedia article? For example: given Q43287 (German Empire) and a lang code 'fr', it should return the string 'Empire allemand', from the linked French article fr:Empire allemand. So, we'd have something like this:
{{wikidata|wikipedia|lang=es|eid=Q43287}}
→ Imperio alemán
Is there anything like that present? I can't figure it out, from the doc. And with |linked=
, then it would generate [[:es:Imperio alemán|Imperio alemán]]
, etc. Thanks in advance. (please mention me on reply; thanks!) Mathglot (talk) 22:09, 18 April 2021 (UTC)
- @Mathglot: No, not as of now. The module has primarily been focused on supporting the local wiki only (i.e. returning values in the local language). But I might include an option in the next update! Thayts ••• 21:53, 22 April 2021 (UTC)
- Thanks. Mathglot (talk) 09:46, 24 April 2021 (UTC)
Courtesy notice
You are invited to join the discussion at Wikipedia talk:AutoWikiBrowser/Rename template parameters § Wikidata aliases. {{u|Sdkb}} talk 06:29, 13 August 2021 (UTC)
Making sure pieces of data belong to each other?
Hi, could someone explain more about this quote from the documentation?
Combine multiple commands into one call to this template, instead of making multiple calls to this template with one command each, to be sure that all the returned pieces of information belong to each other.
I assume this means that if I make multiple calls with one command each, then the pieces of information may belong to different statements. Is my understanding correct? If so, when and why does this happen, and can you give a working example? On another note, can multiple calls of the same module/template code result in different data being returned on different calls? Winston (talk) 05:23, 5 September 2021 (UTC)
- @Notsniwiast: Yes, your understanding is correct. For example, if you would like to take the shape (P1419) of the Earth (Q2) together with its sourcing circumstances (P1480) and you request those in separate calls, then you don't get the desired result:
{{wd|property|Q2|P1419}} ({{wd|qualifier|single|Q2|P1419|P1480}})
→ geoid (roughly)- If you are under the assumption that always the claim with the preferred rank is used, then you will be surprised to see "roughly" returned. This is because the preferred "geoid" property does not have a sourcing circumstances qualifier, but some with a normal rank do, so it simply selects these as they are the best ranked claims that do have a qualifier value of this type (I've added
single
just to return the qualifier of the first of two matching claims it finds). Instead, you should do this: {{wd|property|qualifier|Q2|P1419|P1480}}
→ geoid- You could use the
preferred
flag in the first example to restrict access to claims with that rank, but if there is more than one preferred claim then you end up in the same situation. - Also, I don't think multiple calls with the same parameters could result in different data, assuming that Wikidata always returns claims/statements in the same order (even for claims with the same rank). Thayts ••• 22:54, 15 September 2021 (UTC)
Language of monolingual text
Is there any way to obtain the language of a value of native label (P1705) or official name (P1448)? — Martin (MSGJ · talk) 20:18, 25 October 2021 (UTC)
Getting values (labels) from a local Wikipedia
... {{#invoke:WikidataIB|getSiteLink|qid=Q4272739|wiki=ruwiki|ps=1}}
An example above is how you get a value from a given entity for a different wiki (in this case for Russian Wikipedia) by using WikidataIB module. How do I the same with this one? AXONOV (talk) ⚑ 14:34, 6 November 2021 (UTC)
- Nothing in the documentation indicates to me that this module can do that. Just use WikidataIB? — Martin (MSGJ · talk) 15:57, 27 November 2021 (UTC)
Phabricator task: Improve VisualEditor workflow for updating Wikidata values on Wikipedia articles that use Template:Wikidata
Input from folks here would be welcome at phab:T297854. Cheers, {{u|Sdkb}} talk 01:40, 16 December 2021 (UTC)
Controlling precision of dates
Often, when I'm fetching a date from Wikidata using this module, I'm only interested in the year, not the exact day, which would be too much precision for readers. I can accomplish that by wrapping the result in {{year}}, but that gets clunky (especially when there's references too). Would there be a way to add functionality to this that'd let me set a desired precision within it? {{u|Sdkb}} talk 09:25, 23 November 2021 (UTC)
- Yes, please! This would be really helpfull. @Thayts: is this something you could help with? Tholme (talk) 20:17, 13 January 2022 (UTC)
- I haven't had the time for the past period to work on this module, but soon I will. Thayts ••• 16:19, 14 January 2022 (UTC)
Suggested wishlist items
There are several wishlist items this year that relate to this template. I'd particularly encourage folks to go support Tool to add Wikidata to an article. Cheers, {{u|Sdkb}} talk 22:56, 29 January 2022 (UTC)
Wrap label in nowiki?
At this testcases page, there is an example of a failure to render a retrieved label correctly, because the label has three ' (apostrophe) characters in a row. That string of three ' is rendered as bold markup instead of plain text. Please see this discussion for a similar problem with trusting raw wikidata values to be valid as wikitext output.
Can someone please wrap the label in nowiki formatting so that this problem does not happen? I suspect that there are subtle instances of this sort of error caused by this module on many article pages, not just this one testcases page. Here's a diff showing one way to handle the raw Wikidata text. – Jonesey95 (talk) 15:32, 17 February 2022 (UTC)
- Pinging Uzume, for whom this might be a quick fix. – Jonesey95 (talk) 15:32, 17 February 2022 (UTC)
- @Jonesey95: Okay, I fixed two things for that. First I did 1072641193 to fix the issue of escaping raw Wikidata labels when used in wikitext links but that did not fix the aforementioned test case because the testcase uses a Wikidata item that had no applicable sitelinks and the code avoided making a link for such cases (despite making links for properties which never have sitelinks). So then I did 1072645968 to make it so that Wikidata items will always yield links (when requested). They will continue to use applicable sitelinks when available but will fallback to linking to Wikidata in a fashion similar to how it handled properties (which never have sitelinks). —Uzume (talk) 19:22, 18 February 2022 (UTC)
- Thanks for your attention. I never understand 100% of conversations when Wikidata is involved, but the testcases page that I linked above displays properly now. – Jonesey95 (talk) 19:31, 18 February 2022 (UTC)
- @Jonesey95: Well, if you like, I can attempt to explain things at Wikidata in more detail. Let me know if you are interested. —Uzume (talk) 19:50, 18 February 2022 (UTC)
- Thanks for your attention. I never understand 100% of conversations when Wikidata is involved, but the testcases page that I linked above displays properly now. – Jonesey95 (talk) 19:31, 18 February 2022 (UTC)
- @Jonesey95: Okay, I fixed two things for that. First I did 1072641193 to fix the issue of escaping raw Wikidata labels when used in wikitext links but that did not fix the aforementioned test case because the testcase uses a Wikidata item that had no applicable sitelinks and the code avoided making a link for such cases (despite making links for properties which never have sitelinks). So then I did 1072645968 to make it so that Wikidata items will always yield links (when requested). They will continue to use applicable sitelinks when available but will fallback to linking to Wikidata in a fashion similar to how it handled properties (which never have sitelinks). —Uzume (talk) 19:22, 18 February 2022 (UTC)
Linking non-notable people to Wikidata entry
I discovered here that when I use the "linked" flag, it produces this: [1]. I want to use the flag so that NOAA will be linked, but when I do so, it also links to the Wikidata entry the author, who is not notable. This is not desirable, since only notable topics should be wikilinked. Could this behavior be disabled?
References
{{u|Sdkb}} talk 18:53, 20 February 2022 (UTC)
- Another problem with
{{wikidata|references|linked|P186|Q1997|page=Atmosphere of Earth}}
is that it adds|access-date=
using the date of the most recent en.wiki article refresh. Today, that is 20 February 2022. Tomorrow it will be 21 February 2022 and etc. That is wholly and completely wrong.|access-date=
is used to identify the date that a human editor confirmed that the cited source supported the text in an en.wiki article. A fixed-in-time|access-date=
allows editors to locate an appropriate archive snapshot if (when) the source goes 404. - —Trappist the monk (talk) 19:14, 20 February 2022 (UTC)
- @Trappist the monk, it doesn't look like that's the case. It's using the retrieved (P813) value at Wikidata; I just set it to two days ago, and now it reads February 18. {{u|Sdkb}} talk 20:51, 20 February 2022 (UTC)
- Yeah, ok.
- —Trappist the monk (talk) 23:42, 20 February 2022 (UTC)
- @Trappist the monk, it doesn't look like that's the case. It's using the retrieved (P813) value at Wikidata; I just set it to two days ago, and now it reads February 18. {{u|Sdkb}} talk 20:51, 20 February 2022 (UTC)
- @Sdkb: I think that is a consequence of this change that was recently introduced by Uzume (see the Wrap label in nowiki? discussion above). Thayts ••• 18:11, 21 February 2022 (UTC)
- Ah, thanks for the context; it looks like this is new as of a few days ago. Uzume, could you revert the change so that we can discuss before implementing? {{u|Sdkb}} talk 18:18, 21 February 2022 (UTC)
- Ideally, we can keep the "nowiki" part of change but revert the "linking" part of the change. – Jonesey95 (talk) 21:15, 21 February 2022 (UTC)
- @Sdkb, Jonesey95, and Trappist the monk: Okay, I commented out that part (at Module:Wd#L-701), however, this will likely still be an issue as I only implemented the "nowiki" fix on the linked label path when an actual link is created (that us why I forced it to always create the link when requested by the
|link
parameter, falling back to linking to Wikidata when there is no local sitelink) as that was the only time I was sure client code was not expecting the raw unescaped label value. Reverting this will break testcases for Wikidata items with no local sitelinks (but that have labels needing to be escaped when used in wikitext), e.g., Template:LinkedLabel/testcases#Labels in Wikidata containing wikicode formatting (display plain text without formatting). —Uzume (talk) 22:36, 21 February 2022 (UTC)- @Jonesey95, Sdkb, and Trappist the monk: Okay, I think I fixed this. When a linked label is requested the label is always "nowiki" escaped even when there is no local sitelink and an actual wikitext link is not returned. Raw unescaped labels can still be obtained via this interface by not requesting a linked label (i.e., unlinked labels are not "nowiki" escaped). I still think this should always return a wikitext link when a linked label is requested; when there is no local sitelink it should link to the Wikidata entity as is done for properties (which never have sitelinks). —Uzume (talk) 21:08, 22 February 2022 (UTC)
- Thanks again! – Jonesey95 (talk) 22:24, 22 February 2022 (UTC)
- @Uzume: I have undone this part as it introduced link obscurity for no apparent reason. Also, I'm not in favour of linking to Wikidata if there is no sitelink just because of the example shown by Sdkb. When you want to make changes like these, please discuss them on this page first. Thayts ••• 17:10, 23 February 2022 (UTC)
- @Thayts: I see no issue there. Such things just came about while working on the issues presented here and a little cleanup while trying to understand and make such modifications. Properties have no sitelinks (local or otherwise) but they link to Wikidata. It seemed to me it made sense to return a link when a link is requested even when there was no local sitelink available. If that assumption was wrong, I have no issues discussing and fixing things. You will notice that such a change was introduced while I was attempting to fix the "nowiki" escaping for labels that contain valid wikitext markup. —Uzume (talk) 17:38, 23 February 2022 (UTC)
- Properties are specific to Wikidata, so it's logical to link them to Wikidata. However, the purpose of linking (non-raw) entity labels was to link to their respective Wikipedia articles, if they exist. This because the idea was to make it possible to enrich Wikipedia with data from Wikidata by using this module. Nevertheless, perhaps a new flag can be added to allow linking to Wikidata in such cases. I also don't really understand how nowiki escaping is dependent on either linking or not. Thayts ••• 22:32, 23 February 2022 (UTC)
- @Thayts: I see no issue there. Such things just came about while working on the issues presented here and a little cleanup while trying to understand and make such modifications. Properties have no sitelinks (local or otherwise) but they link to Wikidata. It seemed to me it made sense to return a link when a link is requested even when there was no local sitelink available. If that assumption was wrong, I have no issues discussing and fixing things. You will notice that such a change was introduced while I was attempting to fix the "nowiki" escaping for labels that contain valid wikitext markup. —Uzume (talk) 17:38, 23 February 2022 (UTC)
- @Jonesey95, Sdkb, and Trappist the monk: Okay, I think I fixed this. When a linked label is requested the label is always "nowiki" escaped even when there is no local sitelink and an actual wikitext link is not returned. Raw unescaped labels can still be obtained via this interface by not requesting a linked label (i.e., unlinked labels are not "nowiki" escaped). I still think this should always return a wikitext link when a linked label is requested; when there is no local sitelink it should link to the Wikidata entity as is done for properties (which never have sitelinks). —Uzume (talk) 21:08, 22 February 2022 (UTC)
- @Sdkb, Jonesey95, and Trappist the monk: Okay, I commented out that part (at Module:Wd#L-701), however, this will likely still be an issue as I only implemented the "nowiki" fix on the linked label path when an actual link is created (that us why I forced it to always create the link when requested by the
- Ideally, we can keep the "nowiki" part of change but revert the "linking" part of the change. – Jonesey95 (talk) 21:15, 21 February 2022 (UTC)
- Ah, thanks for the context; it looks like this is new as of a few days ago. Uzume, could you revert the change so that we can discuss before implementing? {{u|Sdkb}} talk 18:18, 21 February 2022 (UTC)
Help for YouTube infobox
I'm in the process of converting the sandbox of {{Infobox YouTube personality}} to rely on Wikidata subscriber counts, which are now being updated every time they change by 10% or reach a new factor of 10 milestone. The WikiProject has expressed interest, too. I'm not sure how to get {{Wikidata}} to work correctly with it, though. I'd like to have it so that it returns social media followers (P8687) but only when the qualifier YouTube channel ID (P2397) is present (doesn't matter what it's set to). Help? {{u|Sdkb}} talk 07:40, 19 March 2022 (UTC)
- @Sdkb: Currently, there is just one way to do it without showing the qualifier (as far as I know):
{{wd|property|qualifier|:Barack Obama|P8687|P2397|format=%p<![]--%q--[]>}}
→ 590,000- This requires the qualifier to be present, but puts it inside an HTML comment so that it's not rendered. Thayts ••• 10:54, 19 March 2022 (UTC)
- @Thayts, thanks for that workaround! It's pretty clunky, though, and unfortunately it gets thrown off as soon as I try to use it with {{Format price}}, which doesn't seem to be able to handle hidden comments within the input. Would it be possible to modify {{Wikidata}} to provide a more direct solution? This would be one of the bigger uses of Wikidata on Wikipedia to date, and would be a huge plus for those whose watchlists are cluttered with subscriber count updates (or who are spending time doing the updates), but we'll have to overcome this obstacle in some way to get it to work. It seems rather silly that Wikidata decided to lump together Twitter followers/YouTube subscribers/etc. in the same property, but given that, we definitely don't want Twitter followers to accidentally show up as YouTube subscribers. The edits so far to the sandbox are here. {{u|Sdkb}} talk 19:04, 19 March 2022 (UTC)
- @Sdkb, here's another workaround for now:
{{Format price|{{#titleparts:{{wd|property|raw|qualifier|:Barack Obama|P8687|P2397|format=%p/%q}}|1}}}}
→ 590,000- Perhaps it's easier to make a template out of this. Thayts ••• 21:06, 19 March 2022 (UTC)
- Thanks! I tried plugging it in here, but I'm not sure how to fetch the value for
|subscriber_date=
with this approach. Ack. {{u|Sdkb}} talk 00:51, 23 March 2022 (UTC)- This is the first time you've mentioned needing the subscriber date! And I'm not clear why you're using {format price} because it isn't a price? It might help if you could be clearer on exactly what output you are seeking. It seems a rather strange way to structure the data on Wikidata. A more traditional structure might be something like this:
- If this structure is becoming common we should perhaps look at supporting it with this module. PS, I've just seen your post on WD and completely agree! — Martin (MSGJ · talk) 09:35, 23 March 2022 (UTC)
- Indeed, if the only reason to use {{format price}} is to add delimiters, then you can simply use {{wd}} without the
raw
flag as shown above. If you mean you also need point in time (P585) as the subscriber date, then you can use the same approach as I showed last time and you could even use the raw followers value to pinpoint the right claim like so: {{#titleparts:{{wd|qualifier|qualifier|single|:Barack Obama|P8687|{{#titleparts:{{wd|property|raw|qualifier|:Barack Obama|P8687|P2397|format=%p/%q}}|1}}|P2397|P585|format=%q2/%q1}}|1}}
→ 6 April 2024- By the way, I am still working on a version that allows you to select claims that have some value for a particular qualifier. Thayts ••• 08:28, 24 March 2022 (UTC)
- The reason I used {{format price}} is since I wanted e.g.
47 million
rather than47,000,000
. {{u|Sdkb}} talk 08:34, 24 March 2022 (UTC)- FYI, infoboxes should be using Module:WikidataIB with the default value for
|onlysourced=
. See the RFC link in that template's documentation for more information. – Jonesey95 (talk) 14:56, 28 March 2022 (UTC)- Well, if this module is a better fit for certain use cases then why not use it. Using the
sourced
flag you can also get just properties that have a reference. Thayts ••• 16:38, 29 March 2022 (UTC) - @Jonesey95, I'm fine with either. If you can get a version of {{Infobox YouTube personality/sandbox}} working with WikidataIB, I'd love to see it! {{u|Sdkb}} talk 00:58, 30 March 2022 (UTC)
- Well, if this module is a better fit for certain use cases then why not use it. Using the
- FYI, infoboxes should be using Module:WikidataIB with the default value for
- The reason I used {{format price}} is since I wanted e.g.
- Indeed, if the only reason to use {{format price}} is to add delimiters, then you can simply use {{wd}} without the
- Thanks! I tried plugging it in here, but I'm not sure how to fetch the value for
- @Thayts, thanks for that workaround! It's pretty clunky, though, and unfortunately it gets thrown off as soon as I try to use it with {{Format price}}, which doesn't seem to be able to handle hidden comments within the input. Would it be possible to modify {{Wikidata}} to provide a more direct solution? This would be one of the bigger uses of Wikidata on Wikipedia to date, and would be a huge plus for those whose watchlists are cluttered with subscriber count updates (or who are spending time doing the updates), but we'll have to overcome this obstacle in some way to get it to work. It seems rather silly that Wikidata decided to lump together Twitter followers/YouTube subscribers/etc. in the same property, but given that, we definitely don't want Twitter followers to accidentally show up as YouTube subscribers. The edits so far to the sandbox are here. {{u|Sdkb}} talk 19:04, 19 March 2022 (UTC)
Use of reference parameter should provide archive URL where available to deal with link rot
On Telugu wikipedia, we have started using Wikidata based infobox templates extensively.(Example page on Tewiki) When the citations are added, we are facing the problem of dead links when values of full work available at URL become dead as given below. {{wikidata|references|linked|eid=Q48728240|P1082|P585=2011}} [1]
References
- ^ CENSUS OF INDIA 2011, ANDHRA PRADESH, SERIES-29, PART XII - B, DISTRICT CENSUS HANDBOOK, WEST GODAVARI, VILLAGE AND TOWN WISE, PRIMARY CENSUS ABSTRACT (PCA) (PDF), Director of Census Operations, Andhra Pradesh, Wikidata Q55972946, archived from the original (PDF) on 25 August 2015, CENSUS OF INDIA 2011, ANDHRA PRADESH, SERIES-29, PART XII - B, DISTRICT CENSUS HANDBOOK, WEST GODAVARI, VILLAGE AND TOWN WISE, PRIMARY CENSUS ABSTRACT (PCA) (PDF), Director of Census Operations, Andhra Pradesh, Wikidata Q55972946, archived from the original (PDF) on 25 August 2015
Arjunaraoc (talk) 04:03, 1 June 2022 (UTC)
- I realized that lack of archive date qualifier prevented the citation from showing archive link. So there is no issue. Arjunaraoc (talk) 05:56, 1 June 2022 (UTC)
Reference is shown differently on Tewiki when only 'stated in' is present
This code below does not show citation differently (only label is shown and the link, wikidata identifier for source is missing) on Telugu Wiki (Example test page) On English wiki, there is no problem. Telugu Wiki uses English wiki templates and Module code as much as possible, without even change of parameter names. {{wikidata|references|linked|eid=Q48728240|P1082|P585=2011}} [1]
References
- ^ CENSUS OF INDIA 2011, ANDHRA PRADESH, SERIES-29, PART XII - B, DISTRICT CENSUS HANDBOOK, WEST GODAVARI, VILLAGE AND TOWN WISE, PRIMARY CENSUS ABSTRACT (PCA) (PDF), Director of Census Operations, Andhra Pradesh, Wikidata Q55972946, archived from the original (PDF) on 25 August 2015, CENSUS OF INDIA 2011, ANDHRA PRADESH, SERIES-29, PART XII - B, DISTRICT CENSUS HANDBOOK, WEST GODAVARI, VILLAGE AND TOWN WISE, PRIMARY CENSUS ABSTRACT (PCA) (PDF), Director of Census Operations, Andhra Pradesh, Wikidata Q55972946, archived from the original (PDF) on 25 August 2015
Arjunaraoc (talk) 04:38, 1 June 2022 (UTC)
- @Thayts and others, I have checked the availability of latest files of enwiki on tewiki. The testcases 1 and 2 are failing. (See te:Module Talk:Wd/testcases/1 as an example.) I have created a new test case 4 on telugu wikipedia for debugging reference parameter. ((See te:Module Talk:Wd/testcases/4) Can you check and fix/guide me in fixing? Arjunaraoc (talk) 09:21, 2 June 2022 (UTC)
- @Arjunaraoc: The reference looks different because there is no Cite Q template available on that wiki. Testcases 1 and 2 are failing, because there is no Utrecht (province) article on the wiki either; you can better replace the Q-number with one that does have an article. And the issue with testcase 4 seems to be in te:మూస:Cite web, which appears to be a one-to-one copy from the English wiki that does not recognise the month name in your language. You should update all localised terms there. Thayts ••• 08:55, 5 June 2022 (UTC)
- @Thayts, Thanks. I already copied Cite Q template to Tewiki, but did not update sitelinks on Wikidata. After updating Wikidata, the citation is same as on Enwiki, except for the non-localised date. Cite Web, which I think uses Module:Citation/CS1/Configuration has already been internationalised to used Mediawiki local language configuration as per discussion. Citation showing English dates is not a major issue on Tewiki. Arjunaraoc (talk) 05:21, 6 June 2022 (UTC)
- @Thayts, I made changes to test cases to use Q668(India) in place of Q55(Netherlands) and Q1159(Andhra Pradesh) in place of Q776 Utrecht (province). Still I got few Lua errors on some lines, which I commented for the timebeing. I found that though the actual, expected are same, the test is being shown as failed (example:{{#invoke:wd|property|edit@end|Q668|P395}} on te:మాడ్యూల్_చర్చ:Wd/testcases/1 _), which you may like to investigate and fix. Arjunaraoc (talk) 06:02, 6 June 2022 (UTC)
- @Thayts, I added publication date to the document on wikidata and found that it is being shown with dates localised dates, while the archive date is being shown with English dates. (Example test page) Can you fix so that only either localised or English dates are shown? Thanks. Arjunaraoc (talk) 07:19, 6 June 2022 (UTC)
- @Thayts, I tried to clean up the references for some entities, with the order of values against a property changed, I find that the references are not shown at all. Please find an example page, in which the second reference for population is not shown at all. Can you address this as well? Arjunaraoc (talk) 13:38, 7 June 2022 (UTC)
- @Thayts, I realized that title or label in Telugu is required to properly show the citation. It may be useful to implement fall back to English label, if the local language label is missing. Arjunaraoc (talk) 04:51, 8 June 2022 (UTC)
- @Arjunaraoc: The label of which item are you talking about in this example? I think the issue with the English dates is again a localisation issue, in template Cite Q (not in this module). Thayts ••• 07:23, 9 June 2022 (UTC)
- @Thayts, I realized that title or label in Telugu is required to properly show the citation. It may be useful to implement fall back to English label, if the local language label is missing. Arjunaraoc (talk) 04:51, 8 June 2022 (UTC)
- @Arjunaraoc: The reference looks different because there is no Cite Q template available on that wiki. Testcases 1 and 2 are failing, because there is no Utrecht (province) article on the wiki either; you can better replace the Q-number with one that does have an article. And the issue with testcase 4 seems to be in te:మూస:Cite web, which appears to be a one-to-one copy from the English wiki that does not recognise the month name in your language. You should update all localised terms there. Thayts ••• 08:55, 5 June 2022 (UTC)
Latest population
How would I get the latest population value for Q8003707, which is 19,262 for 2021? {{wikidata |property |normal+ |Q8003707|P1082 }} yields 18,187, which is for 2016. Betterkeks (talk) 17:54, 5 July 2022 (UTC)
- For now, you can change the rank of the claim for 2021 to "preferred" on Wikidata and then use {{wikidata|property|Q8003707|P1082}}. Thayts ••• 20:22, 5 July 2022 (UTC)
- @Thayts: Thank you! This is fine for just this one suburb, but its not really tenable for all the areas in Australia with population data from the 2016 and now 2021 census. A better solution is probably needed. Why can't current also consider the point in time property to work out the most CURRENT claim? It seems odd for this template to ignore the claim's point in time when getting the CURRENT value. Betterkeks (talk) 07:44, 6 July 2022 (UTC)
- The "current" flag takes a period into account and checks the start and end time to see if the period is, well, current. A point in time is quickly outdated and 2021 is indeed no longer current. However, a "latest" flag would help here. Thayts ••• 09:09, 9 July 2022 (UTC)
- @Thayts: A "latest" flag would work, but so would a polymorphic "current" that is also simpler. The 2021 census data are still being released and the population data were JUST released a short time ago. These data ARE the MOST current data available until the next census data are released in probably five years time. The wikidata template yielding data from 2016 as "current" DESPITE being able to yield MORE "current" data from 2021 does not seem right. Betterkeks (talk) 11:04, 9 July 2022 (UTC)
- "Current" means "as of this very moment in time", which is inapplicable to census data, since it's always released months after the period over which it is collected. By the time it is released, it's no longer "current". It can be "latest" or "most recent", but it can't be "current". (Compare with the well-defined "current number of people on the ISS".) — UnladenSwallow (talk) 17:07, 22 July 2022 (UTC)
- @Thayts: A "latest" flag would work, but so would a polymorphic "current" that is also simpler. The 2021 census data are still being released and the population data were JUST released a short time ago. These data ARE the MOST current data available until the next census data are released in probably five years time. The wikidata template yielding data from 2016 as "current" DESPITE being able to yield MORE "current" data from 2021 does not seem right. Betterkeks (talk) 11:04, 9 July 2022 (UTC)
- The "current" flag takes a period into account and checks the start and end time to see if the period is, well, current. A point in time is quickly outdated and 2021 is indeed no longer current. However, a "latest" flag would help here. Thayts ••• 09:09, 9 July 2022 (UTC)
- @Thayts: Thank you! This is fine for just this one suburb, but its not really tenable for all the areas in Australia with population data from the 2016 and now 2021 census. A better solution is probably needed. Why can't current also consider the point in time property to work out the most CURRENT claim? It seems odd for this template to ignore the claim's point in time when getting the CURRENT value. Betterkeks (talk) 07:44, 6 July 2022 (UTC)
- @UnladenSwallow: My dictionary defines "current" as meaning (1) passing in time, or belonging to the time actually passing: the current month, (2) publicly reported or known, (3) prevalent, and (4) generally accepted; in vogue. (It also defines current in terms of “flow”, but that isn’t applicable and so for brevity I haven’t listed these here.) The current census data is (2)-(4), and (1)-(4) when considered the currently best known data. However, even if CURRENT for this template is assumed to mean "as of this very moment in time" only (which is a much narrower definition than my dictionary provides), then it should ONLY yield the 2016 data on, or when given the date for, census date 2016, and NO data at all otherwise, rather than picking the first entered data that it yields currently. Betterkeks (talk) 19:05, 23 July 2022 (UTC)
appendcategory (appendcat) parameter
Hello. I want to implement this module on Azerbaijani Wikipedia. One thing is missing (it exists on ruwiki version) — properties like d:P6365, d:P1740, d:P3876 would be great to implement while invoking the module with a parameter like |appendcategory=P3876
. It can be helpful for categorisation. — Toghrul R (t) 07:20, 16 August 2022 (UTC)
Trimmed dates (years only)
Is there a way to trim the dates (30 April 2013 → 2013)? Sometimes it would be very handy to have it
{{#invoke:wd|property|qualifier|qualifier|trimdate|normal+|Q55|P35|P580|P582|sep%q=_–_}} → Willem-Alexander of the Netherlands (2013) — Toghrul R (t) 14:47, 28 August 2022 (UTC)
- Why reinvent the wheel? Wrap it in {{YEAR}}. – Jonesey95 (talk) 12:47, 29 August 2022 (UTC)
- @Jonesey95 could you help wrapping it? I'm getting errors while doing it — Toghrul R (t) 06:18, 31 August 2022 (UTC)
- I don't see a way to format just the date qualifier, since you are returning two P values, but if you are returning just one value, you can do it like this:
{{#invoke:wd|property|Q154952|P569}}
→ 27 April 1967{{YEAR|{{#invoke:wd|property|Q154952|P569}}}}
→ 1967- There may be a way to apply a format only to the second qualifier, but I do not know what it is. – Jonesey95 (talk) 14:09, 31 August 2022 (UTC)
- One way to accomplish this is to modify the returned date using string manipulation:
{{#invoke:String|replace|{{#invoke:wd|property|qualifier|qualifier|normal+|Q55|P35|P580|P582}}|%(%d%d? [A-Za-z]+ (%d%d%d%d)%)|(%1)|plain=false}}
→ Willem-Alexander of the Netherlands (2013)
- —Trappist the monk (talk) 14:24, 31 August 2022 (UTC)
- @Jonesey95 @Trappist the monk thanks for the help. It's a bit workaround, but works. However, when applying a format like
|format=<ul>%p[%r] [<span style="font-size:90\%">(%q1–[%q2])</span>]</ul>
it doesn't work, sadly. — Toghrul R (t) 12:24, 1 September 2022 (UTC)- It seems to me wrong for you to include
<ul>...</ul>
tags in|format=
. To me, that belongs outside of the{{#invoke:}}
. But, since you did include<ul>...</ul>
tags, why did you omit the<li>...</li>
tags? - For open date ranges like that of your example, a simple tweak to the string replace works (
<ul>...</ul>
tags removed):{{#invoke:String|replace|{{#invoke:wd|property|qualifier|qualifier|normal+|Q55|P35|P580|P582|format=%p[%r] [<span style="font-size:90\%">(%q1–[%q2])</span>]}}|%(%d%d? [A-Za-z]+ (%d%d%d%d)–%)|(%1–)|plain=false}}
→ Willem-Alexander of the Netherlands (2013–)
- Because it is to be expected that not all dates will be open ended, you could write something like this (here the return from
{{#invoke:wd}}
is a mockup):{{#if:{{#invoke:String|match|s=Willem-Alexander of the Netherlands <span style="font-size:90%">(30 April 2013–30 April 2015)</span>|pattern=%(%d%d? [A-Za-z]+ %d%d%d%d–%d%d? [A-Za-z]+ %d%d%d%d%)|nomatch=}}| {{#invoke:String|replace|source=Willem-Alexander of the Netherlands <span style="font-size:90%">(30 April 2013–30 April 2015)</span>|pattern=%(%d%d? [A-Za-z]+ (%d%d%d%d)–%d%d? [A-Za-z]+ (%d%d%d%d)%)|replace=(%1–%2)|plain=false}}| {{#invoke:String|replace|source=Willem-Alexander of the Netherlands <span style="font-size:90%">(30 April 2013–)</span>|pattern=%(%d%d? [A-Za-z]+ (%d%d%d%d)–%)|replace=(%1–)|plain=false}}}}
- result when returned string has two dates:
- Willem-Alexander of the Netherlands (2013–2015)
- result when returned string has one date:
- Willem-Alexander of the Netherlands (2013–)
- The above assumes that there will always be at least one dd Mmmm YYYY date.
- According to MOS:RANGES, the correct separator for a range of two whole dates (dates that contain spaces) is spaced endash: 30 April 2013 – 30 April 2015. The above does not support that because your
|format=
always uses an unspaced endash. - —Trappist the monk (talk) 14:29, 1 September 2022 (UTC)
- It seems to me wrong for you to include
- @Jonesey95 @Trappist the monk thanks for the help. It's a bit workaround, but works. However, when applying a format like
- @Jonesey95 could you help wrapping it? I'm getting errors while doing it — Toghrul R (t) 06:18, 31 August 2022 (UTC)
Using this to access the latest release date
Could somebody who understands this template (and accessing Wikidata generally) have a look at WP:Teahouse#Wikidata problem with diagrams.net article? The problem is that the call of this template in the infobox in diagrams.net was picking up the release dates of all the versions in d:Q59339175, rather than the latest. I tried to fix it by adding |preferred
- which got rid of all the dates, but actually doesn't produce any because none of them have been marked as "preferred". I was investigating how d:Help:Ranking worked, and was going to set the latest release to be "preferred", but it occurred to me that this must have arisen before, and there must be a better way to handle it.
I wasn't sure whether to ask at Wikidata, or VPT, or here, but I thought I'd try here first.
Pinging Stephenamills, who raised the issue. ColinFine (talk) 17:34, 2 September 2022 (UTC)
- To re-mention what @ColinFine said above, we want the Diagrams.net article to use the latest software release version number that has been entered in its associated Wikidata page.
- I tried to copy-paste the Wikidata property usage from the infobox template on an existing page that already pulls its data from Wikidata, like Adobe Photoshop, but it appears that there must be more that needs to be copy-pasted (or changed) than just what’s in the infobox template, because doing so didn’t work. I’m not sure if there is additional Wikidata syntax on (as an example) the Adobe Photoshop page that I missed, or if there is some additional syntax that needs to be entered separately on the affiliated Wikidata page. Stephenamills (talk) 21:12, 2 September 2022 (UTC)
Accessing titles from other Wikipedias
I'm still interested in a feature that would extract the title of a linked Wikipedia article, perhaps as in this mockup:
{{wikidata|wikipedia|lang=es|eid=Q43287}}
→ Imperio alemán
See Module talk:Wd/Archive 1#Titles from other wikipedias for previous discussion about this. Thanks, (please mention me on reply; thanks!) Mathglot (talk) 04:47, 11 September 2022 (UTC)
Broken row in documentation
In the table at Template:Wikidata/doc#Configuration_flags, the last row appears to be displaying incorrectly. I think the "edit@end
" is meant to go right under "edit" but it's instead appearing one cell to the left. I tried to fix it myself but couldn't figure out how; does anyone know how to make it display correctly? – numbermaniac 05:43, 7 October 2022 (UTC)
- It looks fine to me (Firefox and Chrome for Mac OS, in both Desktop and Mobile view). Maybe try a different web browser or a different skin? Does it look normal if you are logged out? – Jonesey95 (talk) 15:58, 7 October 2022 (UTC)
- Huh, you're right, it does look fine when logged out. Looks like the cause is the "sticky header rows in tables" setting under the Gadgets tab on the Preferences page. Guess I need to figure out where to report that as a bug. – numbermaniac 05:31, 8 October 2022 (UTC)
Add a 'maxvals' option as in Module:WikidataIB
Hi, We are currently trying to import referenced data from WD into infoboxes but we have the issue that for some items, lists could get too long. So having a 'maxvals' parameters as in https://en.wikipedia.org/wiki/Module:WikidataIB would be really nice! (as WikidataIB does not allow to retrieve references) Has anyone seen this? Could this be doable? AdrianoRutz (talk) 08:42, 7 October 2022 (UTC)
- I'm sure this would not be too difficult to add — Martin (MSGJ · talk) 09:33, 7 October 2022 (UTC)
- Good news! I just saw it implemented in the french version: https://fr.wikipedia.org/wiki/Module:Wikidata AdrianoRutz (talk) 11:32, 7 October 2022 (UTC)
- Unfortunately that is the French version of a different module, so unlikely the code can be adapted for this module. I will look into this now though ... — Martin (MSGJ · talk) 07:51, 16 October 2022 (UTC)
- Good news! I just saw it implemented in the french version: https://fr.wikipedia.org/wiki/Module:Wikidata AdrianoRutz (talk) 11:32, 7 October 2022 (UTC)
I have made an attempt but it is not working yet. Perhaps Jonesey95 could help get this working? — Martin (MSGJ · talk) 09:47, 16 October 2022 (UTC)
- I don't have Lua skills. Can AdrianoRutz just use WikidataIB in their infobox? It was built specifically for infoboxes. – Jonesey95 (talk) 13:25, 16 October 2022 (UTC)
- Sorry I thought you were a Lua wizard. I'll keep looking then. They were looking at using this module because they specifically want references to be displayed which WDIB can't do. — Martin (MSGJ · talk) 17:59, 16 October 2022 (UTC)
Possibility to get historic labels
Hello, is there any way to fetch older labels of a subject? For instance, I would like to get Kirovabad (linked) for Ganja via P1448 using a date interval (1935–1989). That would be helpful for getting the correct labels during a person's lifetime. — Toghrul R (t) 07:02, 1 November 2022 (UTC)
- I don't know of any way to do that currently, but I can see it could be useful. Complications: there could be several values which are valid in a certain date, would need to filter results by language. I can't see any way it could be linked because these are text labels and so not linked to any articles. — Martin (MSGJ · talk) 08:12, 1 November 2022 (UTC)
Area
I have been using the template to create lists of suburbs in LGA articles (see Shire of Serpentine-Jarrahdale as an example). It was pointed out to me that the statement drawn from Wikidata, "3.5 square kilometre", is actually incorrect and it should be the plural "square kilometres". The way around this is just to use the "raw" parameter and add square kilometres at the end of the template. Apart from this, it would also be handy to be able to convert the value to the US square mile. I achived this with the convert template, resulting in the rather complicated {{convert|{{wikidata|property|raw|Q5004080|P2046}}|km2|sqmi|abbr=unit}}. Is there currently any either way with the template to achieve the following two:
- Substitute the Wikidata unit with an abbreviated unit (like km2)
- Convert the unit from SI to Imperial and vice-versa
Thanks for any advice. Calistemon (talk) 04:40, 28 November 2022 (UTC)
- When I look at the Wikidata entry for Byford, I see "19.6 square kilometre" under "area" and "64 metre" under "elevation above sea level", which appear to be wrong. That is not a valid way to write distance or area in SI. The table at MOS:UNITNAMES even makes this explicit for those who need to hear it: "SI unit names are pluralized by adding the appropriate -s or -es suffix". I think that strange way of writing units is where the problem lies, so fixing it at Wikidata is probably best. – Jonesey95 (talk) 06:29, 28 November 2022 (UTC)
- @Calistemon: please use
{{convert|input=P2046|qid=Q5004080|abbr=on}}
which produces 22 km2 (8.5 sq mi) — Martin (MSGJ · talk) 07:24, 28 November 2022 (UTC)
- @Calistemon: Or just
{{cvt |input=P2046 |qid=Q5004080}}
to produce 22 km2 (8.5 sq mi). Betterkeks (talk) 09:00, 28 November 2022 (UTC)- Thank you @Betterkeks and MSGJ:, this is such a simpler way to achieve this instead of the clumsy way I produced! Much appreciated. Calistemon (talk) 06:58, 29 November 2022 (UTC)
Access value by date using P585 point-in-time
Why isn't it possible to access specific values by comparing date against P585 point in time not just start and end time? Say call for a value that has point-in-time value in January 1st 2022 because not all values can be correctly described as having start and end points, some for example population is specifically point-in-time value as it is changing day by day. Is it not implemented because it is not possible or it hasn't yet been deemed useful? If it's possible how could it be done? Does someone else add the functionality or do I copy the code and try to add the functionality and then if it is successful it may be added to main Module? Liinisx (talk) 11:48, 5 January 2023 (UTC)
Template-protected edit request on 5 January 2023
This edit request to Module:Wd has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Add functionality to call for a property value if "date=..." matches P585 date-in-time value As I understand it is not possible for now and one can call for a value by date only if it has start-time and/or end-time qualifiers Liinisx (talk) 14:21, 5 January 2023 (UTC)
- Unless you can code this yourself in the sandbox and test it, this probably will not get done. This module is no longer actively maintained, and the last time I tried to edit the code I made little progress.
Examples in the main page
The examples in the main page are kind of difficult:
{{wikidata|properties|qualifier|normal+|Q55|P1082|P585}}
↓
17,282,163 (2019), 16,829,289 (26 August 2014), 16,779,575 (2013), 10,026,773 (1950), 17,000,000 (21 March 2016), 17,132,854 (2017), 17,181,084 (1 January 2018), 17,622,200
The results aren't in any order - neither by time, nor by size.
What I want is eg Santa Fe, Cebu using P150 which can have a number of elements in alphabetic order. They are each similar eg Q26763388, and from each I want (P1082) the most recent population, and the closest earlier.
If I can work it out, that can do the whole job is one line (adding text where needed). - Auntie Kathleen (talk) 06:05, 6 January 2023 (UTC)
- I guess it is giving the values in the order that they are on Wikidata. I have changed the order on there (using wikidata:Help:Statements#Order_of_statements_for_a_property and now it displays 2019 first (which is the statement marked as preferred) and then all the others in chronological order, and then the undated one.
- 17,942,942 (1 January 2024), 17,590,672 (1 January 2022), 17,407,585 (1 January 2020), 17,282,163 (1 January 2019), 17,181,084 (1 January 2018), 17,081,507 (1 January 2017), 17,000,000 (21 March 2016), 16,829,289 (26 August 2014), 16,779,575 (2013), 10,026,773 (1950)
- Hope this helps — Martin (MSGJ · talk) 15:13, 8 January 2023 (UTC)
Pulling structured data from Commons
Is there an equivalent to this module to retrieve structured data from a file on wikimedia commons? E.g. this file should have P275 = Q20007257. Any ideas? T.Shafee(Evo&Evo)talk 06:30, 10 March 2023 (UTC)
Is there a risk for overusing this module?
Hello. Thank you for developing this amazing module. I am working in the Ladin language Wikipedia, where I have created this module by copying this code and it works well. I have started using this module a lot on many articles, because the Ladin Wikipedia is very small and there aren't enough people to regularly update information, so I try to automatise everything as much as possible. I have found that when an article contains several instances of "module:wd", like five or more, it can take a while for the page to display the information. I include this module both in infoboxes as well as in the text of the article. When it takes longer to display the information from Wikidata, it may even show only certain information from Wikidata but not other. I don't think it's a syntax issue, because other pages with the same syntax did not have this issue.
Therefore, I wonder whether there is a recommended guideline against overusing this module, whether using it five times on every single page in the entire Wikipedia would slow everything down considerably. Or is this practice fine? Do the long loading times only happen when the Wikidata item or the Wikipedia article are edited, and otherwise it just loads the information once and then it's fine?
Thanks for helping. Asenoner (talk) 13:01, 19 March 2023 (UTC)
Edit request 4 April 2023
This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Description of suggested change: I would like to update this module with my revision of its sandbox (permalink). I've made the module slightly simpler by simplifying its conditional statements, and fixed two minor errors in pattern matching (attempts to escape w/ backslash instead of %). I've checked my changes in /testcases, and my version appears to fare equally to the current revision.
Diff: diff link
{{Lemondoge|Talk|Contributions}} 20:36, 4 April 2023 (UTC)
- This module is used in more than 1.5 million pages. It would be nice to have this proposed revision checked by one or two editors who are familiar with the module. – Jonesey95 (talk) 22:24, 4 April 2023 (UTC)
- Although I am not very familiar with the inner workings of the module, I reviewed the changes and they look right. Janhrach (talk) 13:44, 8 April 2023 (UTC)
- Not done I'm not willing to make cosmetic, possibly-poorly-tested changes to a module used on a million pages, and it appears no one else is willing to either because this has languished for weeks. * Pppery * it has begun... 01:47, 17 April 2023 (UTC)
COVID-19 pandemic in Luxembourg totally broken
Not sure why there's the memory errors, but all the articles uses of Module:Wikidata are borked. Galobtter (talk) 22:19, 18 April 2023 (UTC)
- That page's corresponding Wikidata page is currently 3,222,389 bytes, with 2,631 statements, putting it at #90 overall on the Wikidata list of long pages. Something probably needs to be done to improve efficiency of querying such a large page, or to reduce the size of the page. – Jonesey95 (talk) 22:49, 18 April 2023 (UTC)
Reference formatting bug when using "author name string" (P2093)
When a reference on Wikidata includes the "author name string" qualifier, the resulting citation is formatted improperly. It should be formatted the same way as when the "author" (P50) qualifier is used. See the reference 1 on GNU GRUB for example. This issue was already discussed in 2020, but it seems that it wasn't solved. Janhrach (talk) 09:58, 6 January 2023 (UTC)
- It looks it is related to Module:Wd/i18n. Maybe it could be fixed by adding something like
[aliasesP.authorNameString] = "author"
between the line 60 and 71. Janhrach (talk) 17:03, 20 January 2023 (UTC)
Template-protected edit request on 2 March 2023
This edit request to Module:Wd/i18n has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Please copy the contents of the revision 1142478456 of Module:wd/sandbox/i18n into Module:wd/i18n and the contents of the revision 1142479763 of Module:wd/sandbox into Module:wd. It is the fix for the bug described in the section above. Janhrach (talk) 17:05, 2 March 2023 (UTC)
- Thanks for looking into this. Have you got any test cases where we can check that everything is working properly? — Martin (MSGJ · talk) 17:21, 2 March 2023 (UTC)
- I don't have any new testcases. I'm not sure how do the testcases of this module work, but Module:wd/testcases/1 references only the original module and testcases 2 and 3 also reference the sandbox. I've made a tweaked copy of testcases/1 at Module:wd/sandbox/testcases/1 and its output seems to be the same as before my edits (5 errors reported). The output of the testcase 2 and 3 is also the same as before. However, I've made a very basic test page for my changes at User:Janhrach/sandbox. Janhrach (talk) 06:11, 3 March 2023 (UTC)
- User:Janhrach/sandbox proves the point that I made below; the
{{cite web}}
template called from wd/sandbox is using|authors=
so that thing in your sandbox will, if used in mainspace add the article to Category:CS1 maint: uses authors parameter. So, I oppose the proposed change. - —Trappist the monk (talk) 15:48, 3 March 2023 (UTC)
- User:Janhrach/sandbox proves the point that I made below; the
- I don't have any new testcases. I'm not sure how do the testcases of this module work, but Module:wd/testcases/1 references only the original module and testcases 2 and 3 also reference the sandbox. I've made a tweaked copy of testcases/1 at Module:wd/sandbox/testcases/1 and its output seems to be the same as before my edits (5 errors reported). The output of the testcase 2 and 3 is also the same as before. However, I've made a very basic test page for my changes at User:Janhrach/sandbox. Janhrach (talk) 06:11, 3 March 2023 (UTC)
- If I understand what it is that this change accomplishes, I think I'm opposed. At line 69 of Module:Wd/sandbox/i18n is this:
[aliasesP.authorNameString] = "authors",
- If I understand the purpose of that, it is supposed to assign whatever value wikidata has for P2093 to the
{{cite web}}
parameter|authors=
. Use of that parameter is discouraged and it will (someday) go away.{{cite q}}
assigns P2093 values to|author=
as a fallback (if one is to believe the module documentation at line 245). Neither of these solutions is a good solution when P2093 lists more than one name. Because P50 can (and does) hold more than one name it seems to me that wikidata q values using P2093 should be fixed to use P50 and this module tweaked to support that. Assigning P2093 to|authors=
seems to me a hack that will come round to bite someone later. Don't do that. - —Trappist the monk (talk) 18:19, 2 March 2023 (UTC)
- I have just noticed that P2093 is supposed to hold one author at once, and if there are more authors, the reference will have more P2093s. For example, see the items listed at the "Most recently created items" URL at d:Property talk:P2093. I suggest to use
author
(instead ofauthors
) for holding P2093s. Janhrach (talk) 14:55, 3 March 2023 (UTC)- Ok, so long as the value from each P2093 goes in a separate enumerated
|author<n>=
parameter. - I have marked this edit request as
|answered=yes
. When you have got working code that does not create broken cs1|2 templates, feel free to set|answered=no
. - —Trappist the monk (talk) 15:48, 3 March 2023 (UTC)
- Ok, so long as the value from each P2093 goes in a separate enumerated
- I have just noticed that P2093 is supposed to hold one author at once, and if there are more authors, the reference will have more P2093s. For example, see the items listed at the "Most recently created items" URL at d:Property talk:P2093. I suggest to use
Template-protected edit request on 4 March 2023
This edit request to Module:Wd and Module:Wd/i18n has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Please copy the contents of the revision 1142767581 of Module:wd/sandbox/i18n into Module:wd/i18n and the contents of the revision 1142771233 of Module:wd/sandbox into Module:wd.
I've implemented the handling of P50 and P2093. In my implementation, each P50 and P2093 has its authorN
parameter, with (template) parameters for P50 having lower N
than parameters for P2093. For compatibility reasons, I have retained code that would handle multiple properties other than P50 and P2093. I've also tweaked the fallback display of citations (used when a citation has parameters not supported by Cite web or when it doesn't include title or URL). The authors from P2093 are now displayed properly and the author separator was changed from " & " to "; ". The parts of the citation are now separated by ". ", not by "; ". For output examples, see User:Janhrach/sandbox.
Janhrach (talk) 09:18, 4 March 2023 (UTC)
Edit: see the comment from March 11.
- This cite seems to be more-or-less correct; this cite does not. It appears that for some reason you are inventing your own citation style which would be ok if it were the only style to be used in articles that use this module. Alas, editors like citation consistency. I'm guessing that the reason for this different style is to prevent the embedded
{{cite web}}
template from emitting an error when wikidata does not have a title for the citation. Titles are required so when{{cite web}}
emits a missing title error, that is a good thing, because someone can go to wikidata and fix it (P1476). I'm inclined to oppose because of the non-standard citation style. - —Trappist the monk (talk) 15:02, 4 March 2023 (UTC)
- I did "invent" a new citation style (which is a slight modification of the previous one), but I did not come up with the idea of a fallback mode. See the updated version of my sandbox for the original behavior of the module. So, is your opinion to remove the fallback mode and issue an error instead, or is it to keep the fallback mode and to issue an error only if the title is missing? Janhrach (talk) 16:21, 4 March 2023 (UTC)
- I would get rid of the fallback format as it exists now. If that is not possible, at the very least, the fallback format should look (to the reader) just like a cs1|2 template rendering. Maybe fallback format can use
{{citation}}
with|mode=cs1
:{{citation |mode=cs1 |author1=John Doe |author2=Jane Doe |url=https://example.org |date=2000}}
- John Doe; Jane Doe (2000). https://example.org.
{{citation}}
: Missing or empty|title=
(help)
- John Doe; Jane Doe (2000). https://example.org.
- This looks much the same as the
{{cite web}}
and{{cite q}}
template renderings; sort of. In the event that there is no url but there is a title,{{citation}}
will treat the citation as a book cite:{{citation |mode=cs1 |author1=John Doe |author2=Jane Doe |title=Title |date=2000}}
- John Doe; Jane Doe (2000). Title.
One thing that should be done with this referencing stuff is to setyeah, there is a pencil icon... forgot about that.|id=[[WDQ (identifier)|Wikidata]] Q<number>
so that editors know where to go to fix missing/broken url/title/whatever.- I should say that while I have contributed to Module:Cite Q, I am, in general, opposed to its use and, by extension, to this module because both create buggy, hard to fix citations.
- —Trappist the monk (talk)
17:16, 4 March 2023 (UTC)17:44, 4 March 2023 (UTC)- What about citation properties/parameters in Wikidata unknown to {{Citation}}? Should they be left undisplayed, should the template output an error, or should the current behavior (outputting them in the format
property: value.
) be retained? Janhrach (talk) 17:54, 4 March 2023 (UTC)citation properties/parameters in Wikidata unknown to {{Citation}}
And what properties/parameters might those be?- —Trappist the monk (talk) 18:09, 4 March 2023 (UTC)
- I meant some miscellaneous data about the reference, but I had nothing specific in my mind. Anyway, such metadata would be irrelevant for the citation and should be removed, so the best solution would be to display an error if any similar situation occurs. In other words, forget about my question. Janhrach (talk) 19:09, 4 March 2023 (UTC)
- What about citation properties/parameters in Wikidata unknown to {{Citation}}? Should they be left undisplayed, should the template output an error, or should the current behavior (outputting them in the format
- I would get rid of the fallback format as it exists now. If that is not possible, at the very least, the fallback format should look (to the reader) just like a cs1|2 template rendering. Maybe fallback format can use
- I did "invent" a new citation style (which is a slight modification of the previous one), but I did not come up with the idea of a fallback mode. See the updated version of my sandbox for the original behavior of the module. So, is your opinion to remove the fallback mode and issue an error instead, or is it to keep the fallback mode and to issue an error only if the title is missing? Janhrach (talk) 16:21, 4 March 2023 (UTC)
Deactivating edit request as still pending discussion and not ready to be implemented. * Pppery * it has begun... 22:15, 4 March 2023 (UTC)
- I've changed my opinion, I disagree with using {{Citation}} as the fallback mode. In my opinion, there are two good options – the fallback mode would retained, but it would issue a warning; or the fallback mode would be removed and an error would be issued if the module is unable to produce a valid template. I think the fallback mode (if retained) should be only temporary, and in the case a citation triggering the fallback mode appears, the citation (or, in special cases, this module) should be modified to produce a valid template. Janhrach (talk) 08:51, 5 March 2023 (UTC)
I'm reopening this edit request. The discussion above is not directly related to my proposed fix. I made minor changes to the fallback display of citations, which (the changes) are partly unrelated to the rest of the fix. If you dislike them, please replace the main module file with the sandbox revision 1142765292 (instead of 1142771233). The below above discussion is about completely changing the fallback display of citations (as the resulting citations are not formatted consistently with CS1/2), which is neither something I wanted to address in my fix, nor something I am experiened enough to do. Addressing the inconsistency of fallback mode-generated citations can (and, in my opinion, should) be done later by more experienced editors than me. Janhrach (talk) 14:43, 11 March 2023 (UTC)
- To editor Janhrach: would be good if we could tuck this one in. I need you to link to precisely the sandbox versions for Module:Wd/sandbox and Module:Wd/i18n/sandbox that you want to implement. And I need you to reassure me that your edits have been tested and are ready to go live. Thank you! P.I. Ellsworth , ed. put'er there 11:09, 25 March 2023 (UTC)
- @Paine Ellsworth: The links are [6] (sandbox) and [7] (sandbox/i18n). My edits have been tested, the results are in my sandbox. Please note that the third reference in the sandbox is supposed to trigger the fallback mode of displaying references, it is not a bug.
- Janhrach (talk) 15:02, 26 March 2023 (UTC)
- Because the 'fallback' does not look like a cs1|2 template rendering, I stand by my previous comment:
I would get rid of the fallback format as it exists now. If that is not possible, at the very least, the fallback format should look (to the reader) just like a cs1
Get rid of the fallback or fix it. - —Trappist the monk (talk) 15:32, 26 March 2023 (UTC)
- @Trappist the monk: I have removed the fallback mode, see my sandbox for the output. One problem is that Wikidata doesn't seem to mandate any other reference parameters than URL. See the first error in Module:Wd/sandbox/testcases/1. The
sourced
command breaks, because one of the references triggers the (now inexistent) fallback mode, which can be considered a problem. Please let me know what you think. Janhrach (talk) 17:08, 28 March 2023 (UTC)- Emitting a Lua script error is clearly the wrong thing to do because it misleads the reader into thinking that the problem is in the Lua module when it is really in the wikidata:
- Lua error in Module:Wd/sandbox at line 250: A reference contains malformed parameters.
- Why would you have the module emit an error message like that? Error message must be meaningful or at the very least link to documentation that explains the error message. Further, using
<strong>...</strong>
and a larger font size for error messages is a lot like SHOUTING; don't do that. - —Trappist the monk (talk) 13:58, 29 March 2023 (UTC)
- @Trappist the monk: I have tweaked the output, please see my sandbox. Is it OK now? Janhrach (talk) 19:30, 29 March 2023 (UTC)
- The appearance is better but the message:
- Error: Reference contains a combination of parameters incompatible with Cite Web and Cite Q templates.
- is wholly untrue, isn't it? If I go to d:Q112795079#P279 and look in the reference I find reference URL (P854), author name string (P2093), author (P50), & publication date (P577). All of these appear in d:Q112795079#P31 and all but P50 appear in d:Q212885#P348. The references created for those latter two are apparently rendered by
{{cite web}}
. Clearly then, the 'parameters' in Q112795079#P279 are not ... incompatible with Cite Web and Cite Q templates. - Why is
the first error in Module:Wd/sandbox/testcases/1
no longer broken? It is one of the twoQ55|P1081
tests (don't remember which). It showed the shouted error message but doesn't show the new error message. Should it? - —Trappist the monk (talk) 22:42, 29 March 2023 (UTC)
- The appearance is better but the message:
- @Trappist the monk: I have tweaked the output, please see my sandbox. Is it OK now? Janhrach (talk) 19:30, 29 March 2023 (UTC)
- Emitting a Lua script error is clearly the wrong thing to do because it misleads the reader into thinking that the problem is in the Lua module when it is really in the wikidata:
- @Trappist the monk: I have removed the fallback mode, see my sandbox for the output. One problem is that Wikidata doesn't seem to mandate any other reference parameters than URL. See the first error in Module:Wd/sandbox/testcases/1. The
- Because the 'fallback' does not look like a cs1|2 template rendering, I stand by my previous comment:
@Trappist the monk: In technical sense, the term "[incompatible] combination of parameters" includes the fact that the citation lacks the needed parameters. Since it will be probably unclear what it means, it can be replaced with something like: "Error: Unable to display the reference properly. See the documentation for details." The documentation would include something like this (under the subtitle of the error): "The Wikidata reference doesn't contain the minimal set of parameters (title and reference URL for Cite web, "stated in" for Cite Q) or has a set of parameters incompatible with both Cite web and Cite Q". As for the error that disappeared, the reason for its disappearance is that the new error message is returned from the getReference function to avoid terminating the whole script, as calling error() did. The "sourced" command counts error-returning references as valid, and I don't think it's a problem – there is no policy that only statements with references renderable with Cite web/Cite Q are considered sourced. Janhrach (talk) 14:19, 30 March 2023 (UTC)
- Most editors at en.wikipedia are not technical. Error messages or the explanatory text linked from the error message must be written so that any editor can learn what is wrong and how to fix it. 'Technical' answers have no place in error messaging unless the 'fix' is only intended to be fixed by technical editors.
- As an example of poor documentation, look at Template:Cite Q § Module:Wd. That section is the only place where stated in (P248) is mentioned. As it turns out, the mention is incorrect; the citation is rendered by
{{cite web}}
, not by{{cite q}}
. I went looking because|stated in=
is not a{{cite q}}
parameter just as|reference url=
is not a{{cite web}}
parameter. - Just because I was curious, I switched the example template at
{{cite q}}
to use the ~/sandbox:{{Wikidata/sandbox|references|raw|Q2978|P2046}}
- https://www.destatis.de/DE/ZahlenFakten/LaenderRegionen/Regionales/Gemeindeverzeichnis/Administrativ/Aktuell/05Staedte.html.
{{cite web}}
: Missing or empty|title=
(help) "Alle politisch selbständigen Gemeinden mit ausgewählten Merkmalen am 31.12.2018 (4. Quartal)". Federal Statistical Office. Archived from the original on 10 March 2019. Retrieved 10 March 2019.
- https://www.destatis.de/DE/ZahlenFakten/LaenderRegionen/Regionales/Gemeindeverzeichnis/Administrativ/Aktuell/05Staedte.html.
- Really? Should that error message be there? The
{{cite web}}
rendering produced by the live version of{{Wikidata}}
is exactly the same as the reference produced by ~/sandbox – neither are 'good' citations but that is one of the huge failings of{{cite q}}
. - —Trappist the monk (talk) 22:28, 30 March 2023 (UTC)
- @Trappist the monk: The example from the Cite Q documentation is wrong because new claims (about the area of Regensburg) have been added since the example was written. Now (as opposed to the time the example was written), there are 2 references supporting the newest claim (as opposed to the one that was intended to appear in the example), but they aren't enclosed in ref tags because of the raw command, so on the first look, they look like one citation. None of the references uses stated in, so they can't be rendered using Cite Q. If you don't understand me, just look at [8]. On the "80.85 square kilometers" claim (which is inadvertently used on the documentation page), the first reference lacks a title, so it causes the error. The second reference is just a normal URL reference. The "80.81 square kilometers" claim is probably the one intended to appear in the example in the Cite Q documentation.
- As for the inexistent
|reference url
parameter, it isn't used because thereference URL
Wikidata property is mapped to theurl
parameter of Cite web in Module:wd/i18n. Thestated in
property is mapped to the first (unnamed) parameter of Cite Q. - As for the new error message suggested in my last comment, is something wrong with it? Is it still too technical? Janhrach (talk) 14:49, 31 March 2023 (UTC)
- I wasn't trying to get you to justify or explain the poor documentation at
{{cite q}}
. I used it as an example of what not to do. Apparently I failed to communicate – a personal failing that has oft been commented on at en.wikipedia. - Error: Unable to display the reference properly. See the documentation for details. What 'documentation' where? Link to it.
The Wikidata reference doesn't contain the minimal set of parameters (title and reference URL for Cite web, "stated in" for Cite Q) or has a set of parameters incompatible with both Cite web and Cite Q"
A point I was trying to get across is that{{cite web}}
does not have a parameter called|reference URL=
and{{cite q}}
does not have a parameter called|stated in=
. I don't know that it is necessary to distinguish between{{cite web}}
and{{cite q}}
. Perhaps you should avoid the word 'parameters' because wikidata doesn't have parameters. The linked help text should explain what properties are required and how to decide whether to use stated in (P248) or to use reference URL (P854) and title (P1476).- The linked help text should also describe how to find the reference that needs fixing. The
{{cite q}}
documentation is an example worth noting. Wikidata change at the whim of wikidata editors who aren't necessarily wikipedia editors so error messages will pop up unexpectedly on en.wiki articles. Editors at en.wiki won't know why the error messages have suddenly appeared and don't know how and where to fix them. It is important that non-technical and/or novice en.wiki editors be told where to find the source of the error and be given instruction on how to fix that error. - —Trappist the monk (talk) 16:30, 31 March 2023 (UTC)
- Thank you for correcting my misunderstandings. In the next few days, when I'll have time, I'll start working on a concrete text for the module documentation. Janhrach (talk) 19:40, 31 March 2023 (UTC)
- @Trappist the monk: I've written a new section for the module documentation and listed some minor changes here. Can you please review it? While I was writing the documentation, I've noticed a potential bug in my proposed changes to the code of the module, but I haven't had time to fix it yet. And there is also another problem – there is a pending edit request at the bottom of this talk page. Until it is either accepted or denied, I can't make a final version of the (whole) code of the module implementing my proposed changes. Janhrach (talk) 19:41, 11 April 2023 (UTC)
- From your documentation:
or has properties not in the table above, the following error is returned ...
Surely you don't actually mean that do you? Are you suggesting that a url with 'stated in' is an error condition? Other than that, I like it. I wonder if the two tables might be somehow combined for the avoidance of confusion ... - —Trappist the monk (talk) 15:27, 13 April 2023 (UTC)
- From your documentation:
- @Trappist the monk: I've written a new section for the module documentation and listed some minor changes here. Can you please review it? While I was writing the documentation, I've noticed a potential bug in my proposed changes to the code of the module, but I haven't had time to fix it yet. And there is also another problem – there is a pending edit request at the bottom of this talk page. Until it is either accepted or denied, I can't make a final version of the (whole) code of the module implementing my proposed changes. Janhrach (talk) 19:41, 11 April 2023 (UTC)
- Thank you for correcting my misunderstandings. In the next few days, when I'll have time, I'll start working on a concrete text for the module documentation. Janhrach (talk) 19:40, 31 March 2023 (UTC)
- I wasn't trying to get you to justify or explain the poor documentation at
I have clarified the sentence you have mentioned. In the sentence I originally assumed it is clear that the module attempts to use Cite Q only after using Cite web has failed, but now I agree with you that the original sentence needed to be clarified. As for the tables, I don't think it's a good idea to merge them, because they describe different citation renderings which shouldn't be confused. Janhrach (talk) 17:03, 14 April 2023 (UTC)
- @Trappist the monk: I've fixed the bug I've mentioned, so the code in the sandbox is now ready to be copied into the main module file. Janhrach (talk) 13:29, 20 April 2023 (UTC)
- @Trappist the monk: The wording of my previous message is probably not clear. Just to clarify: Please copy Module:wd/sandbox and Module:wd/sandbox/i18n to Module:wd and Module:wd/i18n, respectively. Janhrach (talk) 17:55, 30 April 2023 (UTC)
- I came here to object to your use of
|authors=
in the generated citations. I do not know this module nor do I know and understand Wikidata. As such, I am not qualified to determine if your suggested changes are correct and harmless. You should reactivate the edit request to see if you can attract an editor who is qualified. Have you asked the module's primary author Editor Thayts? - —Trappist the monk (talk) 16:07, 1 May 2023 (UTC)
- OK, so I will make another edit request as soon as I will have time for it. By the way, thank you for all your advice. Janhrach (talk) 13:59, 3 May 2023 (UTC)
- I came here to object to your use of
- @Trappist the monk: The wording of my previous message is probably not clear. Just to clarify: Please copy Module:wd/sandbox and Module:wd/sandbox/i18n to Module:wd and Module:wd/i18n, respectively. Janhrach (talk) 17:55, 30 April 2023 (UTC)
Template-protected edit request on 3 May 2023
This edit request to Module:Wd and Module:Wd/i18n has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Please copy the revision 1150716473 of Module:wd/sandbox to Module:wd and the revision 1150510037 of Module:wd/sandbox/i18n to Module:wd/i18n. I've made several changes to processing of citations. For the explanation, see the text under the previous edit request template, but note that I've additionally removed the fallback mode of processing citations, because Trappist the monk convinced me that I shouldn't retain it. (See the above discussion.) I have also listed proposed changes to the module documentation at User:Janhrach/new_wd_documentation. It would be helpful if @Thayts looked at my proposed changes to the module. Janhrach (talk) 17:41, 3 May 2023 (UTC)
- Done * Pppery * it has begun... 16:56, 6 May 2023 (UTC)
- Thank you. Janhrach (talk) 19:05, 6 May 2023 (UTC)
Support for rounding
One of the most common things I do with information I draw from Wikidata using this template is rounding, since it sounds terrible to say "the museum has approximately 14,747 items" rather than "the museum has approximately 15,000 items," which is easier to read and doesn't imply a false precision. However, the current functionality of the module requires me to fetch the raw value, round it, and then fetch the unit/references separately, which is very clunky. Would it be possible to build in functionality for rounding so that this can be simplified and used more widely? {{u|Sdkb}} talk 21:25, 9 May 2023 (UTC)
- Might be better to use the "input" parameter on Template:Convert, then you'll have full access to all of convert's options — Martin (MSGJ · talk) 21:48, 9 May 2023 (UTC)
- @MSGJ, that wouldn't work unless you want to list a conversion, though, right? The specific example that prompted this request doesn't fall into that category (see this diff), nor do many others. {{u|Sdkb}} talk 22:00, 9 May 2023 (UTC)
- Oh, I was thinking if there were units then it was probably a convertible quantity — Martin (MSGJ · talk) 22:55, 9 May 2023 (UTC)
- @MSGJ, that wouldn't work unless you want to list a conversion, though, right? The specific example that prompted this request doesn't fall into that category (see this diff), nor do many others. {{u|Sdkb}} talk 22:00, 9 May 2023 (UTC)
Non-ASCII numeric delimiter
This is probably not so important for enwiki, but people are copying the module to other wikis and might find it useful. When the ["numeric"]["delimiter"]
in Module:Wd/i18n is set to a non-7bit-ASCII value (for example, to mw.ustring.char(0x202f)
, narrow no-break space) the :reverse
method reverses UTF character bytes in
return left .. (num:reverse():gsub("(%d%d%d)", "%1" .. p['numeric']['delimiter']):reverse()) .. right
A quick solution is to first use some symmetric ascii-7 improbable character combination, such as !@!
:
local temp_delimiter = (num:reverse():gsub("(%d%d%d)", "%1" .. "!@!"):reverse())
return left .. temp_delimiter:gsub("!@!", p['numeric']['delimiter']) .. right
Ponor (talk) 14:33, 26 May 2023 (UTC)
References mapping
I cannot find the discussion, but I know I've talked a bit previously about how it can be difficult to map the properties used for references on Wikidata to the CS1 parameter fields here on Wikipedia, particularly when it comes to the website/work fields.
The current mapping uses stated in (P248) for |website=
. That's generally good, although I often see "stated in" (mis-?)used on Wikidata for things that we'd consider here to be a publisher because they're not italicized (whereas websites/works are italicized). However, there are also other related Wikidata properties.
title of broader work (P6333) is sometimes used when the work/website doesn't have its own item. I think that it should probably map to |website=
.
published in (P1433) is also sometimes used. The distinction between it and "stated in" doesn't appear to be as well-defined as it could be.
I'd appreciate some high-level discussion about how we could improve this mapping. {{u|Sdkb}} talk 20:49, 7 June 2023 (UTC)
- Template:Cite Q § Bibliographic parameters is the only listing that I know of; is that it?
- The talk page of lua module does not seem to me to be very
high-level
. Perhaps find a more publicly visible place for your discussion? - —Trappist the monk (talk) 21:27, 7 June 2023 (UTC)
- There are two other short lists at Module:Wd § References.
- —Trappist the monk (talk) 21:33, 7 June 2023 (UTC)
- On visibility, I've notified WT:CS1, WT:Wikidata, and wikidata:Wikidata:Project chat. Together those will hopefully bring in some folks.
- The lists at Template:Wikidata#References are what I'm referring to, although it's interesting to see that Cite Q has its own list. We certainly want those to be in sync with each other. Cheers, {{u|Sdkb}} talk 21:46, 7 June 2023 (UTC)
- I gotta say, I rarely use the work / website parameters with any kind of precision. Lots of times the citation is to a source that's published in print but accessed via the internet. I do a lot of cleanup of script-assisted refercing, and if the script does something dumb like keep the name of the website after a pipe or ndash in the
title=
parameter while filling out thewebsite=
parameter with the first bit of the URL, I'll just reparameterise the human-readable name of the website topublisher
, since it displays the same to the reader. Also since you can't double up onwebsite
andwork
, I've put the name of the periodical (or whatever) in thework
parameter, and the website invia=
. I hope nothing critical is depending on using these parameters precisely, and if so I'd recommend as a first step that Citoid change its output fromwebsite=
tovia=
. Folly Mox (talk) 23:35, 7 June 2023 (UTC)- The cs1|2 templates produce COinS metadata for those readers who consume citations with reference management software (Zotero is one such tool – which, by the way, is a significant contributor to Citoid... we cannot complain about the quality of the data that it produces without we first put our own house in order).
|publisher=
is not defined for, so not included in, the metadata for{{cite web}}
or for any of the periodical templates ({{cite journal}}
,{{cite magazine}}
,{{cite news}}
).|work=
is a generic alias of|journal=
,|magazine=
,|newspaper=
,|periodical=
, and|website=
. Omitting these parameters from their associated templates prevents that important bit of bibliographic data from getting to Zotero and other reference management software. Similarly,|work=
and its aliases are not defined for, so not included in, the metadata for book, encyclopedia, conference, etc templates. |via=
is a visual-only parameter not defined for the metadata for any of the cs1|2 templates. It would be very wrong of Citoid to use that instead of the appropriate work parameter. Further,|via=
has a specific purpose: to minimize astonishment when the reader lands at an on-line location that is different from the publisher's on-line location; see the (not really very good) documentation.- It is good to
[parameterise] the human-readable name of the website
but it should not be to|publisher=
.|website=
should only get the domain name when the source is best known by that name. See also: Help:Citation Style 1 § Work and publisher. We are citing the publisher's work, not the company. - —Trappist the monk (talk) 00:14, 8 June 2023 (UTC)
- I am trying to create the best citations possible – in general: sometimes I get lazy and perform the reparameterisations described above – and I don't want to come off as oppositional, since I recognise we're on the same team. But if
website=
should only get the domain name when the source is best known by that name
, why do scripts assign that parameter the domain name more than nineteen times in twenty? Can things be adjusted such that thewebsite=
parameter gets assigned the domain name for a whitelist of domains, a human-readable name when the appropriate function can determine one, and remains unassigned in all other cases? Folly Mox (talk) 05:16, 8 June 2023 (UTC)
- I am trying to create the best citations possible – in general: sometimes I get lazy and perform the reparameterisations described above – and I don't want to come off as oppositional, since I recognise we're on the same team. But if
- The cs1|2 templates produce COinS metadata for those readers who consume citations with reference management software (Zotero is one such tool – which, by the way, is a significant contributor to Citoid... we cannot complain about the quality of the data that it produces without we first put our own house in order).
Problem in Template:Infobox Russian inhabited locality
I recently edited Kazan as part of a citation repair project, and one of its references displays the pink text Error: Unable to display the reference properly. See the documentation for details., with "the documentation" linking this module.
The error is coming from Template:Infobox Russian inhabited locality, in the bit about 2018 population estimates, where it calls {{wikidata|reference|P1082|P585=2018-01-01}}. I thought I'd ask here if anyone has any ideas how to resolve the error, but I'm open to redirection if there's a better place to ask, whether on wp-en or on wikidata. Folly Mox (talk) 18:41, 12 June 2023 (UTC)
- The issue probably is that the reference for "1,243,500" on Kazan's Wikidata object uses imported from Wikimedia project (P143). —Dexxor (talk) 08:02, 13 June 2023 (UTC)
According to the documentation imported from Wikimedia project (P143) references should be ignored. So perhaps the error is coming from the second reference (maybe the Russian title) instead?More testing is needed. — Martin (MSGJ · talk) 10:11, 13 June 2023 (UTC)- Correction - the error is coming from the first reference. The module is correctly ignoring imported from Wikimedia project (P143), but then all it has is the reference URL (P854) without any title so it can't use {{cite web}}. If you add title (P1476) to the first reference, then it use the first reference. — Martin (MSGJ · talk) 10:15, 13 June 2023 (UTC)
- I suspect what we would like to do is to ignore the whole reference if any of the reference properties include imported from Wikimedia project (P143). That would be a significant change to the way the module is currently coded. — Martin (MSGJ · talk) 10:26, 13 June 2023 (UTC)
- Can I ask, what would be the positives of doing so? Janhrach (talk) 06:40, 18 June 2023 (UTC)
- For now I have deleted the URL which was a dead link anyway. It now correctly displays the second reference for that value. — Martin (MSGJ · talk) 10:29, 13 June 2023 (UTC)
Testing on Wikidata Sandbox (Q4115189):
References
Wikimedia import URL (P4656) should be ignored
This module should ignore Wikimedia import URL (P4656). I have made a fix to the module sandbox. For a sample output, see my sandbox. Apart from ignoring P4656, my code ignores retrieved (P813) when P4656 is present but reference URL (P854) is not, as it is probable that P813 belongs to P4656. If there are no issues with my suggested changes, I'll file an edit request in several days. Janhrach (talk) 08:18, 18 June 2023 (UTC)
Edit request on 23 June 2023
This edit request to Module:Wd has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Please copy the contents of the module sandbox to the main module page. The explanation of the changes is above. Janhrach (talk) 17:17, 23 June 2023 (UTC)
gsub pattern bug?
I was editing the module on another wiki and the editor warned me of an invalid escape sequence in
mw.ustring.gsub(datavalue['amount'], "^\+(.+)$", "%1")
If I'm reading the manual correctly, the escape character is indeed %, not \. So \+
should be replaced with %+
(twice). Ponor (talk) 21:44, 25 May 2023 (UTC)
- You are probably correct but try these in the debug console:
=string.gsub ('+something', "^\+(.+)$", "%1")
→ something 1=string.gsub ('+something', "^+(.+)$", "%1")
→ something 1=string.gsub ('+something', "^%+(.+)$", "%1")
→ something 1
- Number three is probably the 'most' correct. I expect that number 2 works because is doesn't make sense to quantify the zero-width assertion
^
. Does number 1 work because of a flaw? because\
is a character-in-a-string-escape-character (similar to:local pear_type_str = 'D\'Anjou'
)? I don't actually know. - —Trappist the monk (talk) 22:25, 25 May 2023 (UTC)
- I'm only guessing (and mostly repeating your ideas), but it could be that whatever parses that pattern-string first reduces #1 to #2 (there's a mention of something similar with \ddd), which then works because + means nothing but + after that ^. I'd still fix this, so people don't get confused by those two error messages (❌). Ponor (talk) 23:47, 25 May 2023 (UTC)
- What
error messages
? - —Trappist the monk (talk) 23:49, 25 May 2023 (UTC)
- Start editing, next to line number 405 there's gonna be a red square that'll show the error message. Ponor (talk) 09:39, 26 May 2023 (UTC)
- @Ponor: I've investigated this a bit and I've come to the same conclusion as you. But is using
gsub
really necessary?tonumber
doesn't seem to have problems with+
at the beginning of its input, so I think that removing the plus sign is unnecessary. Janhrach (talk) 09:49, 25 June 2023 (UTC)- @Janhrach, I agree. It's just hard to tell what made people put it there, maybe things did not work back then. Which is not the reason to keep it there forever. Ponor (talk) 15:26, 26 June 2023 (UTC)
- I've fixed the error in the sandbox by removing
gsub
. After that, another error of nearly the same kind was shown by the editor on the line 875, which I fixed by replacing\
whith%
. I have a sample output in my sandbox. I've verified both of the examples execute the altered code lines and that output is also correct when+
shouldn't be stripped from the input. If there is no problem with my changes, I'll make an edit request soon. Janhrach (talk) 11:56, 27 June 2023 (UTC)
- I've fixed the error in the sandbox by removing
- @Janhrach, I agree. It's just hard to tell what made people put it there, maybe things did not work back then. Which is not the reason to keep it there forever. Ponor (talk) 15:26, 26 June 2023 (UTC)
- What
- I'm only guessing (and mostly repeating your ideas), but it could be that whatever parses that pattern-string first reduces #1 to #2 (there's a mention of something similar with \ddd), which then works because + means nothing but + after that ^. I'd still fix this, so people don't get confused by those two error messages (❌). Ponor (talk) 23:47, 25 May 2023 (UTC)
Edit request on 30 June 2023
This edit request to Module:Wd has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Please copy the contents of the module sandbox to the main module page. The explanation of the changes is above. For context, read the whole discussion please. Janhrach (talk) 13:58, 30 June 2023 (UTC)
- Done — Martin (MSGJ · talk) 14:14, 30 June 2023 (UTC)
- Thank you. Janhrach (talk) 14:14, 30 June 2023 (UTC)
Possible bug on Mark Lewis page
I am getting citation errors on the page Mark Lewis (filmmaker) for the code {{wikidata|references|P800}}
Usually, that kind of error is caused because Wikidata doesn't have enough information to produce a valid citation. However, in this case, the citation information on Wikidata at d:Q6768591#P800 is more than adequate. Is this a bug or am I using the template incorrectly? Daask (talk) 06:23, 6 July 2023 (UTC)
- @Daask: Thank you for noticing this, it is a bug – the module doesn't recognize published in (P1433). I will make an edit request fixing the bug soon. Janhrach (talk) 15:52, 6 July 2023 (UTC)
Edit request on 8 July 2023
This edit request to Module:Wd and Module:Wd/i18n has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Please copy Module:Wd/sandbox to Module:Wd and Module:Wd/sandbox/i18n to Module:Wd/i18n. It is a fix for the bug reported above. Sample output is here. Janhrach (talk) 07:22, 8 July 2023 (UTC)
- Done And you should consider requesting template editor rights, since you seem to know what you are doing. * Pppery * it has begun... 18:08, 10 July 2023 (UTC)
- Thank you, I will consider that option. Janhrach (talk) 18:52, 10 July 2023 (UTC)
- Update: I don't satify the criteria 3 and 5 here, but when I will, I will make a request. Janhrach (talk) 19:31, 10 July 2023 (UTC)
- Looks like you satisfy 3 to me: Per edit counter tools, 135 module edits + 18 template edits = 153 total edits. I agree that you're technically 1 sandbox short of 5. * Pppery * it has begun... 19:49, 10 July 2023 (UTC)
- @Pppery: Oh, thank you for noticing that, I didn't to look at the template namespace, because I mistakenly thought my edit count there is negligible. Janhrach (talk) 12:45, 11 July 2023 (UTC)
- Looks like you satisfy 3 to me: Per edit counter tools, 135 module edits + 18 template edits = 153 total edits. I agree that you're technically 1 sandbox short of 5. * Pppery * it has begun... 19:49, 10 July 2023 (UTC)
- Update: I don't satify the criteria 3 and 5 here, but when I will, I will make a request. Janhrach (talk) 19:31, 10 July 2023 (UTC)
- Thank you, I will consider that option. Janhrach (talk) 18:52, 10 July 2023 (UTC)
Thousands of broken references
Looking at this search there appears to be thousands of articles with reference errors resulting from imports from Wikidata. Is there any category tracking these errors or anyone attempting to fix the underlying issue? -- LCU ActivelyDisinterested ∆transmissions∆ °co-ords° 13:11, 23 June 2023 (UTC)
- @ActivelyDisinterested, I've tried {{#invoke:wd|reference|raw|Q43148|P8843|P585=2000}}→"Estimation of Local Poverty in the Philippines" (PDF). Philippine Statistics Authority. 29 November 2005. It was missing a title on wikidata. Year 2003 is *still* without a title (here: Tayug (Q43148)), so {{#invoke:wd|reference|raw|Q43148|P8843|P585=2003}}→"2003 City and Municipal Level Poverty Estimates" (PDF). Philippine Statistics Authority. 23 March 2009. Ponor (talk) 14:08, 23 June 2023 (UTC)
- Thanks but that's not what I'm asking. There are thousands of these, I'm wondering if that is being tracked. -- LCU ActivelyDisinterested ∆transmissions∆ °co-ords° 14:22, 23 June 2023 (UTC)
- There is, apparently, no tracking in this module. We could add a category link, perhaps Category:Wd reference errors or some such, to the error message at Module:Wd/i18n line 14. Is there a better category name?
- —Trappist the monk (talk) 14:44, 23 June 2023 (UTC)
- "Module:Wd reference errors" would be fine, but "Wikidata reference errors" could be more obvious. Also is there anyway to make the error more prominent? The more obvious the error the more motivated people are to fix them. At the moment the error in down in the reference section, but could it be displayed instead of footnote number? -- LCU ActivelyDisinterested ∆transmissions∆ °co-ords° 15:14, 23 June 2023 (UTC)
- These error messages are specific to this module, not to all methods of fetching stuff from wikidata.
could it be displayed instead of footnote number?
What do you mean by that? - —Trappist the monk (talk) 15:31, 23 June 2023 (UTC)
- I thought that that might be the case, "Category:Module:Wd reference errors" would be fine.
- I mean could an error be displayed where the citation in the text would be, rather than in the reference section. So rather than [1], there would be a message [some cutdown version of the error message]. Similar to how other inline messages work. -- LCU ActivelyDisinterested ∆transmissions∆ °co-ords° 15:56, 23 June 2023 (UTC)
- What
inline messages
replace a superscript reference indicator with a plain-text message? I have seen messages (as separate templates –{{failed verification}}
for example) follow the reference indicator but never an outright replacement. I'm not enthusiastic about figuring out how to do that and am not sure it is desirable were it doable – I'm not really interested in doing significant work on this module. I am willing to add the category but beyond that, I leave it to someone else. - —Trappist the monk (talk) 17:30, 23 June 2023 (UTC)
- Category:Wd reference errors created.
- —Trappist the monk (talk) 17:42, 23 June 2023 (UTC)
- Thanks Trappist. -- LCU ActivelyDisinterested ∆transmissions∆ °co-ords° 18:16, 23 June 2023 (UTC)
- What
- These error messages are specific to this module, not to all methods of fetching stuff from wikidata.
- "Module:Wd reference errors" would be fine, but "Wikidata reference errors" could be more obvious. Also is there anyway to make the error more prominent? The more obvious the error the more motivated people are to fix them. At the moment the error in down in the reference section, but could it be displayed instead of footnote number? -- LCU ActivelyDisinterested ∆transmissions∆ °co-ords° 15:14, 23 June 2023 (UTC)
- Thanks but that's not what I'm asking. There are thousands of these, I'm wondering if that is being tracked. -- LCU ActivelyDisinterested ∆transmissions∆ °co-ords° 14:22, 23 June 2023 (UTC)
- After a bit of work with Ponor I've just put through a set of titles for refs on Philippine town items, which should clear about 1500 pages out of this category when it's finished processing (hopefully later tonight). Sampling some of the others I think the majority are likely to be also missing a "title" field. However, there are a few complicated ones - eg I have no idea what is going on with Canadian English, where the references seem to have the right metadata. Andrew Gray (talk) 22:38, 27 June 2023 (UTC)
- Just to be clear, it was my unsuccessful attempt, and Andrew was kind enough to sort things out properly. I'm only thinking: wouldn't it be better to have a link in those red messages that takes you straight to wikidata, where a title is missing, instead of the generic message that leaves you clueless where and what needs to be done? Ponor (talk) 23:56, 27 June 2023 (UTC)
- It's already at least 1400 down, nicely done. -- LCU ActivelyDisinterested ∆transmissions∆ °co-ords° 00:44, 28 June 2023 (UTC)
- Thanks! Cleared off another 200-odd now. I think that might be the easiest ones but I'll see if there's others that can be solved in a batch - there seems to be some possibilities with Swiss data there but I haven't quite disentangled it yet.
- Looking at Canadian English which I mentioned above, I think the problem here is that the reference statements have subject named as (P1810). This isn't supported by the mapping for either {{cite web}} or {{Cite Q}}, which I think is why it's going to an error message.
- This particular case is a weird one, but in general this is a fairly common pattern for things which are sourced with an ID property - combine "named as" with stated in (P248) and an ID property - example. I wonder then if it would be worth tweaking Cite Q so that it can treat subject named as (P1810) as a backup to title (P1476) if an actual title is not present (the ID properties are already supported by Cite Q). That might clean up a swathe of them. Andrew Gray (talk) 23:26, 28 June 2023 (UTC)
- Don't quote me on this, but I believe this is all using Cite Web not Cite Q. -- LCU ActivelyDisinterested ∆transmissions∆ °co-ords° 00:29, 29 June 2023 (UTC)
- @ActivelyDisinterested: Yes, you are right. And Andrew Gray is right that the problem is with subject named as (P1810). I think it is a good idea to modify this module to use P1810 as title when title (P1476) is not present. By the way, I thank Andrew Gray very much for his work on eliminating the errors. Janhrach (talk) 13:32, 30 June 2023 (UTC)
- I've implemented the suggested changes in the sandbox. A sample output is in my sandbox. The first test shows that the module correctly removes subject named as (P1810). The second and the third reference in the second test shows that the module uses P1810 as the title if title (P1476) is missing. However, the output isn't correct – the replaced title is actually the name of the database. But this is just a consequence of the incorrect handling of database references. Until I will have completely fixed the handling of database references, I am not going to make an edit request fixing P1810. Janhrach (talk) 15:34, 1 July 2023 (UTC)
- @ActivelyDisinterested: Yes, you are right. And Andrew Gray is right that the problem is with subject named as (P1810). I think it is a good idea to modify this module to use P1810 as title when title (P1476) is not present. By the way, I thank Andrew Gray very much for his work on eliminating the errors. Janhrach (talk) 13:32, 30 June 2023 (UTC)
- Don't quote me on this, but I believe this is all using Cite Web not Cite Q. -- LCU ActivelyDisinterested ∆transmissions∆ °co-ords° 00:29, 29 June 2023 (UTC)
@ActivelyDisinterested and Andrew Gray: I've fixed the handling of database references. The sample output in my sandbox. Previously, database references were displayed using Cite Q with an additional id parameter, see for example the reference no. 8 in my sandbox. Now, the module fetches Wikidata property (P1687) properties from the item in stated in (P248). Then a URL is generated from the first P1687 whose datatype is external-id and is present in the reference; the generated URL is then handled in the same manner as reference URL (P854). Additionally, I have modified the handling of subject named as (P1810) to use it as title only when a URL is present to avoid bugs. I would be happy if you reviewed my code. Janhrach (talk) 16:28, 3 July 2023 (UTC)
- @Janhrach the output there looks good, thankyou for looking into it! Andrew Gray (talk) 21:20, 4 July 2023 (UTC)
- I was hoping this would help clear down the cat, big it's doesn't seem to have happened. Wasy expectation wrong or is there some other update that has to happen? -- LCU ActivelyDisinterested ∆transmissions∆ °co-ords° 12:14, 11 July 2023 (UTC)
- @ActivelyDisinterested: I think most of the errors are caused by missing titles in URL-only references or similar. That couldn't be fixed any other way than by improving Wikidata. Janhrach (talk) 12:37, 11 July 2023 (UTC)
- Thanks for the explanation. -- LCU ActivelyDisinterested ∆transmissions∆ °co-ords° 12:39, 11 July 2023 (UTC)
- @ActivelyDisinterested I think someone may have enabled a new infobox lookup or similar as well - it was down to about 1000 at one point and has now risen again. So I guess that new additions are outpacing any corrections. Wonder if it's possible to track those numbers somehow, hmm.
- I'll see if I can figure out some more potential batch fixes on the WD side to try and bring it down again. Andrew Gray (talk) 16:59, 11 July 2023 (UTC)
- PetScan allows you to output the content of categories (the output tab allows you to download the results). I do the same for my work on Category:Harv and Sfn no-target errors. It would manually running the scan periodically though. -- LCU ActivelyDisinterested ∆transmissions∆ °co-ords° 17:58, 11 July 2023 (UTC)
- Very belatedly, but FYI I'm now running a regular script to check on this - logs the current number and the most recent item. Usually drifts down by a couple of items a day. Will keep an eye out for sudden spikes which indicate a batch that could be addressed.
- After some further investigation, it looks like the vast majority of these seem to be software version numbers that reference the release notes with a plain URL, and while it's straightforward to add a title to the reference manually, it's unfortunately a bit beyond my abilities to write up a bot to do it at scale. Andrew Gray (talk) 20:58, 8 August 2023 (UTC)
- PetScan allows you to output the content of categories (the output tab allows you to download the results). I do the same for my work on Category:Harv and Sfn no-target errors. It would manually running the scan periodically though. -- LCU ActivelyDisinterested ∆transmissions∆ °co-ords° 17:58, 11 July 2023 (UTC)
- Thanks for the explanation. -- LCU ActivelyDisinterested ∆transmissions∆ °co-ords° 12:39, 11 July 2023 (UTC)
- @ActivelyDisinterested: I think most of the errors are caused by missing titles in URL-only references or similar. That couldn't be fixed any other way than by improving Wikidata. Janhrach (talk) 12:37, 11 July 2023 (UTC)
Edit request on 5 July 2023
This edit request to Module:Wd has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Please copy the sandbox to the main module page. The new code fixes handling of database references (as described in my last reply in this discussion) and uses subject named as (P1810) as the reference title when a URL is present in the reference but title (P1476) is not. Janhrach (talk) 12:15, 5 July 2023 (UTC)
- Completed. P.I. Ellsworth , ed. put'er there 16:42, 5 July 2023 (UTC)
- Thank you. Janhrach (talk) 18:34, 5 July 2023 (UTC)
- Happy to help! Paine 18:56, 5 July 2023 (UTC)
- Thank you. Janhrach (talk) 18:34, 5 July 2023 (UTC)
Using appropriate CS1 templates
It appears that {{Wikidata}} always uses {{Cite web}}. Sometimes that differs a bit from e.g. {{Cite news}} or other CS1 templates, though. Would it be possible to improve the module so that it recognizes when it's citing a newspaper/book/journal and uses the appropriate template? {{u|Sdkb}} talk 04:23, 2 September 2023 (UTC)
- @Sdkb: Basically, there are two types of sources on Wikidata: ones using stated in (P248) and ones using reference URL (P854). Per Wikidata:Help:Sources, newspapers, books and journals should use the former option. Only citations containing P854 are formatted using {{Cite web}}. Janhrach (talk) 06:48, 2 September 2023 (UTC)
- This touches on the discussion about mapping above. Currently, for something like a newspaper article, the correct procedure seems to be to use stated in (P248) for the newspaper name and reference URL (P854) for the article URL. Only using P248 would be an incomplete citation, as it would not lead back to the specific article. {{u|Sdkb}} talk 16:02, 2 September 2023 (UTC)
- @Sdkb: stated in (P248) should contain not the newspaper item, but the article item. The Wikidata guideline says that every cited article should have its own item. Janhrach (talk) 06:45, 3 September 2023 (UTC)
- @Janhrach, that would be wildly impractical for simple newspaper articles. {{u|Sdkb}} talk 13:40, 3 September 2023 (UTC)
- @Sdkb: I understand, but that's a Wikidata policy. I am not sure, but I think I have read somewhere on Wikidata about a tool for generating newspaper article items on demand – it may be useful. Janhrach (talk) 19:06, 9 September 2023 (UTC)
- @Janhrach, that would be wildly impractical for simple newspaper articles. {{u|Sdkb}} talk 13:40, 3 September 2023 (UTC)
- @Sdkb: stated in (P248) should contain not the newspaper item, but the article item. The Wikidata guideline says that every cited article should have its own item. Janhrach (talk) 06:45, 3 September 2023 (UTC)
- This touches on the discussion about mapping above. Currently, for something like a newspaper article, the correct procedure seems to be to use stated in (P248) for the newspaper name and reference URL (P854) for the article URL. Only using P248 would be an incomplete citation, as it would not lead back to the specific article. {{u|Sdkb}} talk 16:02, 2 September 2023 (UTC)
Coordinates precision
Forgive me my laziness, I'm hoping someone will know the answer without digging too deep into the code. I would like {{#invoke:Wd|property|Q522100|P625|P518=Q1233637}}
to return
43°26'N, 16°41'E
instead of
43°26'20.8"N, 16°41'11.0"E
.
How do I set the precision? I see it in the code, but not in any of the examples. Thanks. Ponor (talk) 15:13, 24 September 2023 (UTC)
- @Ponor: The code probably uses the precision set in Wikidata, not in Wikipedia. Janhrach (talk) 14:38, 27 September 2023 (UTC)
Built-in citation needed function
Would it be possible to build in a mechanism for the references function of {{Wikidata}} to output a {{Citation needed}} tag if it does not come up with any references? For instance, when we use the template to fetch the number of students at a university, it's theoretically possible that someone in the future will update the count of students (P2196) (setting the more recent value to preferred rank) but not add references. If that happens, it'd be nice for there to be a citation needed tag rather than for the references function to just not display. {{u|Sdkb}} talk 04:21, 4 October 2023 (UTC)
- I'm seeing a use case for this sort of thing at Associated Students of Pomona College, where Module:WikidataIB should be used instead of this module, per the documentation and a related RFC. Using that module will take care of sourcing for you and will decline to show data when sourced numbers are not available. You could tell the module what to display or output a tracking category if if can't get a sourced number. – Jonesey95 (talk) 04:57, 4 October 2023 (UTC)
- @Jonesey95, thanks for the reply; I'll look into converting to Module:WikidataIB there. The particular use case that prompted me to ask here was the first sentence of Pomona College § Student body, where the number of students is used in the prose, so just blanking isn't an option. When I was updating the data for this semester on Wikidata, I tried waiting a moment to add the reference for the new data, hoping that I'd configured the
single
flags (or whatever it is I need to be configuring; perhaps I need to only allowpreferred
-ranked data?) well enough that it would identify that a reference is missing. But it just spit out all the references for the old data instead. The flags are a confusing enough part of the template that I just haven't been able to get them to work quite right. {{u|Sdkb}} talk 05:41, 4 October 2023 (UTC) - As far as I know WikidataIB does not yet display any references — Martin (MSGJ · talk) 09:06, 4 October 2023 (UTC)
- @Jonesey95, thanks for the reply; I'll look into converting to Module:WikidataIB there. The particular use case that prompted me to ask here was the first sentence of Pomona College § Student body, where the number of students is used in the prose, so just blanking isn't an option. When I was updating the data for this semester on Wikidata, I tried waiting a moment to add the reference for the new data, hoping that I'd configured the
Adding names to the coordinates list
I'm using {{GeoGroup}} on Misty Range where I pull the coordinates into the table of mountains using {{wikidata}}:
e.g. {{wikidata | property | page=Mount Rae | linked | coord}}
That works fine but when I click the OpenStreetMap link, the coordinates list on the left is showing "#1", "#2", "#3", "#4" for the names/labels for each coordinate. If you call {{coord}} directly and pass the name parameter, then OSM will display that name rather than "#1". However, I don't see how can set the coordinates name when I'm using {{wikidata}} to extract the coordinates. RedWolf (talk) 22:10, 4 September 2023 (UTC)
- @RedWolf: From a quick look at the source code of the module, it seems that is doesn't implement named coordinates. Janhrach (talk) 13:55, 14 September 2023 (UTC)
- Thanks. I wonder if we could add a new named argument such as "coords_title" and then modify Config:getValue() to append this argument (if given) to the URL it builds when datatype = 'globecoordinate'. RedWolf (talk) 17:19, 23 September 2023 (UTC)
- I have created Module:Titled_coords and its helper template {{Titled_coords}} to address this issue. RedWolf (talk) 21:33, 20 October 2023 (UTC)
Edit request
This edit request to Module:wd has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Line 2006: please change "crimson" to "#d33" per above. Also change "4" on the line 1819 to "5". Janhrach (talk) 13:26, 26 October 2023 (UTC)
- Done – Jonesey95 (talk) 14:36, 26 October 2023 (UTC)
Problems with this module
I get it, semantic web shit is cool for nerds, but this doomed tech experiment is hurting Wikipedia instead of helping it. The people responsible should switch focus; their goal should be to help Wikipedia editors and not the likes of Google and LLMs and other cringe techbro buzzwords. I understand that the ideal solution, getting rid of wikidata, will not happen, so we should try to minimize the harm it is causing.
There are a bunch of problems with this module:
- This module shows errors, but it is not clear how to fix the errors unless you spend 73 hours trying to understand how it and Wikidata work. The solution should be two-fold:
- It should be made clear on wikidata and in the article which attributes are missing/incorrect. Nota bene, currently this is explained in neither of those places. One or the other is not an acceptable solution. It should be explained in both places.
- Someone should write a detailed tutorial/helppage. But a link to that is not enough; in addition we need specific instructions which piece of data is causing the problem.
- The warning messages are alarmist and displayed very prominently, even when it is an incredibly minor problem or not a real problem at all. A very large majority of the pages in Category:Module:Wd reference errors do not have a problem that is big enough to warrant such a obnoxious warning message.
- For example: A reference url without a title (which appears to be optional at Wikidata) is handled poorly. For comparison,
{{Cite web|url=https://github.com/andresriancho/w3af/releases/tag/1.6.54}}
produces:
https://github.com/andresriancho/w3af/releases/tag/1.6.54. {{cite web}}: Missing or empty |title= (help)
That still gives a clickable reference and the red message is less prominent.
The Wikidata equivalent instead shows nothing. No explanation of what is wrong or how to fix it. All you get is this message that explains nothing and links to generic advice that isn't applicable:
Error: Unable to display the reference properly. See the documentation for details.
- For example: A reference url without a title (which appears to be optional at Wikidata) is handled poorly. For comparison,
- The message doesn't even link to the reference URL.
- The message falsely claims it is an error when no error has occured. There is just a missing piece of wikidata. 99.99999% of people who see that message are not willing and able to add that piece of wikidata.
- The message doesn't even link to the place on Wikidata where the problem is.
- The message uses crimson while other messages like the cite web template use #d33.
This means that people would have to read and understand all that documentation, find the location where the reference is inserted, figure out they have to click on the pencil icon, discover an entirely new and incredibly unuserfriendly interface on a separate website and figure out how to fix the error there, then go back to the article to see if they actually managed to fix the problem, discover they have not or that there are other problems and repeat the process (newsflash: 99% of Wikipedia editors won't do all that, why are you trying to force them to).
Even if you do something that should be simple, e.g. you add an infobox to an article, you get the message and no way to fix it. For example {{Infobox Swiss town}} causes problems for example in Lausanne, Geneva, Zug, Montreux, Bern, Solothurn (I got too lazy to find more examples).
I understand that this is people's baby and the WMF probably wasted a fuckton of money on it; but it should be clear that this is a net negative for 99% of editors at the moment. Things used to be so simple. More complexity is not an improvement. Polygnotus (talk) 04:00, 24 October 2023 (UTC)
- That is quite a rant. I agree with one point, at least. In Lausanne, reference #2 displays "Error: Unable to display the reference properly. See the documentation for details." instead of displaying "https://www.pxweb.bfs.admin.ch/pxweb/fr/px-x-0102020000_201/-/px-x-0102020000_201.px/table/tableViewLayout2/?rxid=c5985c8d-66cd-446c-9a07-d8cc07276160", which is the source that supports the population figure. Showing only the error message is unhelpful. Showing the URL along with a more explanatory error message would be helpful; something like "Error: url requires title in Wikidata" (with a link to the relevant section of P1082 in the article's Wikidata entry) might lead ambitious editors to fix the actual problem. – Jonesey95 (talk) 04:26, 25 October 2023 (UTC)
- @Polygnotus: On the problems you listed:
- The relevant section is four-paragraph-long. While it doesn't directly describe how to fix a reference, it makes it clear when is the error printed. Everyone who doesn't understand can ask on this page. Yes, the messages could refer to specific parts of the reference which are invalid, I will work on that later. Note: this module is not directly related to Wikidata as a project, it is a Wikipedia module for rendering data.
- Yes, the messages should be more specific. As for the messages being too alarmist, see this discussion. User:Trappist the monk wanted an error message if the reference is not renderable using CS1, and I agree with them.
- See 2.
- See 2.
- Ok, this should also be fixed.
- This is a minor issue fixable with an edit request.
- In the end, all good arguments against Module:Wd can be summarized into following:
- The error massage should be more specific.
- Right now, I do not spend much time editing Wikipedia. The reference handling function should be cleaned up first. To fix it, it is needed to fix the testcases.
- Janhrach (talk) 13:04, 26 October 2023 (UTC)
- The citation (reference #2 in Lausanne) is renderable using {{cite web}}, though. It looks like this:
- https://www.pxweb.bfs.admin.ch/pxweb/fr/px-x-0102020000_201/-/px-x-0102020000_201.px/table/tableViewLayout2/?rxid=c5985c8d-66cd-446c-9a07-d8cc07276160.
{{cite web}}
: Missing or empty|title=
(help) - The error message is incorrect. This basic problem is not yet fixed. – Jonesey95 (talk) 14:44, 26 October 2023 (UTC)
- @Jonesey95: By "renderable using CS1", I meant without errors. Also, I mentioned the phrase only in the last comment. The documentation is more specific.
- I know the error message should say what extra properties does the reference contain, or which needed properties it does not, but I will fix that later. Maybe the module should leave reporting a missing title for now, as a temporary solution. Janhrach (talk) 14:59, 26 October 2023 (UTC)
Bot task: adding "title" to a reference url
It's Grumpy again; is there a bot that adds the title to a reference URL on Wikidata if its missing? It could simply scrape the HTML <title> tag. The results wouldn't be perfect, but of course they would be better than the current situation. The bot could leave a short message on the relevant talkpage explaining this is a bot action and humans are invited to make improvements where they see fit. Polygnotus (talk) 16:58, 26 October 2023 (UTC)
- I've asked on Wikidata. Janhrach (talk) 13:14, 27 October 2023 (UTC)
- @Janhrach: I see your post here but shouldn't we ask on WP:BOTREQ instead? Polygnotus (talk) 10:19, 28 October 2023 (UTC)
- This is an intriguing idea, but it'd have to be handled with care. Bot messages on every talk where this happens is not handling with care (it's asking for "external links modified" 2.0). {{u|Sdkb}} talk 13:41, 28 October 2023 (UTC)
- @Polygnotus: (I assume you meant d:WD:BOTREQ) The page says that asking on the Project Chat is preferable, so I decided to ask there first. Janhrach (talk) 19:30, 1 November 2023 (UTC)
- @Janhrach: I see your post here but shouldn't we ask on WP:BOTREQ instead? Polygnotus (talk) 10:19, 28 October 2023 (UTC)
Edit request 15 December 2023
This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Description of suggested change: Add optional globalSiteId parameter, for getEntityId() usage to get the QID from a non-enwiki sitelink
Diff: See Special:Diff/1190036817
Testcase: See Special:Diff/1190040466
Example: {{#invoke:wd/sandbox|label|raw|page=Crosslauf-Europameisterschaften 2009|globalSiteId=dewiki}}
should yield Q1141358. Implemented on sandbox and verified all test cases pass. It should not affect any existing behavior, as it only adds a new feature. If there is no opposition to this change, I can implement it. --Habst (talk) 16:12, 15 December 2023 (UTC)
- What is the use case? — Martin (MSGJ · talk) 16:30, 15 December 2023 (UTC)
- @MSGJ, in my case, I wanted to use it to help translate foreign-language pages in my userspace. If I could easily (with a regex) translate all [[wikilinks]] in a dewiki article into
{{#invoke:wd/sandbox|label|raw|page=wikilink|globalSiteId=dewiki}}
(or a template that would make this syntax shorter), I could combine that with {{LinkedLabel}} to effectively translate all the wikilinks in a dewiki article into their enwiki equivalent titles. - This is very helpful, because often times when translating an article, even if you understand the words, it can be difficult to know for sure what the appropriate target for a wikilink is. This can currently be done manually by clicking each wikilink in dewiki and then clicking "view wikidata item", but that's a painstaking manual process that only works one link at a time. --Habst (talk) 21:48, 15 December 2023 (UTC)
- Okay, sounds like a good idea! — Martin (MSGJ · talk) 21:52, 15 December 2023 (UTC)
- @MSGJ, in my case, I wanted to use it to help translate foreign-language pages in my userspace. If I could easily (with a regex) translate all [[wikilinks]] in a dewiki article into
Wikidata reference errors at Taguig
There are two. I have to go to work soon and don't have time to figure out what's wrong over at Wikidata; can I irresponsibly pass ownership of this problem to someone here who understands how to fix it? Folly Mox (talk) 13:58, 12 January 2024 (UTC)
- Well I've retrieved archived for the deadlinked 2015 and 2019 "poverty incidence" reference URLs at d:Q1643: 2015, 2018.I can't figure out how to edit these in at the Wikidata item (which is greylocked) even in desktop view. Folly Mox (talk) 03:40, 13 January 2024 (UTC)
- @Folly Mox: I have fixed that, the reference had missing a title. Janhrach (talk) 08:32, 13 January 2024 (UTC)
- Thank you for those fixes. Is there any way the error output of this module could be made a bit more specific? As a moderately technical editor with at least a basic understanding of where to look for Wikidata errors, I'm not sure how long it would have taken me to guess that the problem here was a missing
title
. Folly Mox (talk) 15:22, 13 January 2024 (UTC)- I have this in my to-do list, but I don't know when I'll do it. The problem is that the testcases are currently triplicated in three pages. I have started centralizing them, but it is tedious and repetitive, so I rarely work on this. I don't want to substatially modify the module until the testcases are ready. So until the testcases are centralized and the module is modified, I will answer editors' questions here. Janhrach (talk) 15:37, 13 January 2024 (UTC)
- Thank you for those fixes. Is there any way the error output of this module could be made a bit more specific? As a moderately technical editor with at least a basic understanding of where to look for Wikidata errors, I'm not sure how long it would have taken me to guess that the problem here was a missing
Error
{{wikidata|references|P11698|eid=Q7227384}}
([1]) is displaying an error, presumably because the module is having trouble with the statement's reference including section, verse, paragraph, or clause (P958). It should be mapped to {{Cite web}}'s |at=
parameter. Could this be fixed? {{u|Sdkb}} talk 06:10, 1 February 2024 (UTC)
- @Sdkb: I have made a fix in the sandbox:
- [1]
- I am not sure this is how it should be displayed, the meaning of "B22" would not be clear for me if I saw it in a citation while reading. What do you think? Janhrach (talk) 20:31, 3 February 2024 (UTC)
- @Janhrach: Looks good to me! My view is that it should be displayed the same as it would in CS1: [2] I agree that the display in CS1 isn't ideal, but that's a larger issue for CS1 to deal with (and not a particularly dire one — having the specific location might help someone trying to verify the information, but it's not really going to harm anyone confused by it). Cheers, {{u|Sdkb}} talk 23:01, 3 February 2024 (UTC)
- Ok, so I will submit an edit request in several days if nobody will have complained. Thank you for reporting this. Janhrach (talk) 08:14, 4 February 2024 (UTC)
- @Janhrach, seeing no concerns, are we good to implement? {{u|Sdkb}} talk 03:57, 8 February 2024 (UTC)
- @Sdkb: Yes, we are. Considering you are a template editor, could you please make the change yourself, so that an edit request isn't needed? Janhrach (talk) 09:40, 11 February 2024 (UTC)
- Done here. Please let me know if there are any issues. Cheers, {{u|Sdkb}} talk 15:58, 11 February 2024 (UTC)
- @Janhrach if you would like the TPE userright, please let me know, as I believe you meet the criteria — Martin (MSGJ · talk) 21:26, 11 February 2024 (UTC)
- I believe I am one template edited short of one of the requirements. Janhrach (talk) 19:29, 18 February 2024 (UTC)
- @Sdkb: Yes, we are. Considering you are a template editor, could you please make the change yourself, so that an edit request isn't needed? Janhrach (talk) 09:40, 11 February 2024 (UTC)
- @Janhrach, seeing no concerns, are we good to implement? {{u|Sdkb}} talk 03:57, 8 February 2024 (UTC)
- Ok, so I will submit an edit request in several days if nobody will have complained. Thank you for reporting this. Janhrach (talk) 08:14, 4 February 2024 (UTC)
- @Janhrach: Looks good to me! My view is that it should be displayed the same as it would in CS1: [2] I agree that the display in CS1 isn't ideal, but that's a larger issue for CS1 to deal with (and not a particularly dire one — having the specific location might help someone trying to verify the information, but it's not really going to harm anyone confused by it). Cheers, {{u|Sdkb}} talk 23:01, 3 February 2024 (UTC)
References
- ^ a b "Pomona College 2023–2024 Common Data Set". Pomona College. B22. Archived from the original on 19 February 2024. Retrieved 17 April 2024.
- ^ "Pomona College 2023–2024 Common Data Set". Pomona College. B22. Retrieved 1 February 2024.
Accessing titles from other Wikipedias
Courtesy link: Module talk:Wd/Archive 1 § Titles from other wikipedias
Still interested in this feature: given a wikidata Q-id and an ISO-639 code 'xx', return the title of the article at xx-wiki for that item. Perhaps as in this mockup:
{{wikidata|wikipedia|lang=es|eid=Q43287}}
→ Imperio alemán
There's also another editor interested in this; adding Your Friendly Neighborhood Sociologist. Thanks, Mathglot (talk) 08:59, 14 February 2024 (UTC)
- Theres a suggestion on the courtesy linked page to use {{#invoke:WikidataIB|getSiteLink|qid=Q43287|wiki=eswiki|ps=1}} >> Imperio alemán, @Mathglot. Ponor (talk) 12:18, 16 February 2024 (UTC)
- @Ponor: Thank you for your comment. I thought I missed a reply in that discussion or something, but it turns out that it came from a different discussion in section § Getting values (labels) from a local Wikipedia, and unfortunately I never saw that one. Also, I believed the response I got in the original discussion that it wasn't possible, so this is a very pleasant surprise. That's some eagle-eyed sleuthing; thanks again! Mathglot (talk) 23:12, 16 February 2024 (UTC)
- Oh... thank you, @Mathglot, I learned something new too. This could be made into a separate template, if needed, so other people can find it:
{{sitelink|qid|wiki}}
//{{sitelink|Q43287|es}}
→ es:Imperio alemán, or whatever you wanna to call it. It's a 10 minute job. Ponor (talk) 23:50, 16 February 2024 (UTC)- @Ponor:, yeah, and creating a template wrapper for it got added to my list the minute you replied and I saw it was workable. Only for me, it's more like a 2–3 hour job: ten minutes to code and test it, just as you say; then maybe 30-45' to write the doc page and maybe create a couple of template shortcuts, and another hour-plus or so to hunt down some RW examples in a few languages, and another hour or so to write the test cases page. Maybe I need to go to perfectionist jail for a while . I think it might need several redirect names; probably 'sitelink' is a good template name, but won't mean much to those who think 'foreign wikipedia title' and it's not obvious to me how to ensure it is findable; all your suggestions would be welcome.
- As it happens, I'm deep into a wrapper creation right now: Draft:HasTemplate, which is going to be incredibly useful once it is released. It's got a backstory that is turning out to be a lot more complex than I ever expected; you can look at this discussion if you're curious, but fair warning: it really gets into the weeds on some things, so what I thought was going to be a terse, one-sentence, one-response discussion, is way more than that. (Feel free to wade in there, if you're not afraid of drowning in the details.) So, I will definitely write {{sitelink}} (or whatever we decide to call it) but you never know when something that seemed like a ten-minute thing at the time, turns out to have all sorts of little issues around it and goes on a lot longer, but I hope not! Mathglot (talk) 00:33, 17 February 2024 (UTC)
- Well... I did something here: Template:Sitelink :) People will probably find it in its category, with other similar templates. Need to figure out how to make the foreign titles wikilinked, nothing like [[:es:xxxx|]] worked.
- {{sitelink|es|qid=Q43287}}: Imperio alemán
- {{sitelink|fr|title=German empire}}: Empire allemand (was cheap to get)
- {{sitelink|fr}} in any article should also work
- Feel free to play further! And whoever's reading this. Ponor (talk) 01:22, 17 February 2024 (UTC)
- Well, you just saved me ten minutes. (I went ahead and updated the doc a bit more; see what you think.) I tested
{{sitelink|fr}}
at German Empire, and it worked perfectly, although there probably won't be much call for that. On the other hand, being able to use it from the associated Talk page would be very useful; I tested it at Talk:German Empire, and of course no big surprise that it returned empty. Any way it could be updated to detect namespace, i.e., switch to {{SUBJECTPAGENAME}} if it were on the Talk page? That would be very useful. Mathglot (talk) 02:52, 17 February 2024 (UTC)- @Mathglot: I have a few usecases on my 'other' wiki, for example when pointing readers to full documentation page for templates taken from enwiki, as in Predložak:Get QID (ha! I used {{sitelink|hr|title=Template:Get QID}} here). I'm pretty sure something can be done about the talk pages, let me think about it. Should that be one wiki's talk page to another wiki's talk page or something else? One can always use QIDs and page titles, I wonder if adding more complexity to our little wrapper template would be worth it. Ponor (talk) 14:17, 19 February 2024 (UTC)
- Well, you just saved me ten minutes. (I went ahead and updated the doc a bit more; see what you think.) I tested
- Well... I did something here: Template:Sitelink :) People will probably find it in its category, with other similar templates. Need to figure out how to make the foreign titles wikilinked, nothing like [[:es:xxxx|]] worked.
- Oh... thank you, @Mathglot, I learned something new too. This could be made into a separate template, if needed, so other people can find it:
- @Ponor: Thank you for your comment. I thought I missed a reply in that discussion or something, but it turns out that it came from a different discussion in section § Getting values (labels) from a local Wikipedia, and unfortunately I never saw that one. Also, I believed the response I got in the original discussion that it wasn't possible, so this is a very pleasant surprise. That's some eagle-eyed sleuthing; thanks again! Mathglot (talk) 23:12, 16 February 2024 (UTC)
"Not enough memory" errors
At Comparison of cross-platform instant messaging clients, many of the table entries are displaying Lua error: not enough memory. for various {{wikidata}} calls. I don't know anything about wikidata lookups, just passing along a message left on that article's talk-page. DMacks (talk) 04:13, 27 February 2024 (UTC)
- And it would be nice to have a better fallback in the future. Clicking on the links results currently in a not very helpful popup. https://i.imgur.com/IyXvE6p.png & MediaWiki:Scribunto-common-no-details should probably link to this page so people can get help if they need it & MediaWiki:Scribunto-lua-error. Polygnotus (talk) 04:33, 27 February 2024 (UTC)
- FWIW: The article source, at the bottom, shows "Lua memory usage: 52428782/52428800 bytes" in the limit report. – Jonesey95 (talk) 18:28, 28 February 2024 (UTC)
A systematic way to avoid reference errors may be needed
I wonder, looking at just the "Comparison of ..." articles in Category:Wd reference errors (currently 1,181 pages), whether a change to the module might help fix some of these errors. Having an error message displayed instead of a reference, especially when nothing has changed in the Wikipedia article, is not good practice. It may be helpful for someone familiar with this module and with Wikidata's structure to look through a sample of these errors to see if a default setting like "prefer the most recent reference when a reference is requested" or a similar preference might help fix some of these errors. – Jonesey95 (talk) 18:55, 28 February 2024 (UTC)
- @Jonesey95: The vast majority of the errors are caused by missing titles. The error messages were introduced into this module as a result of this discussion. I do agree that the current message, which doesn't specify what exactly caused the issue, is not good, and I plan to fix that in some time. However, this might be a complex problem, and I don't think I will have time for that in several months, at least.
- As for the errors specifically, you might want to propose a change the module to not need titles in Wikidata references. In that case, you should read the mentioned discussion. Janhrach (talk) 18:51, 5 March 2024 (UTC)
- A template-based reference that is missing a title is (a) incomplete, and should generate an error message, and (b) should generate an error message saying specifically that the title is missing. I hope that will not be difficult to achieve. – Jonesey95 (talk) 19:15, 5 March 2024 (UTC)
- So we can do nothing about the number of the errors, except editing Wikidata. (Making a Wikidata bot adding titles to references is possible, but I can't do so.) As for no. 2, I am going to fix that sometime. Janhrach (talk) 19:59, 5 March 2024 (UTC)
- A missing title is not an error and should not generate an error message. I asked about making a wikidata bot to add titles to references and all I got was Module_talk:Wd/Archive_1#Bot_task:_adding_"title"_to_a_reference_url 6 months ago you also said "Right now, I do not spend much time editing Wikipedia".[9] Why do we have to depend on 1 busy volunteers spare time to fix this important problem? Perhaps some of that $180.2 million of WMF revenue could be spent on something actually useful? Polygnotus (talk) 20:24, 5 March 2024 (UTC)
- See WP:BAREURL. If not an error message, then at least append {{Bare URL inline}} to tag the reference for cleanup. – Jonesey95 (talk) 20:31, 5 March 2024 (UTC)
- A missing title is not an error and should not generate an error message. I asked about making a wikidata bot to add titles to references and all I got was Module_talk:Wd/Archive_1#Bot_task:_adding_"title"_to_a_reference_url 6 months ago you also said "Right now, I do not spend much time editing Wikipedia".[9] Why do we have to depend on 1 busy volunteers spare time to fix this important problem? Perhaps some of that $180.2 million of WMF revenue could be spent on something actually useful? Polygnotus (talk) 20:24, 5 March 2024 (UTC)
- So we can do nothing about the number of the errors, except editing Wikidata. (Making a Wikidata bot adding titles to references is possible, but I can't do so.) As for no. 2, I am going to fix that sometime. Janhrach (talk) 19:59, 5 March 2024 (UTC)
- A template-based reference that is missing a title is (a) incomplete, and should generate an error message, and (b) should generate an error message saying specifically that the title is missing. I hope that will not be difficult to achieve. – Jonesey95 (talk) 19:15, 5 March 2024 (UTC)
Reference call returns blank on te.wikipedia.org in one case
On te.wikipedia.org, the code used in infobox template for displaying reference is not working in some cases. Example url: https://te.wikipedia.org/wiki/%E0%B0%AA%E0%B1%8D%E0%B0%B0%E0%B0%A4%E0%B1%8D%E0%B0%AF%E0%B1%87%E0%B0%95:ExpandTemplates
template code that does not work
{{#invoke:wd|references|Q18395504|P2046}}
similar template code that works
{{#invoke:wd|references|Q18395504|P1082|P585=2011}}
On en.wikipedia.org at the URL https://en.wikipedia.org/wiki/Special:ExpandTemplates the code works for both cases.
The Templates and Modules involved are replicated on Telugu Wikipedia from English Wikipedia. I request help to address the problem.--Arjunaraoc (talk) 10:43, 20 February 2024 (UTC)
- @Arjunaraoc: I think I have found out the cause of the issue, but I am not certain. Could you send me more examples of this bug?
- I didn't have much time for Wikipedia recently, and I think I won't have in the immediate future, so don't expect this to be fixed in less than ~2 weeks. I will ping you when a fix is ready. Janhrach (talk) 17:19, 23 February 2024 (UTC)
- @Janhrach, The code that I cited is used in 670+ pages on Telugu wikipedia. I found the references call with P854, P1476 working properly (d:Q60165513 and corresponding Telugu Wikipedia page https://te.wikipedia.org/wiki/%E0%B0%87%E0%B0%82%E0%B0%95%E0%B1%8A%E0%B0%B2%E0%B1%8D%E0%B0%B2%E0%B1%81_%E0%B0%AE%E0%B0%82%E0%B0%A1%E0%B0%B2%E0%B0%82). So I updated almost all entries to use the working code. So while this is not a priority, let me know when the fix is ready. Arjunaraoc (talk) 10:53, 27 February 2024 (UTC)
- @Janhrach, Today I found another test case where the code works on both English and Telugu Wikipeidas
{{#invoke:wd|references|Q60165552|P2046}}
{{#invoke:wd|references|Q60165552|P1082|P585=2011}}
- Hope that helps.. Arjunaraoc (talk) 07:04, 28 February 2024 (UTC)
- @Arjunaraoc: I think I know what causes the issue, but I am sure I won't have time to fix the issue in the next two weeks, if not more. Be patient, please. Janhrach (talk) 18:22, 5 March 2024 (UTC)
- @Arjunaraoc: The fix is ready in the sandbox. If there are any problems, write to me here. Keep subscribed to this topic, so you will be notified if anybody raises an issue with this change. Thank you for reporting this bug.
- To everybody: In accordance with the policy, I will wait for several days until I update the main module. Please review my changes. Janhrach (talk) 16:11, 22 March 2024 (UTC)
- @Janhrach, Thanks for the fix. I tested it on Telugu wikipedia and found the the test cases working. Arjunaraoc (talk) 00:38, 23 March 2024 (UTC)
- Module updated. Janhrach (talk) 08:11, 1 April 2024 (UTC)
Getting Template:Update tracker working with qualifiers
I've been working on developing {{Update tracker}} and its child {{Update tracker item}}, templates for articles that use {{Wikidata}} that create a table for the talk page that lists which information needs to be updated (convenient for subjects like colleges that have a lot of data that needs updating every year).
I've gotten it mostly functional, except that I can't figure out how to get it to work with qualifiers (see the testcases). To function, it needs to call extra qualifier commands only when the |qualifier=
or |qualifier-value=
parameters are defined. I don't know of a way to conditionally add extra parameters, though, and keeping them blank causes an error.
Does that make sense? Anyone able to help? Sdkb talk 14:05, 10 April 2024 (UTC)
- @Sdkb: what do you mean by "there's an error" (in your testcases)? Is it an error thrown by the module or is it just the wrong data that you're getting? I suppose you tried
{{Wikidata |qualifier |single |{{{property|}}} |P585 |eid={{{entity|}}} |{{{qualifier|}}}={{{qualifier-value|}}} }}
- Did you leave out the vertical bars in the last two variables? I did a quick test in your code, previewing your test cases while editing, and the previous code did return some values and no obvious errors.
- I see another problem here / for Scripps College (Q10664609). This:
- {{Wikidata|qualifier|single|eid=Q10664609|P1128|P585|P518=Q5428874}}→ 2019 (current WD value is 2019)
- seems alright. However, in
- {{Wikidata|qualifier|single|eid=Q10664609|P1128|P585}} → 2019
- you'd expect the result to be 2020 (right?), but without any qualifiers the call returns the first of the two values of:
- {{Wikidata|qualifier|eid=Q10664609|P1128|P585}} → 2019; September 2020
- This would require a change on WD, another "applies to" or "rank: preferred", I believe.
- Although, this does seem to work, so
|qualifier=
should be given with no value when there are other nonempty qualifiers for the property:- {{Wikidata|qualifier|single|eid=Q10664609|P1128|P585|P518=}}→ September 2020
- Ponor (talk) 12:56, 10 April 2024 (UTC)
- Thanks for the reply, Ponyo! The error I'm referencing came from the fact that
|qualifier=
and|qualifier-value=
are optional, and the most simple use case (the first two test cases) leave them out. The previous code I tried removed the equal sign if they were not present, causing the template to evaluate as, where the pipe and blank parameter at the end causes it to become blank. Curiously, using your more basic method, the template evaluates as{{Wikidata |qualifier |single |{{{property|}}} |P585 |eid={{{entity|}}} | }}
, which I didn't even try because I presumed it would produce even more of an error, but it actually seems to cause it to work as intended. So that resolves my problem, although I don't trust that blank equals signs will always be okay for {{Wikidata}} as it evolves in the future, so if there's a more durable solution that'd be good to know about. Sdkb talk 19:45, 10 April 2024 (UTC){{Wikidata |qualifier |single |{{{property|}}} |P585 |eid={{{entity|}}} | = }}
- @Sdkb: glad it worked (wasnt' sure what exactly wasn't working). I don't think the blank equals sign will cause any problems; when there's nothing on its left, it should be discarded. If, however, you want to run some tests on your variables, you can try Someone more familiar with parsers and stuff might tell us if there's a better way; something tells me there has to be a hard-coded = sign, and not its replacements. Ponor (talk) 20:23, 10 April 2024 (UTC)
{{#if:…{{{qualifier|}}}…| {{Wikidata|…|{{{qualifier}}}={{{qualifier-value}}}}} | {{Wikidata|…}} }}
- The same test, using the nothing-on-the-left-of-equals-sign trick: Ponor (talk) 20:30, 10 April 2024 (UTC)
{{Wikidata |qualifier |single |{{{property|}}} |P585 |eid={{{entity|}}} |{{#if: some function of {{{qualifier|}}} and {{{qualifier-value}}} | {{{qualifier}}} | }} = {{{qualifier-value}}} }}
- @Sdkb: glad it worked (wasnt' sure what exactly wasn't working). I don't think the blank equals sign will cause any problems; when there's nothing on its left, it should be discarded. If, however, you want to run some tests on your variables, you can try
- Thanks for the reply, Ponyo! The error I'm referencing came from the fact that
Current population value
Wikidata:Q6045892 page contains population values between 2007-2022. However, when I type the wikidata:Property:P1082 value, the template calls the population value for 2007. What should I do to have it call up the population value for the most recent year?
{{wd|property|Q6045892|P1082}}
→ 2,010
Thank you. Sadrettin (talk) 10:48, 7 April 2024 (UTC)
- You have at least two options, @Sadrettin:
- {{wd|property|Q6045892|P1082|P585=2022}} >> 3,783
- Change the rank of the latest property on wikidata to preferred
- Ponor (talk) 13:08, 7 April 2024 (UTC)
{{#invoke:wd |property |P1082 |P585={{#invoke:Wikidata |getRawQualifier |qualifier=P585 |property=P1082 |sort=P585 |invert=true |limit=1 }} }}
- The above filters the multiple values of population (P1082 property) by the latest year (P585 qualifiers). If you add
|P459=Q6042918
after|P1082
, then the result is also filtered by determination method. Serresmap (talk) 18:55, 18 April 2024 (UTC)- @Serresmap: Thank you for your reply. When I wrote this code exactly, it didn't work. Could there be a problem? Could you please check again? --Sadrettin (talk) 08:41, 23 April 2024 (UTC)
Reference without title
If a reference doesn't have a title, the URL isn't shown and "Error: Unable to display the reference properly. See the documentation for details." is shown instead.
Would it be possible to not use {{Cite web}} if there's no title so that the URL is shown? The RedBurn (ϕ) 15:59, 11 May 2024 (UTC)
- This is an as-yet unaddressed problem with the module. See above. – Jonesey95 (talk) 03:47, 13 May 2024 (UTC)
- I plan to improve this error message; in the next ~3 months, if nothing wrong. But I agree with you it would probably be better if we let {{Cite web}} to report missing titles. I thinks so because if the reference rendering fails, the module will need to report two errors (one for {{Cite web}} missing/unknown param on Wikidata, and one error for {{Cite Q}}) – this would be probably too confusing for non-technical editors.
- Is anybody opposed to this change?
- —Janhrach (talk) 09:35, 25 May 2024 (UTC)
- I have made the said change to the sandbox. Here is a result sample:
- Original behavior, for comparison:
- – Janhrach (talk) 17:32, 7 June 2024 (UTC)
References
- ^ a b . Federal Statistical Office https://www.pxweb.bfs.admin.ch/pxweb/de/. Retrieved 15 June 2020.
{{cite web}}
: Missing or empty|title=
(help)
- @The RedBurn: Oops, I misread
to not use {{Cite web}}
in your comment as "to use {{Cite web}}". As for this, we could probably not; see this discussion. To quote an editor from the discussion:Titles are required so when
.{{cite web}}
emits a missing title error, that is a good thing, because someone can go to wikidata and fix it - As for the change I did (even though it's not what you proposed), what do you think of it?
- –Janhrach (talk) 06:40, 9 June 2024 (UTC)
- Your change is great, I actually thought {{Cite web}} was the culprit for hiding the URL when there's no title. The RedBurn (ϕ) 06:29, 10 June 2024 (UTC)
- Ok, I went ahead and updated the module. Janhrach (talk) 19:18, 10 June 2024 (UTC)
- @Janhrach: This is a huge improvement, thank you! Polygnotus (talk) 19:42, 15 June 2024 (UTC)
- Ok, I went ahead and updated the module. Janhrach (talk) 19:18, 10 June 2024 (UTC)
- Your change is great, I actually thought {{Cite web}} was the culprit for hiding the URL when there's no title. The RedBurn (ϕ) 06:29, 10 June 2024 (UTC)
- @The RedBurn: Oops, I misread
Wikipedia article link in plain form needed
While creating a variant template for use on Andhra Pradesh Village articles which uses{{ Infobox settlement}}, I needed wikipedia site link text in plain form so that I can change the visible text to remove suffixes in label names like district or mandal. I am unable to do that, as the current linked form gives a full fledged link with site link text and label as its visible text. I am unable to process such text as the response has pipe symbol in it. Is there any other way to get only Wikipedia article link text in plain form? Arjunaraoc (talk) 11:18, 21 June 2024 (UTC)
- I think this module could not output sitelinks (i.e. interwiki links hosted in Wikidata), linked or not. Could you clarify what exact arguments are you giving to the template call? Janhrach (talk) 13:08, 21 June 2024 (UTC)
- Template:Sitelink or parts of its code? Ponor (talk) 13:42, 21 June 2024 (UTC)
- @Ponor, Thanks for your help. It worked. I used the corresponding function from {{WikidataIB}} in my code. @Janhrach, Your response is correct. I wanted the sitelink in plain text form for the same language, instead of link form with label. Arjunaraoc (talk) 00:57, 22 June 2024 (UTC)
imported from Wikimedia project (P143) and Wikimedia import URL (P4656) in references
I propose to modify the module to ignore references containing these properties. This seems to be the correct way of handling them – these references should not contain any information useful for Wikipedia references. Any thoughts? Janhrach (talk) 15:17, 15 June 2024 (UTC)
- @Janhrach, Agree. Non Wiki references are only proper references. Arjunaraoc (talk) 11:13, 21 June 2024 (UTC)
- I have made the change to the sandbox. References containing inferred from (P3452) are also fully ignored. Janhrach (talk) 16:41, 21 June 2024 (UTC)
- Done: module updated. Janhrach (talk) 09:49, 23 June 2024 (UTC)
2 urls in source
There are 2 URLs in the source of the 2023 population data on this page: reference URL However, one of them appears on Wikipedia. Is it possible for 2 URLs to appear? Sadrettin (talk) 10:21, 24 June 2024 (UTC)
- No, it is not possible for a Wikipedia reference to have two URLs. I am not sure if the Wikidata reference you mentioned is valid; it is possible the reference should be split into two (the first reference would contain the first URL, and the second reference would contain the second URL) even if the other metadata are the same. Janhrach (talk) 07:36, 29 June 2024 (UTC)