Module talk:Wd: Difference between revisions

Content deleted Content added
Volvox (talk | contribs)
(41 intermediate revisions by 8 users not shown)
Line 13:
| minthreadstoarchive = 1
}}
{{Copied |from=Module:Wd |from_oldid=1258646059 |to=Module:European and national party data/Wd |date=22 May 2025 |to_oldid= 1291650920}}
 
== Summing values across items ==
 
Hi,
 
I am already using this module to call values for specific items (in my case, political parties, such as their number of members).
 
Is there a way to sum these values for several items that are all instances of an item. For instance, the parties I deal with are all instances of "European political parties", and I am trying to sum their values to display the result (e.g., the sum total number of members of all European political parties).
 
Is these feasible one way or another?
 
Thanks! [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 07:47, 21 October 2024 (UTC)
 
:This is not possible with this module. [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 15:41, 25 October 2024 (UTC)
::Thanks for the reply! And too bad. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 07:48, 28 October 2024 (UTC)
 
== Support for P5017 ''last update'' ==
<!-- [[User:DoNotArchiveUntil]] 15:16, 18 August 2025 (UTC) -->{{User:ClueBot III/DoNotArchiveUntil|1755530186}}
{{ping|Thayts|Janhrach}} Hi. Is it possible to add support for [[:d:Property:P5017|P5017 ''last update'']] property? It seems to be perfectly valid citation/reference property for continuously updated sources to indicate last-update date of the version actually cited and it is being used all over WD this way, see [[d:Special:WhatLinksHere/Property:P5017|backlinks]] and [https://linkcount.toolforge.org/?project=www.wikidata.org&page=Property%3AP5017 stat]. Right now rendering attempt of a citation having this property filled here on enwiki leads to a nasty error output:
:<code><nowiki>{{#invoke:wd|reference|Q733993|P2046}}</nowiki></code> → <ref name="wikidata-8d9471ae1372c5ce8f22dc9a33852d9f3e9a6bc3-v18"><span style="color:#dd3333">
Line 61 ⟶ 46:
{{reflist-talk}}
 
=== CapitalisationProposed fix ===
 
I have implemented (in /sandbox) support for configuring the module (in /i18n) for using multiple Wikidata properties as sources for citation paramenters. These properties are ordered – each has it priority, which determines when to use the said property. I used this functionality to fix the above issue. (Both ''publication date'' and ''last update'' are used as a source for the {{mono|date}} citation argument, but ''last update'' has higher priority.) I also used this mechanism to reimplement the usage of ''subject named as'' as a fallback for {{mono|title}}. Your comments are welcome. [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 16:48, 6 July 2025 (UTC)
 
:{{done}}. Implemented. [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 19:55, 22 July 2025 (UTC)
 
== Intenationalisation of dates ==
 
Hi,
a Spanish Wikipedian noted that dates in Spanish use the article "de". For instance, "10 november 1992" will be "10 '''de''' noviembre '''de''' 1992". Is there a way to account for this in the i18n code? [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 08:31, 5 June 2025 (UTC)
Is there a way to change the capitalisation of results? I am trying to call Wikidata to provide the description on Wikipedia articles but Wikidata says descriptions should not be capitalised, while Wikipedia English needs capitalisation. Is there a way to capitalise the first letter of the resulting string?
Thanks! [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 14:16, 9 December 2024 (UTC)
:{{slink|Help:Magic_words|ucfirst}}
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 14:30, 9 December 2024 (UTC)
::I am so bookmarking this. Thanks a lot! [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 15:22, 9 December 2024 (UTC)
 
:Actually, secondary question: is there a way to account for the plural form for currencies? Like "1 euro, 2 euros". [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 08:33, 5 June 2025 (UTC)
== Retrieving multiple wikidata property values in one call ==
::Unfortunately, both of these behaviors are hardcoded and are not (yet) configurable. [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 18:19, 7 June 2025 (UTC)
:::Thanks! [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 07:4720, 219 OctoberJune 20242025 (UTC)
:::Actually @[[User:Janhrach|Janhrach]], even though this is not currently feasible in Wd, how would you go about adding an "s" to the currency in a forked module? Assuming the currency value is always plural. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 07:24, 9 June 2025 (UTC)
:This is:::Has notAhecht possiblealready withanswered thisyour module.questtion? [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 1518:4117, 2512 OctoberJune 20242025 (UTC)
::Thanks:::Yes, forhe thehas, reply!thanks Andfor tooasking bad.@[[User:Janhrach|Janhrach]] [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 0720:4818, 2812 OctoberJune 20242025 (UTC)
:::::@[[User:Janhrach|Janhrach]] Maybe the changes made to [[Module:European and national party data/Wd]] can be useful to [[Module:Wd]]? [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 20:19, 12 June 2025 (UTC)
::::::Maybe. I have some work to do in the sandbox, which I want to finish before I start doing anything else related to this module. [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 13:36, 15 June 2025 (UTC)
:@[[User:Julius Schwarz|Julius Schwarz]] For the first case, are you trying to output the date in that format? If so, as long as the input date is the raw "1992-11-10" or in English, you could set up the code to run the date through something like <source lang=lua inline>lang:formatDate( i18n.fullDate, '1992-11-10')</source> and then, for Spanish, set <code>i18n.fullDate = 'n \\d\\e F \\d\\e Y'</code>. <span class="nowrap">--[[User:Ahecht|Ahecht]] ([[User talk:Ahecht|<b style="color:#FFF;background:#04A;display:inline-block;padding:1px;vertical-align:middle;font:bold 50%/1 sans-serif;text-align:center">TALK<br />PAGE</b>]])</span> 14:14, 9 June 2025 (UTC)
::Thanks a lot, @[[User:Ahecht|Ahecht]]. In the meantime, a Spanish contributor, @[[User:Leoncastro|Leoncastro]], helped out [https://en.wikipedia.org/w/index.php?title=Module:European_and_national_party_data/Wd&action=history here] and [https://en.wikipedia.org/w/index.php?title=Module:European_and_national_party_data/Wd/i18n&action=history here], in case you want to have a look! [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 14:37, 9 June 2025 (UTC)
::I:PS: am@[[User:Ahecht|Ahecht]], sowould bookmarkingyou this.know Thankshow to hard-code a lot!plural for the currency, by any chance? [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 1518:2234, 9 DecemberJune 20242025 (UTC)
::::@[[User:Julius Schwarz|Julius Schwarz]] If you modify your module to do two calls to [[Module:Wd]], one with the <code>raw</code> flag and one with the <code>data</code> flag, you can then do something like <source lang=lua inline>if amount > 1 then unit = unit .. 's' end</source> (and you would then have an override for languages such as Swedish where the plural of 'krone' is 'kroner'). I suppose you could also I did update [[Module:European and national party data/sandbox]] so that you can request the unit from <code>allpp_get_data()</code> or <code>xlate_wikidata()</code>. <span class="nowrap">--[[User:Ahecht|Ahecht]] ([[User talk:Ahecht|<b style="color:#FFF;background:#04A;display:inline-block;padding:1px;vertical-align:middle;font:bold 50%/1 sans-serif;text-align:center">TALK<br />PAGE</b>]])</span> 20:53, 9 June 2025 (UTC)
:::::Thanks @[[User:Ahecht|Ahecht]]. [https://en.wikipedia.org/w/index.php?title=Module%3AEuropean_and_national_party_data%2Fsandbox&diff=1294906871&oldid=1294792449 First time] not lucky :D Did I get your <code>unit=yes/no</code> right? [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 14:28, 10 June 2025 (UTC)
::::::@[[User:Julius Schwarz|Julius Schwarz]] I don't have time to debug your code, but I think you need to specify <code>raw=yes</code> to get it without the unit. When I uncomment the 2nd-to-last line of the module (the one that exports xlate_wikidata) and run <source lang=lua inline>=p.xlate_wikidata('property', 'Q950179', 'P12919', '', '', '', '', '', '', 'unit=yes')</source> in the console it returns <code>euro</code> and when I do <source lang=lua inline>=mw.getContentLanguage():formatNum(tonumber(p.xlate_wikidata('property', 'Q950179', 'P12919', '', '', '', '', 'raw=yes', '', '')))</source> it returns <code>171,460.56</code>. <span class="nowrap">--[[User:Ahecht|Ahecht]] ([[User talk:Ahecht|<b style="color:#FFF;background:#04A;display:inline-block;padding:1px;vertical-align:middle;font:bold 50%/1 sans-serif;text-align:center">TALK<br />PAGE</b>]])</span> 15:10, 10 June 2025 (UTC)
:::::::Thanks @[[User:Ahecht|Ahecht]]. I will check it out and try and fix it. I guess what I was trying to say is that I am not really sure how the "unit" bit works. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 20:18, 10 June 2025 (UTC)
:::::::@[[User:Ahecht|Ahecht]] second time almost lucky! That did help, but somehow we lose the thousand delimiter in the process :S [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 09:31, 11 June 2025 (UTC)
::::::::@[[User:Julius Schwarz|Julius Schwarz]] The <code>mw.getContentLanguage():formatNum(tonumber())</code> part above around the raw currency amount should fix that. <span class="nowrap">--[[User:Ahecht|Ahecht]] ([[User talk:Ahecht|<b style="color:#FFF;background:#04A;display:inline-block;padding:1px;vertical-align:middle;font:bold 50%/1 sans-serif;text-align:center">TALK<br />PAGE</b>]])</span> 13:15, 11 June 2025 (UTC)
Thanks:::::::::@[[User:Ahecht|Ahecht]] took a bit of tinkering but I think it is working, thanks a lot! [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 1413:1626, 911 DecemberJune 20242025 (UTC)
 
== Seeking most recent value ==
I am trying to retrieve multiple property values in one call but it is ignoring the other properties I give so I only ever get one property value. I must not be giving things in the correct order but none of the examples help me. For example, given a mountain name, I want to retrieve the elevation, prominence, mountain range, coordinates and the first ascent significant event.
So given this:
P4552 = mountain range
P2044 = elevation
P2660 = prominence
P625 = coordinates
P793 = significant event; Q1194369 = first ascent; P585 = point in time
I can get all the values if I code one call per property but how do I code it so I can get all the properties in one call?
The documentation for the "property" command says "Returns the requested property – or list of properties". Yet, I see no example or syntax of how to specify this list of properties.<br/>
 
When seeking a value such as a population via this template, Wikidata will often have multiple values with different {{wpl|585}} qualifiers. Sometimes the most recent one will be given a preferred rank but sometimes not. Is there any way to ask it to retrieve the most recent one? I don't think (?) the future/current/former flags can work for this, both because they rely only on {{wpl|580}}/{{wpl|582}}, not on {{wpl|585}}, and because even if they did, the most recent value would just be one instance of a former value and wouldn't be prioritized if the other happened to be listed first.
If I code the following, I only get the value of property P2044.<br/>
<nowiki>{{#invoke:wd|property|qualifier|page=Mount Robson|P2044|P2660|P4552|P625|P793|Q1194369|P585}}</nowiki>
[[User:RedWolf|RedWolf]] ([[User talk:RedWolf|talk]]) 19:32, 23 January 2025 (UTC)
 
I [[Module_talk:Wd/Archive_1#Seeking_newest_value,_rather_than_current_value|asked about this a few years ago]] and @[[User:Thayts|Thayts]] mentioned something in the works; has there been progress on it? <span style="border:3px outset;border-radius:8pt 0;padding:1px 5px;background:linear-gradient(6rad,#86c,#2b9)">[[User:Sdkb|<span style="color:#FFF;text-decoration:inherit;font:1em Lucida Sans">Sdkb</span>]]</span> <sup>[[User talk:Sdkb|'''talk''']]</sup> 22:37, 28 July 2025 (UTC)
:Have you tried using <code>properties</code> instead of <code>property</code>? [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 20:45, 23 January 2025 (UTC)
::Yes, first thing I tried but it's not for specifying multiple properties to return but rather for returning multiple values of the given property. [[User:RedWolf|RedWolf]] ([[User talk:RedWolf|talk]]) 22:04, 23 January 2025 (UTC)
:::It seems that this module does not support this functionality – the diagram at [[Module:Wd#Positional arguments]] apparently says only one <code>property_id</code> argument is supported. The description you quoted from the documentation probably refers to using <code>properties</code>. [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 13:29, 24 January 2025 (UTC)
 
== Specifying URL alive/dead status ==
== Retrieve foreign Wikipedia page title ==
 
Citations with archive URLs are displayed differently when the URL is specified as alive via {{para|url-status|live}} vs. when it's specified as dead or not specified (see first paragraph of [[Help_talk:Citation_Style_1#Treating_all_references_as_dead_by_default|here]]). Would it be possible to create a way for this template to likewise specify URL status? <span style="border:3px outset;border-radius:8pt 0;padding:1px 5px;background:linear-gradient(6rad,#86c,#2b9)">[[User:Sdkb|<span style="color:#FFF;text-decoration:inherit;font:1em Lucida Sans">Sdkb</span>]]</span> <sup>[[User talk:Sdkb|'''talk''']]</sup> 00:22, 29 July 2025 (UTC)
I want to use the template to retrieve the foreign Wikipedia title of an article, given the local title. As an example: I have 'Eiffel Tower', and I want to retrieve the name '''Eiffelturm''' from the name of the corresponding page on de-wiki, according to the information available at the bottom of page [[d:Q243#sitelinks-wikipedia|Q243]].
 
:Yes, maybe sometime in the future, but it is not supported right now. [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 16:20, 7 August 2025 (UTC)
I am new to the wikidata template, and I have discovered how to do some of what I need to do, for example: I see that <code><nowiki>{{wikidata|label|raw|page=Eiffel Tower}}</nowiki></code> gives me back {{kbd|{{wikidata|label|raw|page=Eiffel Tower}}}}. I see how to get various properties, like where it is located:
* <code><nowiki>{{wikidata|property|page=Eiffel Tower|P17}}</nowiki></code> ⟶ {{wikidata|property|page=Eiffel Tower|P17}}
But I don't see what the property name or id of the foreign wikipedia property is, so I can retrieve the German page title. What I want logically, I think, is something like this, maybe:
* <code><nowiki>{{wikidata|qualifier|page=Eiffel Tower|P99999|de}}</nowiki></code> ⟶ Eiffelturm
where {{kbd|P999999}} is an imaginary property number for 'Wikipedia language link' and {{kbd|de}} is the language code for the foreign Wikipedia containing the title I am looking for. But I can't find a property value for Wikipedia site link. There must be a property or something for the wikipedia names, but I can't find it. Maybe it's not a property, but something else? [[User:Mathglot|Mathglot]] ([[User talk:Mathglot|talk]]) 02:11, 10 March 2025 (UTC)
 
== Handling of Wikidata refs - empty titles and missing properties ==
:@[[User:Mathglot|Mathglot]]: [[Template:Sitelink]] or the code within. [[User:Ponor|Ponor]] ([[User talk:Ponor|talk]]) 05:42, 10 March 2025 (UTC)
:: Oh, I forgot about that one, and I even had a hand in writing some of the documentation for it. Thanks! [[User:Mathglot|Mathglot]] ([[User talk:Mathglot|talk]]) 09:53, 10 March 2025 (UTC)
 
We have a problem on cywiki where we have pages taking references from Wikidata. In 2023, @[[User:Janhrach|Janhrach]] very kindly forked the code and applied some additional handling to prevent visible errors. Time moves on and the code in the module has been refactored. I applied this version but it shows errors again - see https://cy.wikipedia.org/wiki/8_Mile
== "Multilanguage" not working ==
 
I would like to keep the module up-to-date, so I had various attempts to re-apply the previous fix - but as variables have changed, it's quite tricky. There are also some more significant errors regarding those properties such as Rotten Tomatoes and Meta Critic, which is potentially easier to fix. Is there a possibility of handling this in an easier way? I would prefer not to put in special handling just for us as it limits future updates, but it would be good to know what's feasible. I could revert my changes to what was working, but I suspect that I would also need to revert other updates to Citation/CS1 modules as well. Thank you. [[User:Dafyddt|Dafyddt]] ([[User talk:Dafyddt|talk]]) 22:42, 22 August 2025 (UTC)
I noticed that the example <code><nowiki>{{wikidata|property|multilanguage|Q55|P1549|P407=Q36846}}</nowiki></code> on [[Template:Wikidata]] no longer works – the output is empty. This seems to happen generally when trying to retrieve language-specific values of P1549 using "multilanguage".
 
:Regarding the specific errors you have mentioned, the problem was that Wikidata says that references citing online databases need to contain both {{prop|248}} and a property of the {{mono|External identifier}} data type, while the references causing errors contained only the latter. This may seem like a minor technicality, but database references are handled by an ugly hack in the module, and I do not want to make this hacky code more complicated to support references like this. I plan to fix this issue by creating a separate template for citing database references; this will hopefully also eliminate cryptic error messages like these.
Does anyone know how to fix or work around this issue? --[[User:Volvox|Volvox]] ([[User talk:Volvox|talk]]) 18:40, 9 April 2025 (UTC)
:As for re-introducing the cywiki fix, the old code is probably of little use, because the code has changed quite a lot. If it is really needed, I can try to reimplement it, but I would strongly prefer if you waited until I make the fix I have mentioned in the previous paragraph.
:Also, regarding the changes <u>to this module</u> since I made the cywiki fix, there were two of them that are especially relevant here:
:* I added verbose error messages. They should mostly be comprehensible after reading the documentation. I agree though that the errors you have mentioned are hard to understand; I will fix that.
:* {{mono|1={{!}}title=}} is no longer a mandatory param for {{tl|Cite web}}. In practice, this means that missing titles in references do not cause errors in this module, but in the citation template, like you see in the article you have linked. This hopefully made the errors more understandable. When I create the database-citation template, many of these missing-title errors could be eliminated.
:—[[User:RedWolfJanhrach|RedWolfJanhrach]] ([[User talk:RedWolfJanhrach|talk]]) 1914:3219, 2326 JanuaryAugust 2025 (UTC)
::{{tq|{{mono|1={{!}}title=}} is no longer a mandatory param for {{tl|Cite web}}.}} False. I don't know where you got that idea but you are mistook. {{para|title}} {{em|is}}, and likely will always be, required by {{tld|cite web}}. If you have found some place where it is stated that {{para|title}} is {{em|not}} required, name that place so that it can be visited and fixed.
::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 14:3040, 926 DecemberAugust 20242025 (UTC)
:::I meant that ''this module'' does not consider it mandatory. I wrote that {{tq|this means that missing titles in references do not cause errors in this module, but in the citation template[...]}} [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 14:43, 26 August 2025 (UTC)
::::Yes, I saw that, but your initial declaration that {{para|title}} is not required by {{tlx|cite web}} is false. That declaration cannot be allowed to stand unchallenged.
::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 14:52, 26 August 2025 (UTC)
:::::I should have made it clear that I refered to ''my'' changes to ''this'' module. I now see that {{tq|changes since I made the cywiki fix}} could have been interpreted as including changes to CS1. [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 14:59, 26 August 2025 (UTC)