Module talk:Wd/Archive 1: Difference between revisions

Content deleted Content added
m Archiving 1 discussion(s) from Module talk:Wd) (bot
m Archiving 1 discussion(s) from Module talk:Wd) (bot
 
(7 intermediate revisions by the same user not shown)
Line 1,628:
 
:{{done}}: module updated. [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 09:50, 9 August 2024 (UTC)
 
== Another update ==
 
I once again altered the internal workings of the citation-rendering function in the sandbox, but also /i18n. Apart from a bugfix, in this update I tried to make much template- and param-specific behavior (previously hardcoded into the function) configurable in /i18n. Changes to /i18n are not backward-compatible. Some testcases are [[User:Janhrach/sandbox3|here]]. [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 18:40, 15 August 2024 (UTC)
 
:Thanks for the info &mdash;&nbsp;Martin <small>([[User:MSGJ|MSGJ]]&nbsp;·&nbsp;[[User talk:MSGJ|talk]])</small> 18:46, 15 August 2024 (UTC)
:{{done}}. [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 09:45, 26 August 2024 (UTC)
 
== Reference error message improvement ==
 
Finally, I improved the reference error messages. The code is in the sandbox. <code>/i18n</code> has also been modified. You can see the difference of the outputs [[User:Janhrach/sandbox3|here]]. I appreciate your feedback. [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 17:17, 27 August 2024 (UTC)
 
:{{done}}. [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 17:06, 2 September 2024 (UTC)
 
==Discussion at Template talk:Wikidata entity link § Not picking up mul labels from Wikidata entities==
[[File:Symbol watching blue lashes high contrast.svg|25px|link=|alt=]]&nbsp;You are invited to join the discussion at [[:Template talk:Wikidata entity link#Not picking up mul labels from Wikidata entities|Template talk:Wikidata entity link §&nbsp;Not picking up mul labels from Wikidata entities]]. [[User:Peaceray|Peaceray]] ([[User talk:Peaceray|talk]]) 01:10, 30 August 2024 (UTC)<!-- [[Template:Please see]] -->
 
:@[[User:Thayts|Thayts]], [[User:Janhrach|Janhrach]], et al.: What do you think? I was thinking to change [[Module:Wd#L-704]] from <syntaxhighlight lang=lua inline>label = mw.wikibase.getLabelByLang(id, self.langCode)</syntaxhighlight> to <syntaxhighlight lang=lua inline>label = mw.wikibase.getLabelByLang(id, self.langCode) or mw.wikibase.getLabel(id)</syntaxhighlight> (at least as an interim step). Is this the right thing to do or should we just remove <code>getLabelByLang()</code> all together? Currently it is also being (mis)used at [[Module:Wd#L-1294]] (with a hardcoded "en" for the language). Incidentally this module currently also uses <code>getDescription()</code> (and not <code>getDescriptionByLang()</code>) at [[Module:Wd#L-2523]]. It seems like the language usage (and their fallbacks) is not very unified here. Thank you, —[[User:Uzume|Uzume]] ([[User talk:Uzume|talk]]) 15:11, 30 August 2024 (UTC)
::I am not familiar with the Wikibase API. As for the status quo, it is not good and I already have had to fix a bug arising from a lack of label fallback. I don't know whether <code>getLabel</code> provides a good fallback mechanism, and I don't now have time to check the documentation. (Though maybe tomorrow I will have.)
::As for the {{tq|hardcoded "en"}}, it is required that the language is hardcoded, because the fetched label is used in a Geohack call. (However, I find it much preferable for this string to be fetched from a WD property and not from the label, because in the future, there will be no guarantee that the label will be accepted as a Geohack param.) [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 19:26, 1 September 2024 (UTC)
:::Update: I found the documentation is linked in the linked discussion, so I didn't have to search for it. It seems that it is desirable use getLabel only. There may arise some issues, but they would (in my speculation) only affect multilingual wikis. I will look into this possible bug later. [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 19:36, 1 September 2024 (UTC)
::::The hypothetical bug I have mentioned quite probably won't arise, so ignore this part of the comment. [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 17:53, 2 September 2024 (UTC)
 
===Proposed fix===
I made a fix to the sandbox. Sample output:
*English label:
**live module: {{#invoke:wd|label|Q46}}
**sandbox: {{#invoke:wd/sandbox|label|Q46}}
*Multilingual label:
**live module: {{#invoke:wd|label|Q42}}
**sandbox: {{#invoke:wd/sandbox|label|Q42}}
—[[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 16:36, 8 September 2024 (UTC)
 
:{{done}}. [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 18:29, 12 September 2024 (UTC)
 
== Property mapping and ignoring unrecognized parameters ==
 
I was brought here by the following citation errors which had ''too much information'':
{{collapse top}}
# [[d:Q625794#P569]] {{demo inline|<nowiki>{{wikidata|references|Q625794|P569}}</nowiki>}}
# [[d:Q625794#P570]] {{demo inline|<nowiki>{{wikidata|references|Q625794|P570}}</nowiki>}}
# [[d:Q625794#P20]] {{demo inline|<nowiki>{{wikidata|references|Q625794|P20}}</nowiki>}}
{{reftalk}}
{{collapse bottom}}
 
This is partially just an edit request to add some properties to the property mapping. {{Wikidata property link|P50}} and {{Wikidata property link|P291}} are common citation parameters that need to be added to the property mappings documented at {{slink|Template:Cite Q#Bibliographic parameters}} and {{slink|Template:Wikidata#References}}. I would further map {{Wikidata property link|P136}} to {{para|[[Help:Citation Style 1#Type|type]]}} and {{Wikidata property link|P1433}} to {{para|[[Help:Citation Style 1#Work and publisher|work]]}}.
 
However, I also think that this template/module refusing to produce any citation when there are unrecognized parameters is not ideal. I suggest that it should ignore unrecognized parameters without error messages in published articles, and only show a green warning message on previews.
 
{{small|Pinging {{u|Sdkb}} from their prior interest at {{slink|Module talk:Wd/Archive 1#References mapping}}.}}
 
[[User:Daask|Daask]] ([[User talk:Daask|talk]]) 08:03, 24 September 2024 (UTC)
 
:As for the errors containing {{tq|too much information}}, there were repeated complaints that the previous error message, which only indicated that an error had occured and linked to the documentation, was unclear. And I think too little information is a lesser problem than too much information, especially when there is no middle ground.
:As for the requested mappings, the usage of the mentioned properties in WD refs is not standard per [[wikidata:Help:Sources]].
:Ignoring unknown properties is problematic, because some properties may be deliberately left from the Cite web mapping to force the module to use Cite Q. This will be very important if new output templates are added, which is something I want to do eventually. [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 15:06, 27 September 2024 (UTC)
::{{re|Janhrach}} I apologize for my unclear comment. My concern was not that the error message was verbose, but rather that the error was caused by Wikidata having too much information about the citation. [[User:Daask|Daask]] ([[User talk:Daask|talk]]) 15:36, 27 September 2024 (UTC)
:::I have made some edits to the refs on Wikidata, and I will also modify the module later. [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 18:01, 27 September 2024 (UTC)
::::I have added support for {{prop|P291}} into the Cite web mapping. [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 13:20, 5 October 2024 (UTC)
:::::Why? When citing a web source, that source exists somewhere (or multiple somewheres) on the intarwebs but is not tied to a physical ___location. Just because a box can be filled, it does not mean that it should be filled.
:::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 13:44, 5 October 2024 (UTC)
::::::I added the property because the reference number two above displayed an error, as it contained the P291, which was not in the mapping. Is the usage of "Bloomington" in <code>publication-place</code> in the above reference incorrect? Should all instances of usage like this be removed from Wikidata? [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 13:58, 5 October 2024 (UTC)
:::::::Yes, incorrect. And because you are citing a website, the proper parameter is {{para|website}} not {{para|publisher}}. Wikidata should contain correct data. The problem there is that there are few if any standards so editors will fill-in the boxes because 'omg!-there-is-an-empty-box!-I-must-fill-it!' All that you can do is recognize that and choose {{tlx|cite web}} parameters appropriately.
:::::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 14:12, 5 October 2024 (UTC)
::::::::OK, I fixed the incorrect publication-place properties on WD and reverted my edits to this module. [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 14:24, 5 October 2024 (UTC)
::::::::May I ask why you think ''Kinsley Institute'' should be in <code>website</code>, not in <code>publisher</code>? [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 16:48, 5 October 2024 (UTC)
:::::::::Because we cite the {{em|work}} ({{para|website|Kinsey Institute}} in this case – note spelling) not the publisher (Indiana University).
:::::::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 18:38, 5 October 2024 (UTC)
::::::::::Is the Kinsey Institute a work? It quite seems to match the definition of "publisher" from the Cite web documentation ({{tq|The [[publisher]] is the ''company'', ''organization'' or other legal entity that publishes the work being cited.}}).
::::::::::We could say that we cite the institute's website, which has the same name as the institute. Is this what you mean?
::::::::::(Thanks for the spelling correction; I sometimes misread words and misspell them afterwards.)
::::::::::– [[User:Janhrach|Janhrach]] ([[User talk:Janhrach|talk]]) 12:55, 11 October 2024 (UTC)
 
== 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)
 
== Capitalisation ==
 
Hi,
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)
 
== Retrieving multiple wikidata property values in one call ==
 
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/>
 
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)
 
: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)
 
== Retrieve foreign Wikipedia page title ==
 
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]].
 
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)
 
:@[[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)
 
== "Multilanguage" not working ==
 
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".
 
Does anyone know how to fix or work around this issue? --[[User:Volvox|Volvox]] ([[User talk:Volvox|talk]]) 18:40, 9 April 2025 (UTC)
 
: {{Reply|Volvox}} It appears that <code>multilanguage</code> itself works, as in the following for the {{Prop|1549}} property of {{Q|55}}.
: <code><nowiki>{{wikidata|property|multilanguage|Q55|P1549}}</nowiki></code> (show one value)
:: {{wikidata|property|multilanguage|Q55|P1549}}
: <code><nowiki>{{wikidata|properties|multilanguage|Q55|P1549}}</nowiki></code> (show all values)
:: {{wikidata|properties|multilanguage|Q55|P1549}}
: I think the problem might be that {{para|P407|Q36846}} as shown in that example is looking for a {{Prop|407}} qualifier containing {{Q|36846}}, which is not how the {{Q|21044568}} datatype stores the language. You can see how it is stored by expanding the following.
{{Collapse|title=Output of <code><nowiki>{{examine|P1549|qid=Q55}}</nowiki></code>|content={{examine|P1549|qid=Q55}}}}
: Not sure if there is a way to fix this without an update to [[Module:wd]]. Perhaps someone having more experience with this module would know. -- [[User:Zyxw|Zyxw]] ([[User talk:Zyxw|talk]]) 03:14, 27 April 2025 (UTC)
 
:: Also, to show it does work when there are {{Prop|407}} qualifiers, see the following for the {{Prop|856}} property of {{Q|7565108}}.
:: <code><nowiki>{{wikidata|property|multilanguage|Q7565108|P856}}</nowiki></code>
::: {{wikidata|property|multilanguage|Q7565108|P856}}
:: <code><nowiki>{{wikidata|property|multilanguage|Q7565108|P856|P407=Q5287}}</nowiki></code> (in {{Q|5287}})
::: {{wikidata|property|multilanguage|Q7565108|P856|P407=Q5287}}
:: <code><nowiki>{{wikidata|property|multilanguage|Q7565108|P856|P407=Q150}}</nowiki></code> (in {{Q|150}})
::: {{wikidata|property|multilanguage|Q7565108|P856|P407=Q150}}
:: To see how this is stored, expand the following.
{{Collapse|title=Output of <code><nowiki>{{examine|P856|qid=Q7565108}}</nowiki></code>|content={{examine|P856|qid=Q7565108}}}}
:: -- [[User:Zyxw|Zyxw]] ([[User talk:Zyxw|talk]]) 03:58, 27 April 2025 (UTC)