Module talk:Wd#Titles from other wikipedias

{{Permanently protected}}

{{talk header}}

{{WikiProject banner shell|

{{WikiProject Wikidata}}

}}

{{tmbox|text=Use Wikipedia talk:Wikidata for general Wikidata support discussions.}}

{{Lua sidebar|template=Wikidata|module=Wd}}

{{User:MiszaBot/config

| algo = old(90d)

| archive = Module talk:Wd/Archive %(counter)d

| counter = 1

| archiveheader = {{Automatic archive navigator}}

| minthreadstoarchive = 1

}}

{{Copied |from=Module:Wd |from_oldid=1258646059 |to=Module:European and national party data/Wd |date=22 May 2025 |to_oldid= 1291650920}}

Support for P5017 ''last update''

{{User:ClueBot III/DoNotArchiveUntil|1755530186}}

{{ping|Thayts|Janhrach}} Hi. Is it possible to add support for 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 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:

:{{#invoke:wd|reference|Q733993|P2046}}

Error: Unable to display the reference from Wikidata properly. Technical details:

  • Reason for the failure of {{tl|Cite web}}: The Wikidata reference contains the property {{property|P5017}}, which is not assigned to any parameter of this template.
  • Reason for the failure of {{tl|Cite Q}}: The Wikidata reference contains the property {{property|P5017}}, which is not assigned to any parameter of this template.

See the documentation for further details.

Category:Module:Wd reference errors

On other wikis such citations are citable at least, even if the last update value is not used. E.g.: [https://cs.wikipedia.org/wiki/Special:ExpandTemplates?wpInput=%7B%7B%23invoke%3AWikidata%7CformatStatements%7Cid%3DQ733993%7Cproperty%3DP2046%7Crank%3Dbest%7Climit%3D1%7Cshowqualifier%3Dp585%7Csort%3Dp585%7Cinvert%3Dtrue%7Cshowsource%3Dtrue%7D%7D].

If there really is a good reason to keep current strict semantics (i.e. to fail with error on any unknown/unmapped citation property instead of just ignoring it or maybe including some hidden note and a monitoring cat. assignment), maybe an explicit whitelist of "tolerated" though unused citation properties would be useful. It doesn't make much sense to be completely unable to render citations that are valid on WD itself and renderable on other projects. And another negative side effect of this approach is that if anyone adds such an unsupported property on WD side later, unaware of the limitations of this module, it will introduce an unintentional error here, that is out of control of the original author, who inserted a (then working) citation. That's definitely not nice behavior. --Teslaton (talk) 18:41, 24 November 2024 (UTC)

:Hello, sorry for the late reply.

:As for adding P5017, it is of course possible. Which Cite-web parameter should it be mapped to? Should it override publication date?

:Note that :wikidata:Help:sources does not mention this property at all, which, in itself, is not a problem. I am mentioning the Wikidata page because it is worth noting that references on Wikidata aren't really standardized. That page is, at least in my knowledge, the only one to say something about formatting references, yet it seems to be far from complete.

:Unfortunately, there is no simple way to fix the citation-rendering function to just ignore unknown properties – outputting an error on failure is an inherent property of the (very simple) algorithm, as long as we want it to always produce understandable results. For example, an exteral id property (together with a "stated in" property) is sufficient to generate a Cite-web citation. However, this combination is also sufficient to create a Cite-Q citation. How should the module decide which citation template to use?

:The original algorithm solved this problem by not using a citation template if the Wikidata reference contained any properties not mapped to its parameters. If neither of the templates could be used, a fallback citation was generated. However, this fallback was removed (almost two years ago), because it was dissimilar to existing citation styles and sometime quite human-unfriendly.

:This is a very conservative solution – it rarely produces gibberish citations (e.g. leaving out information essential to the reference), but always fails on atypical Wikidata citations.

:If you have ideas for a better algorithm, please share your ideas.

:PS: After finishing writing this reply, I got an idea: maybe a good solution would be to ignore properties that are unknown to both of the citation templates (and issue an invisible error when encountering them). I will think about it.

:– Janhrach (talk) 19:08, 5 December 2024 (UTC)

::Test: {{#invoke:wd/sandbox|reference|Q733993|P2046}} Janhrach (talk) 20:27, 20 December 2024 (UTC)

{{hidden ping|Thayts|Janhrach}} Gentlemen, please, any thought on this? --Teslaton (talk) 13:16, 2 December 2024 (UTC)

{{reflist-talk}}

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.

If I code the following, I only get the value of property P2044.

{{#invoke:wd|property|qualifier|page=Mount Robson|P2044|P2660|P4552|P625|P793|Q1194369|P585}}

RedWolf (talk) 19:32, 23 January 2025 (UTC)

:Have you tried using properties instead of property? 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. 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 property_id argument is supported. The description you quoted from the documentation probably refers to using properties. 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 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 {{wikidata|label|raw|page=Eiffel Tower}} gives me back {{kbd|{{wikidata|label|raw|page=Eiffel Tower}}}}. I see how to get various properties, like where it is located:

  • {{wikidata|property|page=Eiffel Tower|P17}} ⟶ {{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:

  • {{wikidata|qualifier|page=Eiffel Tower|P99999|de}} ⟶ 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? Mathglot (talk) 02:11, 10 March 2025 (UTC)

:@Mathglot: Template:Sitelink or the code within. 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! Mathglot (talk) 09:53, 10 March 2025 (UTC)

"Multilanguage" not working

I noticed that the example {{wikidata|property|multilanguage|Q55|P1549|P407=Q36846}} 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? --Volvox (talk) 18:40, 9 April 2025 (UTC)

: {{Reply|Volvox}} It appears that multilanguage itself works, as in the following for the {{Prop|1549}} property of {{Q|55}}.

: {{wikidata|property|multilanguage|Q55|P1549}} (show one value)

:: {{wikidata|property|multilanguage|Q55|P1549}}

: {{wikidata|properties|multilanguage|Q55|P1549}} (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 {{examine|P1549|qid=Q55}}|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. -- 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}}.

:: {{wikidata|property|multilanguage|Q7565108|P856}}

::: {{wikidata|property|multilanguage|Q7565108|P856}}

:: {{wikidata|property|multilanguage|Q7565108|P856|P407=Q5287}} (in {{Q|5287}})

::: {{wikidata|property|multilanguage|Q7565108|P856|P407=Q5287}}

:: {{wikidata|property|multilanguage|Q7565108|P856|P407=Q150}} (in {{Q|150}})

::: {{wikidata|property|multilanguage|Q7565108|P856|P407=Q150}}

:: To see how this is stored, expand the following.

{{Collapse|title=Output of {{examine|P856|qid=Q7565108}}|content={{examine|P856|qid=Q7565108}}}}

:: -- Zyxw (talk) 03:58, 27 April 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? Julius Schwarz (talk) 08:31, 5 June 2025 (UTC)

:Actually, secondary question: is there a way to account for the plural form for currencies? Like "1 euro, 2 euros". Julius Schwarz (talk) 08:33, 5 June 2025 (UTC)

::Unfortunately, both of these behaviors are hardcoded and are not (yet) configurable. Janhrach (talk) 18:19, 7 June 2025 (UTC)

:::Thanks! Julius Schwarz (talk) 07:20, 9 June 2025 (UTC)

:::Actually @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. Julius Schwarz (talk) 07:24, 9 June 2025 (UTC)

::::Has Ahecht already answered your questtion? Janhrach (talk) 18:17, 12 June 2025 (UTC)

:::::Yes, he has, thanks for asking @Janhrach Julius Schwarz (talk) 20:18, 12 June 2025 (UTC)

:::::@Janhrach Maybe the changes made to Module:European and national party data/Wd can be useful to Module:Wd? 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. Janhrach (talk) 13:36, 15 June 2025 (UTC)

:@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 lang:formatDate( i18n.fullDate, '1992-11-10') and then, for Spanish, set i18n.fullDate = 'n \\d\\e F \\d\\e Y'. --Ahecht (TALK
PAGE
)
14:14, 9 June 2025 (UTC)

::Thanks a lot, @Ahecht. In the meantime, a Spanish contributor, @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! Julius Schwarz (talk) 14:37, 9 June 2025 (UTC)

:::PS: @Ahecht, would you know how to hard-code a plural for the currency, by any chance? Julius Schwarz (talk) 18:34, 9 June 2025 (UTC)

::::@Julius Schwarz If you modify your module to do two calls to Module:Wd, one with the raw flag and one with the data flag, you can then do something like if amount > 1 then unit = unit .. 's' end (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 allpp_get_data() or xlate_wikidata(). --Ahecht (TALK
PAGE
)
20:53, 9 June 2025 (UTC)

:::::Thanks @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 unit=yes/no right? Julius Schwarz (talk) 14:28, 10 June 2025 (UTC)

::::::@Julius Schwarz I don't have time to debug your code, but I think you need to specify raw=yes 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 =p.xlate_wikidata('property', 'Q950179', 'P12919', , , , , , , 'unit=yes') in the console it returns euro and when I do =mw.getContentLanguage():formatNum(tonumber(p.xlate_wikidata('property', 'Q950179', 'P12919', , , , , 'raw=yes', , ))) it returns 171,460.56. --Ahecht (TALK
PAGE
)
15:10, 10 June 2025 (UTC)

:::::::Thanks @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. Julius Schwarz (talk) 20:18, 10 June 2025 (UTC)

:::::::@Ahecht second time almost lucky! That did help, but somehow we lose the thousand delimiter in the process :S Julius Schwarz (talk) 09:31, 11 June 2025 (UTC)

::::::::@Julius Schwarz The mw.getContentLanguage():formatNum(tonumber()) part above around the raw currency amount should fix that. --Ahecht (TALK
PAGE
)
13:15, 11 June 2025 (UTC)

:::::::::@Ahecht took a bit of tinkering but I think it is working, thanks a lot! Julius Schwarz (talk) 13:26, 11 June 2025 (UTC)