Template talk:Convert

(Redirected from Help talk:Convert messages)
Latest comment: 3 days ago by NebY in topic English variety

... in conception
... and in reality

1 g of something from each m²

edit

In dust devil I've found this statement: 1 gram of dust per second from each square metre (10 lb/s from each acre). Is there a workaround to use {{convert}} in this case?-- Carnby (talk) 13:44, 11 April 2026 (UTC)Reply

How about {{convert|1|g/s/m2|lb/s/acre}} : 1 gram per second per square metre (8.9 lb/s/acre) -- WOSlinker (talk) 17:30, 11 April 2026 (UTC)Reply
If you want to keep the verbose version of the SI value (probably a good idea in this case), you could use "|disp=out |abbr=off": 1 gram of dust per second from each square metre (8.9 pounds per second per acre). Indefatigable (talk) 17:50, 11 April 2026 (UTC)Reply
{{convert|1|g/s/m2|lb/s/acre|abbr=off}} displays as: 1 gram per second per square metre (8.9 pounds per second per acre)  Stepho  talk  05:36, 12 April 2026 (UTC)Reply
I wrote this: {{convert|1|g/s/m2|lb/s/acre|-1|abbr=off}} yielding "Field experiments indicate that a dust devil can lift 1 gram per second per square metre (10 pounds per second per acre) of dust on the ground over which it passes." Does it soundlook good?-- Carnby (talk) 13:09, 13 April 2026 (UTC)Reply
Looks good. Although I think the correct grammar is "off the ground".  Stepho  talk  21:52, 13 April 2026 (UTC)Reply
Right, thank you.-- Carnby (talk) 04:01, 14 April 2026 (UTC)Reply

Rounding method

edit

Which rounding method does the template/module implement? Is it PHP's round? (In that case, which RoundingMode?) I imagine there might be some special cases. Could this be documented at Help:Convert? TheFeds 22:13, 15 April 2026 (UTC)Reply

Convert rounds half away from zero using custom code (not PHP). The convert system is the common usage meaning of "round" so I think documenting it would just bloat the already over-sized page and cause confusion because many people would be unaware that other methods existed. Johnuniq (talk) 06:48, 16 April 2026 (UTC)Reply

Multiple output

edit

Right now many Canadian airports contain something like {{convert|1.5|NM||lk=in}} giving 1.5 nautical miles (2.8 km; 1.7 mi). But when using |order=flip, like this {{convert|1.5|NM||lk=out|order=flip}} you get 2.8 kilometres; 1.7 miles (1.5 NM). Is there any way to get either the kilometres or miles, depending on the article, inside the brackets? CambridgeBayWeather (#1 deranged), Uqaqatigijaa (talk), Huliva 04:31, 17 May 2026 (UTC)Reply

Not really. You can use order=out to do what you want, but also linking NM is a problem. The closest is:
  • {{convert|1.5|NM|mi km NM|lk=out|order=out}}1.7 miles (2.8 km; 1.5 NM)
With order=out, the input is used for the conversion but is then ignored. The displayed input is the first unit in the output. If really needed, there could be a new unit NMlk which was the same as NM but had a link built in to the symbol and name. That is done for unit chain which also has chainlk. Johnuniq (talk) 06:02, 17 May 2026 (UTC)Reply
Thanks. I figured that there was some way to do it but I just couldn't see it. Linking the nautical miles is important because most people don't use it. CambridgeBayWeather (#1 deranged), Uqaqatigijaa (talk), Huliva 06:08, 17 May 2026 (UTC)Reply
Please link to, say, three articles where NMlk would be useful and the unit can be added. That is, if linking km as above is a problem. Johnuniq (talk) 06:15, 17 May 2026 (UTC)Reply
Cambridge Bay Airport, Inuvik (Mike Zubko) Airport, Dawson City Airport, and there's 100's more Canadian airports that will have it. I'm not sure that linking kilometres is a problem but it probably falls under Wikipedia:Manual of Style/Linking#What generally should not be linked item 3 "Common units of measurement". CambridgeBayWeather (#1 deranged), Uqaqatigijaa (talk), Huliva 06:23, 17 May 2026 (UTC)Reply
I added NMlk:
  • {{convert|1.5|NM|mi km NMlk|order=out}}1.7 miles (2.8 km; 1.5 NM)
Johnuniq (talk) 06:35, 17 May 2026 (UTC)Reply
Thanks. CambridgeBayWeather (#1 deranged), Uqaqatigijaa (talk), Huliva 06:46, 17 May 2026 (UTC)Reply
Pinging @10mmsocket
Surely the question is "what is the relevance of nautical miles?". I understand that in aeronautical publications, this is the preferred unit of measure, but Wikipedia is not an aeronautical publication. It would be the same as identifying the Belair Stud as being 9+12 furlongs (1+316 mi; 1.9 km) from the nearest 7-Eleven store. A case of horses for courses? As I have also observed, if it was anything other than an airfield, such as a parkland, or a large town, we wouldn't hesitate to unload a unit of measure that is alien to most readers of Wikipedia. However I do recognise that the original data often comes in the form of NM, so I looked for a solution that included that aspect.
My solution, as already described in this discussion is a variant of the convert template as follows...

{{convert|5|NM|mi km|0|order=out}} starts with 5 NM but outputs 6 miles (9 km)
or, with a little bit of tweaking
{{convert|5|NM|0|abbr=in|order=out}} outputs metric first i.e. 9 km (6 miles)

The other bonus here is that everybody recognises both miles and km, and we no longer need a link to explain "NM".
WendlingCrusader (talk) 13:15, 17 May 2026 (UTC)Reply
Yup. I'm 100% with you. Distance in NM can be sourced if necessary, but displaying it is just not needed. 10mmsocket (talk) 20:02, 17 May 2026 (UTC)Reply

Not playing nice with visual editor?

edit

If I edit:

{{convert|12.75|±|0.02|km2|sigfig=3}}

with the Visual Editor I get a mess. It comes up with From unit = "±", To units = "0.02", and Precision of suffix = "km2". Is this a problem with VE, or a problem with the template? RoySmith (talk) 17:17, 24 May 2026 (UTC)Reply

@RoySmith: Neither, it's a problem with the definitions at Template:Convert#TemplateData, which presumes that the first four positional parameters will only take on certain roles. In other words, it's not flexible. --Redrose64 🌹 (talk) 21:15, 24 May 2026 (UTC)Reply

English variety

edit

Would it be possible for this template to use American English spellings by default in articles with {{Use American English}}? A Wondrous Raven (talk) 19:29, 31 May 2026 (UTC)Reply

This has been suggested before, see August 2023 and December 2025. As can be seen in my replies, I do not think individual modules should roll their own method of detecting page-wide options such as "Use X English". Convert could do what was wanted If there were a way for a module to read such data efficiently and reliably. Preferably, the method would work, or at least not cause problems, on Wikipedias in other languages because dozens of sites use convert. The issue should be raised as a wishlist request for the WMF to resolve, but see WP:COMMTECHGATE. Johnuniq (talk) 01:49, 1 June 2026 (UTC)Reply
Ah, okay. A Wondrous Raven (talk) 02:12, 1 June 2026 (UTC)Reply
Technically I suspect it would be easy for a bot to set convert to use sp=us on articles that are tagged with {{Use American English}}, however whether there would be consensus for that task is a different question I would not like to predict the answer to. Thryduulf (talk) 09:39, 1 June 2026 (UTC)Reply
That's an interesting thought. A bot could use Category:Use American English which would work well (modules cannot access page categories). At one point, WP:AWB was set to include certain changes to convert when doing its routine changes. I haven't noticed that in recent years and don't know if it is still used. If not done with other edits, a bot might hit a lot of articles. It should avoid changing converts with abbr=on for simplicity and to reduce the number of changes. Johnuniq (talk) 10:27, 1 June 2026 (UTC)Reply
For the same reasons a bot also shouldn't add the parameter when British and US English are the same, e.g. lbs ↔ kg, ft → m when abbreviation is not "in" or "off". That could get quite complicated though. Thryduulf (talk) 23:43, 1 June 2026 (UTC)Reply
Things could go wrong. Sometimes editors go on a tear of adding {{Use American English}} to many articles inappropriately (seen it, rolled it back, got the T-shirt). If a bot adjusted the uses of Convert before any caught it, that'd survive rollback of the template additions and nothing would cause the bot to self-revert. NebY (talk) 14:10, 2 June 2026 (UTC)Reply
A maintenance bot could look for the addition or removal of such templates and add/remove the sp=us parameter after a delay to allow for quick rollbacks, etc. There are multiple bots that work like this for other tasks. Thryduulf (talk) 14:17, 2 June 2026 (UTC)Reply
I did not know (/think of) that. Thank you! NebY (talk) 14:19, 2 June 2026 (UTC)Reply
It should be technically possible in the same way that {{cite web}}, et al., can figure out how to format dates in articles when there is {{use mdy dates}} or {{use dmy dates}} present. Imzadi 1979  01:11, 2 June 2026 (UTC)Reply