Module talk:Wd/Archive 1: Difference between revisions

Content deleted Content added
m Archiving 1 discussion(s) from Module talk:Wd) (bot
m Archiving 2 discussion(s) from Module talk:Wd) (bot
Line 889:
 
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 <code>|appendcategory=P3876</code>. It can be helpful for categorisation. <span style="font-family: 'Droid Sans', Calibri, Verdana, sans; color: silver;">— [[User:Toghrul R|Toghrul R]] <small>([[User talk:Toghrul R|t]])</small></span> 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
 
<nowiki>{{#invoke:wd|property|qualifier|qualifier</nowiki>'''|trimdate|'''<nowiki>normal+|Q55|P35|P580|P582|sep%q=_–_}}</nowiki> → Willem-Alexander of the Netherlands (2013) <span style="font-family: 'Droid Sans', Calibri, Verdana, sans; color: silver;">— [[User:Toghrul R|Toghrul R]] <small>([[User talk:Toghrul R|t]])</small></span> 14:47, 28 August 2022 (UTC)
:Why reinvent the wheel? Wrap it in {{tl|YEAR}}. – [[User:Jonesey95|Jonesey95]] ([[User talk:Jonesey95|talk]]) 12:47, 29 August 2022 (UTC)
::@[[User:Jonesey95|Jonesey95]] could you help wrapping it? I'm getting errors while doing it <span style="font-family: 'Droid Sans', Calibri, Verdana, sans; color: silver;">— [[User:Toghrul R|Toghrul R]] <small>([[User talk:Toghrul R|t]])</small></span> 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:
:::<code><nowiki>{{#invoke:wd|property|Q154952|P569}}</nowiki></code> &rarr; {{#invoke:wd|property|Q154952|P569}}
:::<code><nowiki>{{YEAR|{{#invoke:wd|property|Q154952|P569}}}}</nowiki></code> &rarr; {{YEAR|{{#invoke:wd|property|Q154952|P569}}}}
:::There may be a way to apply a format only to the second qualifier, but I do not know what it is. – [[User:Jonesey95|Jonesey95]] ([[User talk:Jonesey95|talk]]) 14:09, 31 August 2022 (UTC)
::One way to accomplish this is to modify the returned date using string manipulation:
:::<code><nowiki>{{#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}}</nowiki></code> → {{#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}}
::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 14:24, 31 August 2022 (UTC)
:::@[[User:Jonesey95|Jonesey95]] @[[User:Trappist the monk|Trappist the monk]] thanks for the help. It's a bit workaround, but works. However, when applying a format like <code><nowiki>|format=<ul>%p[%r] [<span style="font-size:90\%">(%q1–[%q2])</span>]</ul></nowiki></code> it doesn't work, sadly. <span style="font-family: 'Droid Sans', Calibri, Verdana, sans; color: silver;">— [[User:Toghrul R|Toghrul R]] <small>([[User talk:Toghrul R|t]])</small></span> 12:24, 1 September 2022 (UTC)
::::It seems to me wrong for you to include {{tag|ul}} tags in {{para|format}}. To me, that belongs outside of the <code><nowiki>{{#invoke:}}</nowiki></code>. But, since you did include {{tag|ul}} tags, why did you omit the {{tag|li}} tags?
::::
::::For open date ranges like that of your example, a simple tweak to the string replace works ({{tag|ul}} tags removed):
:::::<code><nowiki>{{#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}}</nowiki></code> → {{#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}}
::::
::::Because it is to be expected that not all dates will be open ended, you could write something like this (here the return from <code><nowiki>{{#invoke:wd}}</nowiki></code> is a mockup):
:::::<syntaxhighlight lang="moin">{{#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}}}}</syntaxhighlight>
:::::result when returned string has two dates:
::::::{{#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–30 April 2015)</span>|pattern=%(%d%d? [A-Za-z]+ (%d%d%d%d)%)|replace=(%1–)|plain=false}}}}
:::::result when returned string has one date:
::::::{{#if:{{#invoke:String|match|s=Willem-Alexander of the Netherlands <span style="font-size:90%">(30 April 2013–)</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–)</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}}}}
::::The above assumes that there will {{em|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 {{para|format}} always uses an unspaced endash.
::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 14:29, 1 September 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 <code>|preferred</code> - 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 {{U| Stephenamills}}, who raised the issue. [[User:ColinFine|ColinFine]] ([[User talk:ColinFine|talk]]) 17:34, 2 September 2022 (UTC)
 
:To re-mention what @[[User:ColinFine|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. [[User:Stephenamills|Stephenamills]] ([[User talk:Stephenamills|talk]]) 21:12, 2 September 2022 (UTC)