Module talk:Wd
Add topic| Module:Wd is indefinitely protected from editing as it is a heavily used or highly visible module. Substantial changes should first be proposed and discussed here on this page. If the proposal is uncontroversial or has been discussed and is supported by consensus, editors may use {{edit template-protected}} to notify a template editor to make the requested edit.
|
| This is the talk page for discussing improvements to the Wd module. |
|
| Archives: 1Auto-archiving period: 3 months |
| This module does not require a rating on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | ||||||||
| ||||||||
| Use Wikipedia talk:Wikidata for general Wikidata support discussions. |
| Text or other creative content from this version of Module:Wd was copied or moved into Module:European and national party data/Wd with this edit on 22 May 2025. The former page's history now serves to provide attribution for that content in the latter page, and it must not be deleted as long as the latter page exists. |
Handling of Wikidata refs - empty titles and missing properties
[edit]We have a problem on cywiki where we have pages taking references from Wikidata. In 2023, @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
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. Dafyddt (talk) 22:42, 22 August 2025 (UTC)
- Regarding the specific errors you have mentioned, the problem was that Wikidata says that references citing online databases need to contain both stated in (P248) and a property of the 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.
- 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 to this module 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.
- |title= is no longer a mandatory param for {{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.
- —Janhrach (talk) 14:19, 26 August 2025 (UTC)
|title= is no longer a mandatory param for {{Cite web}}.
False. I don't know where you got that idea but you are mistook.|title=is, and likely will always be, required by{{cite web}}. If you have found some place where it is stated that|title=is not required, name that place so that it can be visited and fixed.- —Trappist the monk (talk) 14:40, 26 August 2025 (UTC)
- I meant that this module does not consider it mandatory. I wrote that
this means that missing titles in references do not cause errors in this module, but in the citation template[...]
Janhrach (talk) 14:43, 26 August 2025 (UTC)- Yes, I saw that, but your initial declaration that
|title=is not required by{{cite web}}is false. That declaration cannot be allowed to stand unchallenged. - —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
changes since I made the cywiki fix
could have been interpreted as including changes to CS1. Janhrach (talk) 14:59, 26 August 2025 (UTC)
- I should have made it clear that I refered to my changes to this module. I now see that
- Yes, I saw that, but your initial declaration that
- I meant that this module does not consider it mandatory. I wrote that
- Thanks for the reply! I will wait until your changes are made and may look at reverting our copy of Wd until that's done. Dafyddt (talk) 18:20, 26 August 2025 (UTC)
- @Dafyddt: I am sorry for leaving you wait for so long.
- I am currently working some changes to this module. I expect them to be ready soon. After that, I can re-implement the fallback on cywiki.
- There is also another option. With the changes I am working on, it will be possible to implement a partial fallback (i.e. one which mitigates those types of errors you referred to, but not all types of errors) solely by modifying the i18n submodule and creating a helper template. This will mean it will be much easier to update the module after it is changed on enwiki.
- If you are fine with the latter option, please let me know. In that case, I would like to implement the partial fallback on cywiki before deploying (on enwiki) the changes I am working on.
- —Janhrach (talk) 18:56, 2 August 2026 (UTC)
- Thanks for this! The second option sounds good. Please note that I may not be around for the next week or so to look at any changes. Dafyddt (talk) 19:36, 4 August 2026 (UTC)
Language label
[edit]Hello, could we have more customization on Language label? I mean the part when code constructs cite web etc. I see it uses aliasesP.language which means for Q1860 it picks "English". Maybe we could "tell" in i18n configuration to return value of ISO 639-1 or even P424 if that language has it, of course we always fallback to aliasesP.language. This issue comes from my local wiki, for example Module is returning label in cite web that is giving CS1 error unrecognized language. Zygimantus (talk) 13:00, 28 August 2025 (UTC)
- Possible? Certainly. But there other, possibly more important issues to fix first, and I do not want to devote too much time to this module. (Its creator has seemingly abandoned it.) A temporary solution would be to map aliasesP.language to an empty parameter, which would cause the aliasesP.language to be ignored. Janhrach (talk) 15:01, 5 September 2025 (UTC)
- Yeah, need to think about it. I am generally using practice for modules from enwiki like this: I treat them like upstream repo and I do not want to "fork more" than adding translations or other minor localizations. Code changes in local wiki will mean that we would deviate too much from original code and could cause many problems. Zygimantus (talk) 10:19, 10 September 2025 (UTC)
- Yes, but the temporary workaround I proposed would imply modifying Module:wd/i18n (which is expected to be modified on other wikis), not the main module. Also, thinking about this issue, I may look into it sooner than I originally planned, because the solution I have in mind could also fix other problem, if it works. But I am quite busy these days, so don't expect anything for at least a month. Janhrach (talk) 19:53, 17 September 2025 (UTC)
- Yeah, need to think about it. I am generally using practice for modules from enwiki like this: I treat them like upstream repo and I do not want to "fork more" than adding translations or other minor localizations. Code changes in local wiki will mean that we would deviate too much from original code and could cause many problems. Zygimantus (talk) 10:19, 10 September 2025 (UTC)
- Note for myself: Maybe modify
getReferenceDetails/getReferenceDetailto make usinggetValueoptional (replacable with alternatives). This could also be used to make handling of author params more flexible. Janhrach (talk) 19:17, 18 March 2026 (UTC) - @Zygimantus: I am currently working on an update that will enable implementing the behavior you want. Janhrach (talk) 18:43, 2 August 2026 (UTC)
Proposed update: customizable snak-->param rendering, related changes, misc. bugfixes
[edit]I would like to propose updating the main module from the sandbox. Both Module:Wd/sandbox and Module:Wd/sandbox/i18n have been modified. Feel free to ask questions or voice your concerns about the code. If there are no issues with it, I will deploy it in about a week.
Some testcases are available at User:Janhrach/sandbox3. A modified version of the updated code has already been deployed on Welsh Wikipedia.
The main change is that I introduced a mechanism (custom renderers) to customize how Wikidata values are rendered into arguments for citation templates, when citations are requested using the reference command. Custom renderers are defined in the /i18 submodule.
I ported three pre-existing behaviors to custom renderers: handling of external identifiers specific to {{Cite Q}}, and handling of language of work or name (P407) and external identifiers specific to {{Cite web}}. (In the non-sandbox version, the behaviors are hardcoded in getReference.) The description of these behaviors in the documentation still applies.
Due to this change, I was finally able to make the code cleaner by removing the additionalProcessedProperties variable and its associated code.
This change, however, does slightly modify the behavior of the module when rendering citations. Uncollapse for details:
Extended content | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Explanatory note: this module only outputs a citation error only if there was a {{Cite web}} error and a {{Cite Q}} error. For a demonstration of these differences, see User:Janhrach/sandbox3.
|
Apart from this, I made several minor bug fixes. I removed the use of templates from citation error messages (the transclusions worked only due to a coincidence), fixed faulty behavior of getValue when generating external links from certain external identifiers, and made it possible to set the priority of external-ID properties when rendering citations.
Missing citation properties
[edit]After a modified version of this module was deployed on cywiki, I discovered several Wikidata properties that can (mostly legitimately) appear in citations, yet are not known to this module.
The following mappings should be considered for addition to {{Cite web}}:
| property | template parameter | notes |
|---|---|---|
| editor (P98) | editor | This mapping would only be correct if there is only a single editor, as this module lacks support for splitting the Wikidata value into lastname–firstname pairs. |
| title of broader work (P6333) | website | |
| object named as (P1932) | quote | I am quite unsure here. |
| object stated in reference as (P5997) | ||
| work available at URL (P953) | url | |
| place of publication (P291) | location | or publication-place |
| subtitle (P1680) | title | When both subtitle and title are present, the resulting param should contain both the title and the subtitle, separated by a colon. |
| online access status (P6954) | url-access | Only some values are applicable. |
| file page (P7668) | url | Modify the url in reference URL (P854) or work available at URL (P953) by adding a page link. |
| filename in archive (P7793) | ? |
The following mappings should be considered for addition to {{Cite Q}}:
| property | template parameter | notes |
|---|---|---|
| applies to part (P518) | at | I am unsure how useful these values actually are. |
| volume (P478) | volume | |
| issue (P433) | issue | |
| edition number (P393) | edition | |
| part of (P361) | work | |
| author (P50) | author | Useful when citing an article in a book that is a collection of articles from various authors. |
| catalog code (P528) | id | I am unsure here; see below. |
The following properties are used in an undocumented citation type for citing archived documents:
- archives at (P485)
- catalog (P972)
- collection (P195)
- inventory number (P217)
- record number (P9994)
- folio(s) (P7416)
- registration district (P5564) – birth certificates and similar
- catalog code (P528)
The following properties should be ignored:
- file format (P2701)
- copyright license (P275) – usage is already discouraged
- supports qualifier (P10551)
- sourcing circumstances (P1480)
- document file on Wikimedia Commons (P996)
- has characteristic (P1552)
References containing the following properties should be ignored en bloc:
Filter/Match by reference
[edit]@Janhrach:: Thanks to your maintainance and recent updates to this module (and LGTM for sandbox).
Concerning the reference part, I would like to know if new script function(s) can be introduced so the match mechanism i.e. qualifierMatches can be applied to references. The only difference is to enum qualifiers in each reference for one claim.
By design and simplicity, this function could be something like |S248=https://example.com and |S854=Q111. But property aliases should be refracted if doing so.
I can write code changes and unit testcases, if in favour.
-- Tiger3018🗫 20:00, 2 September 2026 (UTC)
and LGTM for sandbox
– Thank you!- --
I would like to know if new script function(s) can be introduced
– On the non-technical level, feel free to write the code in the sandbox (when the sandbox is free again) and then submit an edit request.- Quite soon, I won't have much free time, so I unfortunately won't help you with writing the change.
- On the technical level, I am not the author of this module (nor its maintainer – I just watch the talk page and occassionally submit some changes) and I am not particularly familiar with all of it, so I can't tell if your suggestion is feasible.
- --
- Plus, to avoid misunderstandings, what do you mean by
qualifiers in each reference
? Do you mean snaks (property–value pairs) in a reference? (References don't contain qualifiers.) - —Janhrach (talk) 22:36, 2 September 2026 (UTC)