Jump to content

Template talk:Convert/Archive June 2019

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia


Converting qualifier value from Wikidata

Hello. How do I convert a qualifier value from Wikidata? For example, what is the neatest way to convert length in this statement: has part(s) (P527)tidal barrage (Q7800783), with qualifier as length (P2043). Rehman 15:48, 30 April 2019 (UTC)

An example would help understanding the issue. What text in what article would convert be operating on? What would the desired result be? Bear in mind that the enwiki community is not happy with the idea of getting values from Wikidata. For example, see Module:Cycling race which has been effectively removed from enwiki and might be deleted following WT:WikiProject Cycling#Wikidata templates. Johnuniq (talk) 23:36, 30 April 2019 (UTC)
Johnuniq, no live examples yet, but looking here, I feel things like tide_barrage_height are better off as a qualifier to has part(s) (P527)tidal barrage (Q7800783) (compared to how it is now). But I'm not sure if that can be done with the current functions of Convert. Fyi, the Wikidata structure was defined by myself a few days ago, so there should not be any issue in changing it. And hence, if there are any better alternatives, it could also be done. Rehman 01:30, 1 May 2019 (UTC)
Template:Infobox power station includes these converts in some complex wikitext for data38:
{{Convert|input=P2048|qid={{{qid|}}}|ft|abbr=on|qual=Q7800783}}
{{Convert|input=P2048|qid={{{qid|}}}|m|abbr=on|qual=Q7800783}}
If more is wanted, I recommend asking Mike Peel who has done a lot of infobox with Wikidata work. Johnuniq (talk) 01:42, 1 May 2019 (UTC)

Thanks Johnuniq (sorry, I missed your reply earlier). Hi Mike Peel. May I ask for your thoughts on this please? Rehman 11:57, 20 May 2019 (UTC)

An example of what is wanted is needed: article; Wikidata item, properties; desired output. Johnuniq (talk) 00:30, 21 May 2019 (UTC)
Hey Johnuniq. As per my reply on May 1, there isn't a live example as yet. I need to know if this function could be imlemented so as to define the structure to store this data:
has part(s) (P527)tidal barrage (Q7800783), with qualifier length (P2043)
As you can see, the above structure is for barrage length, for tidal power stations that uses tidal barrages. I need a way to convert the qualifier value in the infobox.
The function (or future function) of being able to convert the qualifier values also has a number of more uses, such as converting has part(s) (P527)wind turbine (Q49833), with qualifier height (P2048), for wind farms.
--Rehman 12:22, 21 May 2019 (UTC)
@Rehman: Are you saying that an article would have an infobox, and some syntax in the infobox would determine whether the Wikidata item for the article exists, and if so, if it has a tidal barrage part with property length, and if so, the unit provided for that length would be converted to some other default unit? I think that's a bit much for convert. Perhaps there could be a wrapper which checks each step and calls convert if a suitable value and unit can be determined. Johnuniq (talk) 23:15, 21 May 2019 (UTC)
Johnuniq, yes. I agree it is rather complex, especially when looked in the above perspective. I will also see if anything can be done from Module:WikidataIB. Cheers, Rehman 06:39, 22 May 2019 (UTC)
@Johnuniq: Module:WikidataIB already has the ability to call {{cvt}} internally (lines 902-908, 1010-1015) on any output by specifying |conv=yes. Using the the Wikidata Sandbox (Q4115189):
  • {{#invoke:WikidataIB |getQualifierValue |fwd=ALL |osd=n |uabbr=y |conv=y |P527 |pval=Q7800783 |qual=P2043 |qid=Q4115189}}
It should handle ranges as well. I'm hoping that will do the trick. Cheers --RexxS (talk) 16:41, 22 May 2019 (UTC)
@RexxS: Thanks, that's stunning work. I'll know who to call next time. Johnuniq (talk) 04:07, 23 May 2019 (UTC)

Hello RexxS. Running {{#invoke:WikidataIB |getValueByQual |P2046 |qualID=P518 |qvalue=Q159719 |qid={{{qid|}}} |fetchwikidata={{{fetchwikidata|ALL}}}|suppressfields={{{suppressfields|none}}}|name=ps_site_area|onlysourced={{{onlysourced|no}}}|linked=false|unitabbr=true|convert=true|maxvals=1|sorted=true|noicon=true|sep="<br />"|{{{ps_site_area|}}}}} on Sagasolar Power Station, generates this error Error in convert: Unit name "ac" is not known. Is that a bug? Rehman 09:46, 8 June 2019 (UTC)

Hi Rehman The problem was that Wikidata stated that the unit symbol (P5061) for acre (Q81292) was "ac". Unfortunately, nobody uses that symbol and {{convert}} naturally doesn't recognise it:
I've fixed it for now by removing the Wikidata entry. So for Sagasolar Power Station (Q48727856):
  • {{#invoke:WikidataIB/sandbox |getValueByQual |P2046 |qualID=P518 |qvalue=Q159719 |qid=Q48727856 |fetchwikidata={{{fetchwikidata|ALL}}}|suppressfields={{{suppressfields|none}}}|name=ps_site_area|onlysourced={{{onlysourced|no}}}|linked=false|convert=true|maxvals=1|sorted=true|noicon=true|sep="<br />"|{{{ps_site_area|}}}}} → 45 acres (18 ha)
Note that if |convert=true is specified, it automatically sets unitabbr to true, so that it uses symbols preferentially where they exist. Also, if you set |maxvalues=1, then you're only getting one value returned, which makes |sorted=true and |sep="<br>" redundant. Cheers --RexxS (talk) 10:44, 8 June 2019 (UTC)
Thank you RexxS! Rehman 10:50, 8 June 2019 (UTC)

Template:Conv

While correcting an error, I noticed that it was due to a syntax problem in {{conv}} which I don't recall but which was discussed before. Template:Conv is a redirect to {{convert}} and was created in July 2014. It has 350 transclusions. If anyone feels like replacing these with convert, please go ahead! Saving three characters while introducing confusion (what is conv? is it different from convert?) does not seem useful to me. Johnuniq (talk) 08:16, 6 June 2019 (UTC)

Template:Conv actually dates back to 2007, but the earlier version was deleted. I agree that the present redirect has no real value. I'll see if I can make the changes using AWB. --RexxS (talk) 16:56, 6 June 2019 (UTC)
Great, I see you have finished already and {{conv}} is now not used in articles. That caused me to notice an RfD for Template:Con showing that {{con}} is also a redirect to convert with 63 transclusions. I wonder if TfD participants would support deletion of conv + con on the grounds that it is better to remove confusion and require convert given the tiny saving in typing. Johnuniq (talk) 00:49, 8 June 2019 (UTC)
I replaced con with convert so that is clean for the moment. Johnuniq (talk) 04:14, 8 June 2019 (UTC)
I suspect the folks over at WP:Redirects for discussion will prefer to keep redirects as they are cheap, but we could try it. Anyway, it's easy enough to clean up {{conv}} and {{con}} – in fact we might be able to persuade the folks at AWB to include those in their "general clean-up" in the same way as AWB changes {{cn}} to {{citation needed}}. That might be better than regularly explaining to folks what happened to their favourite short-cut if those were deleted. --RexxS (talk) 10:00, 8 June 2019 (UTC)
AWB general clean-up would be a good idea if achievable. OTOH maybe we could wait for a couple of months and see if much gets added. Articles using the templates are: conv + con (those links show nothing at the moment). Johnuniq (talk) 10:08, 8 June 2019 (UTC)
The editors at RfD have some strange fetish to keep almost absolutely any redirect that has ever been created. The editors at TfD seem to be much less sympathetic to bad redirects. Sadly, RfD handles this. While redirects might be cheap, they can, and do cause problems in actual module code, which can be (usually) fixed, but can require massive amount of work or a lot of extra lines, for very few, if any, benefit other than "redirects are cheap", which, is contradictory to the amount of work it takes to support them. --Gonnym (talk) 19:16, 13 June 2019 (UTC)
We could declare them both "Deprecated" and add {{Deprecated template}}. I think the code issues mentioned by Johnuniq and Gonnym are serious enough for this. When done formally here (by consensus), we can ask AWB people to replace instances in general cleanup, as with the {{cn}} example mentioned. -DePiep (talk) 10:12, 14 June 2019 (UTC)

Template:Infobox unit/doc

Editors who understand units might like to consider recent edits at Template:Infobox unit/doc. Please add any thoughts at Template talk:Infobox unit. Johnuniq (talk) 08:06, 22 June 2019 (UTC)