Template talk:Convert/Archive April 2013

Converting an entire table
Is it possible to convert an entire table, or to convert a table column, from one set of units to another? I'm thinking of this as either (a) being performed in real time by the viewer; of (b) the chosen units being selected for display in real time by the viewer. This would allow the table to show eg "sq miles" for area, and then the viewer changing all entries in the colum to "sq kms". This could be particularly useful if the column is sortable. — Preceding unsigned comment added by Degrey1 (talk • contribs) 01:53, 5 April 2013 (UTC)

Developing Convert/validate to warn errors
I have begun to experiment with a possible quick parameter validation subtemplate, Template:Convert/validate, which could be run, as a sideshow, to report invalid parameters without increasing the nesting to hit the wp:expansion depth limit. For example:
 * {&#123;convert/validate|34|lb|kg|2|sp=us|lk=out}} &rarr;
 * {&#123;convert/validate|34|lb|kg|zz|sigfig=3}} &rarr;
 * {&#123;convert/validate|21|ft|1|in|m|2|abbr=on}} &rarr;
 * {&#123;convert/validate|2L|ft|1|in|m|2|abbr=on}} &rarr;

Tests have shown {Convert/validate} can validate conversions at over 500 per second, adding just 1/100 of a second to an article edit-preview, for each 5 uses of {Convert} on a page. The new subtemplate is just for experimentation, at this point, to determine what parameters can be validated without rejecting valid options. The plan is to check for major problems, while not slowing the performance of {Convert}. -Wikid77 (talk) 15:29, 25 February 2013 (UTC)


 * Watch out for disp=x params -- WOSlinker (talk) 19:16, 25 February 2013 (UTC)
 * 1 ft
 * 1 ft


 * Good catch there, and "adj=mid" or "adj=pre" would use parameter 4 as well. I have added those exceptions as valid, but the typical validation speed remains as 500 conversions/second. Hopefully, those are all the exceptions. It will be good to detect the 3-unit errors (such as "|lb|kg|lb"), which can happen often when reversing "kg|lb" to become "lb|kg" but forgetting to change parameter 4. -Wikid77 23:23, 25 February 2013 (UTC)
 * I would like to recommend checking if the two units (from and to, parameters 3 and 4) are the same or synonyms (e.g. { {convert|5|km|km} }, { {convert|20|ft|feet} }. This should help avoid the template loop talked about in the documentation: An attempt to convert a unit to itself, e.g., km to km, will result in a template loop.  Nutster (talk) 20:21, 5 March 2013 (UTC)
 * The attempted same-unit conversions are probably somewhat common, such as when rewriting as a reverse conversion but changing only one unit, not the other, and seeing the result as a template-loop message. Here, {convert|14|km|km}:
 * 14 km <!- Neutralized, since non-active archive discussion, causes error category. -->
 * Many users would not understand "template-loop" to mean "same unit" as input/output units. -Wikid77 (talk) 10:27, 6 April 2013 (UTC)

Template for paintings?
Is there a template on Wikipedia that's the equivalent of this size template at Commons: ? You put in, say, the size of a painting in inches and it would return "123 × 456 in (312.4 × 1,158.2 cm)". Thanks! – Kerαu noςco pia ◁ gala xies 07:09, 8 April 2013 (UTC)
 * 123 x will output 123 x.  Imzadi 1979  →   08:16, 8 April 2013 (UTC)
 * If you want more precision, you could use 123 x, which gives 123 x (as you'd wanted), but I'd say that that would be too precise. If you want abbreviations, you could use 123 x , which gives 123 x. Note that the unit is given twice (as per MOSNUM). J IM ptalk·cont 11:07, 8 April 2013 (UTC)
 * Wonderful, thank you guys so much. I need the x to appear both times, so that last example is perfect. – Kerαu noςco pia ◁ gala xies 17:53, 8 April 2013 (UTC)


 * Use range 'xx' for art museum paintings: Various museums measure paintings in inches and cm, but they typically show each unit name only once. The range word 'xx' can be used for that format. For example, with paintings in the Guggenheim Museum:
 * {&#123;convert|77+3/8|xx|51+1/4|in|cm|1}} &rarr; 77+3/8 xx
 * {&#123;convert|195|xx|130|cm|in|1}} &rarr; 195 xx
 * To show cm as decimal tenths, the rounding option "|1" has been included. Note how use of range 'xx' matches the format of measurements at the Guggenheim's website, such as "Painting, 195 x 130 cm, May 1953" at Guggenheim.org. That format is very typical of measurements for paintings in art galleries. -Wikid77 (talk) 07:47, 9 April 2013 (UTC)


 * Yes, thank you!! I figured the two units was a sacrifice I was willing to make, but this is fantastic. I also use the extra |1 and |abbr=on parameters. It comes out perfectly. – Kerαu noςco pia ◁ gala xies 08:32, 9 April 2013 (UTC)

Redlinked categories
I'm getting Category:Pages using Template Convert/disp=unit, Category:Pages using Template Convert/adj=off, Category:Pages using Template Convert/disp=number, Category:Pages using Template Convert/disp=u2 and similar on articles. I'm just curious what the plan is for these, and will they be created and hidden?  Imzadi 1979  →   00:44, 9 April 2013 (UTC)
 * Yes, that was the plan. The idea is to keep track of what's going on with regard to how the template is being used. J IM ptalk·cont 01:01, 9 April 2013 (UTC)
 * wouldn't it be better to use a single category, and set the sort parameter to be the value? this would reduce the number of tracking categories, and allow you to see ones that are not valid as well (that you may not have predicted were in use), also you should probably add a check to see if disp=number as indicated by Wikid77 below. Frietjes (talk) 18:06, 9 April 2013 (UTC)


 * See below: . -Wikid77 17:58, 9 April 2013 (UTC)

Ruler precisions
I was just remembering how 12-inch rulers are calibrated to eighths or sixteenths of an inch, as being 12+0/8 inches, or 12+0/16 inches, where:
 * {&#123;convert|12+0/8|in|cm}} &rarr; 12+0/8 in
 * {&#123;convert|12+0/16|in|cm}} &rarr; 12+0/16 in


 * {&#123;convert|12.000|in|cm}} &rarr; 12.000 in

To hide the fraction, use {convert/f} with r1=0 to round input to 0 decimals:
 * {&#123;convert/f|12+0/16|in|cm|r1=0}} &rarr;

Those are rare cases, but show how to convert a ruler (measuring stick) known to be accurate to within some calibrated fractions of a unit. -Wikid77 (talk) 08:59, 9 April 2013 (UTC)

Expression errors from disp=number category link
I am changing Template:Convert/f to remove the hidden category link with option "near=n" to avoid expression errors. I did not realize that #expr thinks internal category links are invalid data, so option "disp=number" has been generating expression errors, in a few pages, on "[" with message:
 * "Expression error: Unrecognized punctuation character "["."

The specifics of the expression error can be seen in the following:
 * {convert|4|m|ft} &rarr; 4 m
 * {&#123;convert|4|m|ft|disp=number}} &rarr; 4 m
 * "{&#123;convert|4|m|ft|disp=number}}" &rarr; "4 m"
 * {&#123;str_len|{&#123;convert|4|m|ft|disp=number}} }} &rarr; 3
 * &rarr;
 * &rarr;
 * &rarr;

The option "disp=output number only" also craters:
 * &rarr;

At the time of this message, there were 260 pages in "Category:Pages_using_Template_Convert/disp=number. However, few of those pages showed the generated "[" error, because {convert/spell} only uses disp=number to display the amount, not to re-calculate that amount, and {convert/spell} seems to still function correctly. -Wikid77 17:58, 9 April 2013 (UTC)

Wrapping output for display purposes
Hi, following up on a script request, I was wondering if there was any interest in wrapping output in spans so that unit measurements could be hidden by user CSS. So for an example, output like "3.21 kilograms (7.1 lb)" could display as "3.21 kilograms" or "7.1 lb" based on user preference. It would need to output something like this: Then some CSS could suppress the different elements to only display measurements in the user's units of choice. For example if the user didn't like metric: If haven't gotten into all the template's outputs, so I'm sure there would be many more classes needed, but it's an idea for how it might work. Any thoughts? — Bility (talk) 15:57, 9 April 2013 (UTC)
 * Interesting idea to select unit preference but generates many problems: Although the embedded span-tags could be feasible, to suppress parts of conversions, there would be excessive complexity due to the wide variety of data formats already in use among 500,000 article pages. Instead, perhaps consider a special {convert/spantag} template for articles where the preference would be a great benefit. Otherwise, there would be numerous complications in many articles. For example, some tables prefer option "abbr=values" to show both the input and output values in tables which state both values are being shown. Example:
 * {&#123;convert|45|m|ft|abbr=values}} &rarr; 45 m
 * If one value was hidden, the current table column header would then incorrectly state two values are listed, but only one value would appear in table cells under that heading (and which of the two would that value be). Also, the HTML-text size of conversions would be bloated by the extra span-tags, which might greatly bloat tables with many conversions. There is also a wp:MOS style rule to show the first conversion, on a page, as the full unit name, not the abbreviated unit symbol of the output-unit text. Then other templates, which did not use convert, would need to be span-tagged to match, or else users would gripe that {Weather_box} was still showing climate data in the suppressed units. Also, some browsers do not process CSS customization classes well, and might require special support. I would suggest creating a separate {convert/spantag} wp:wrapper template to be used in pages which are specifically designed and written to allow hiding parts of conversions. Otherwise, too many problems, and some users would request new on/off options to force display of some whole conversions, in some cases. Meanwhile, there would be thousands of cases to test, to ensure workability, while the new options would be an arena of "creeping featurism" to make the whole situation even more featured creepyism of bizarre, unexpected interactions (than already occur now). For that reason, I suggest creating a wrapper template, {convert/spantag}, and see in which pages it might be beneficial. For most articles, there are only an average of 5 conversions in use. -Wikid77 (talk) 18:38, 9 April 2013 (UTC)

Error with ±
There's a bug in this template which surfaces at Milky Way. 8.33 ± produces this error: 8.33 ± 8.33 - 0.35 kpc does not: 8.33 - 0.35 kpc. I'm pretty sure this is a new bug, but can't find the relevant recent change. Could someone who knows this template possibly track that down? I'd appreciate it! —Alex (ASHill &#124; talk &#124; contribs) 02:21, 11 April 2013 (UTC)


 * Fixed. J IM ptalk·cont 08:44, 11 April 2013 (UTC)
 * Thanks. —Alex (ASHill &#124; talk &#124; contribs) 12:14, 11 April 2013 (UTC)
 * No worries. J IM ptalk·cont 10:43, 12 April 2013 (UTC)

Tracking categories
The point of these was to make it easier to keep track of how the template was being used. They replaced the old empty templates from which you could do the same job by going to "What links here". It does make it easier to track down what's going on but I'm beginning to wonder whether it was worth the trouble. The old empty templates seemed to cause less trouble. Perhaps it's time to go back to these. J IM ptalk·cont 12:18, 12 April 2013 (UTC)
 * yes, how about if we use something like, which does the same thing as what we have but through transclusion.  the problem is there is no way of finding all the problems caused by these tracking categories. Frietjes (talk) 14:36, 12 April 2013 (UTC)


 * Wikipedia not ready for hidden categories in links/expressions: I agree that the hidden categories should be removed from the Convert output, after logging the current category counts. The current primitive parsing of wikitext markup cannot handle nested "[...]" and so any category links inside wikilinks or external links or expressions (etc.) will cause the markup to garble. Many people imagine that the MediaWiki software was somehow "designed" by computer scientists who melded the best of typesetting scripting languages with the wiki-interface concept; however, it seems the MediaWiki software was just hacked together and does not handle the typical automatic nesting of structures, such as embedded square brackets, as typical of professional computer software for many decades. I think the whole world has become too complex for "pro-active designs" and that is why a car will auto-lock the doors after a driver starts the car with the door open, moves forward a few metres, puts the gear in neutral, then gets out to retrieve a nearby package. Once the driver shuts the car door, then all doors will auto-lock with the engine running until the car runs out of fuel. And the auto-industry spent billions to reach the pinnacle of that featured creepyism of getting auto-locked out of an idling automobile. We cannot use hidden categories with Convert at this stage of the primitive MediaWiki software, until the expression or wikilink parsing learns to process and bypass any category links in the link text. -Wikid77 (talk) 18:48, 12 April 2013 (UTC)


 * I've deleted the category system in favour of tracking subtemplates. J IM ptalk·cont 05:30, 13 April 2013 (UTC)

Using disp=flip breaks lk
Using 'disp=flip' in combination with a 'lk' breaks the template. Thus, 2.86745 AU gives:
 * 2.86745 AU

Removing the 'lk' option will work, but will also remove the link(s):
 * 2.86745 AU

Praemonitus (talk) 14:38, 12 April 2013 (UTC)
 * fixed. Frietjes (talk) 15:25, 12 April 2013 (UTC)
 * Thank you for fixing it for the instance of 'lk=on'. The same issue exists for 'lk=in' and 'lk=out'.
 * 2.86745 AU
 * 2.86745 AU


 * Praemonitus (talk) 16:16, 12 April 2013 (UTC)
 * fixed. Frietjes (talk) 16:27, 12 April 2013 (UTC)
 * Thank you! Praemonitus (talk) 17:57, 12 April 2013 (UTC)

Breaking links
Why does convert now break links when it's piped in? See for instance here; this kind of usage has worked for years - why all of a sudden is it broken? Parsecboy (talk) 21:42, 11 April 2013 (UTC)
 * you are correct, and here an example from your diff 15 cm SK L/45 guns. the issue may be the generation of tracking categories by the template.  for example, the code is generating  in the first step, which then breaks the linking. Frietjes (talk) 22:20, 11 April 2013 (UTC)
 * Thanks for explaining that. I guess there's nothing we can do to fix it, so hard-coding is the way to go for now. 11:38, 13 April 2013 (UTC)
 * actually, it's now been fixed by changing the tracking system, see below! Frietjes (talk) 14:55, 13 April 2013 (UTC)
 * Excellent, thanks! Parsecboy (talk) 15:08, 13 April 2013 (UTC)

"Pages using" categories
It looks like there need to be changes to this template, per the deletion discussion about Category:Pages using Template Convert, so that this template no longer categorizes articles into this nonexistent category. Hyacinth (talk) 02:36, 14 April 2013 (UTC)
 * The changes were made, the discussion was closed then the categories were deleted. The template doesn't categorise articles any more; go to any article & you'll see the category gone.  However, if you go to one of the deleted category pages, the articles will still be there; it takes a while for these to catch up. J IM ptalk·cont 03:08, 14 April 2013 (UTC)
 * I came here after seeing more than one article categorized. If it was the case that if I went "to any article" I'd "see the category gone" I wouldn't have posted a message saying I did see the category after I did see it. Hyacinth (talk) 03:16, 15 April 2013 (UTC)


 * I've seen it too. Presently on Suillus_salmonicolor, Cley_Marshes, James_Joyce.  Its an issue with Wikipedia caching and should clear when the page is next edited.  Incidentally, I've seen a number of problems with large categories populating and depopulating slowly lately, and things not being updated promptly.  Dragons flight (talk) 04:21, 15 April 2013 (UTC)

Errors
New changes in the template introduced errors in conversions, for example. Please fix it. Subtropical-man (talk) 08:58, 14 April 2013 (UTC)

Anyone like to explain what has gone wrong in this GA-- Rain?-- Clem Rutter (talk) 10:03, 14 April 2013 (UTC)


 * Fixed with an edit to Template:Convert/track/disp// -- WOSlinker (talk) 12:45, 14 April 2013 (UTC)

disp=flip seems to break convert/3
as in

works fine without disp=flip

John of Cromer in Philippines (talk) mytime= Sun 17:48, wikitime=  09:48, 14 April 2013 (UTC)
 * Developed a {convert/flip3} to allow other options: Various options have been conflicting with others, so the best alternative has been to develop a separate Template:Convert/flip3 to handle that situation. Compare:
 * {&#123;convert/3|3.5|,|3.0| and| 2.0|m|ftin|abbr=on}}     &rarr;
 * {&#123;convert/flip3|3.5|,|3.0| and| 2.0|m|ftin|abbr=on}} &rarr;
 * {&#123;convert/flip3|3.5|,|3.0| and| 2.0|m|in|disp=x| [or |]}} &rarr;
 * The decision to have a {convert/flip3}, as a separate wp:wrapper template, has taken years to decide, due to numerous other options which have been added during the time period. Now, other options as "disp=?" can also be used with the flipped format. -Wikid77 (talk) 08:41, 15 April 2013 (UTC)

Template broken
Can someone please revert this back to this version until the testing is completed? The template is adding a link at every use for some reason. See for example List of World Heritage Sites in Southeast Asia. Thanks, Reywas92 Talk 03:59, 25 April 2013 (UTC)
 * I've fixed the template. -- WOSlinker (talk) 06:16, 25 April 2013 (UTC)

Excessive precision
The Blue whale article says the creature is 98 feet long, which is overly precise. Better to say 100 feet. But we're using the convert template to go from 30 meters. Is there a way to have the result rounded? --Uncle Ed (talk) 17:19, 24 April 2013 (UTC)

Oh, never mind: I got it. You gotta specify the sigfig parameter:
 * The typical blue whale is 30 m long

--Uncle Ed (talk) 17:25, 24 April 2013 (UTC)
 * The longest reliably measured was 29.9 m (98.1 ft), not 100 ft. Please don't add feet where they don't exist. And the typical blue whale is anywhere from 68 to 87 ft long, depending on which ocean basin it occurs in. SHFW70 (talk) 21:06, 24 April 2013 (UTC)

As discussed at talk:Blue whale, the source said 98 feet (not 98.1 ft). Please don't add precision where it is not in the source.

Also, can we get a source for the typical blue whale? I believe you know your aquatic mammals, but I don't want someone slapping a {fact} tag on it when I put in the range you just gave me. --Uncle Ed (talk) 21:27, 28 April 2013 (UTC)
 * Oh my god. NINETY-EIGHT POINT ONE feet is the exact conversion for 29.9 meters. I was simply pointing out that even the goddamn source rounded off a tenth of a foot and that it would be ridiculous to add TWO WHOLE FUCKING FEET when it's already been ROUNDED! And like I already said, the page already gives average sizes for both the Northern and Southern Hemispheres. Read the damn article. SHFW70 (talk) 16:08, 29 April 2013 (UTC)


 * First up, Wikipedia is supposed to both readable by children and professional. Swearing in the change summary and getting angry at those trying to help you is neither.
 * I don't have the reference book mentioned but if you can repeat for us here the exact sentence used in the book and we will then try to work with you to rework the article appropriately. The normal way to do it is to use the exact measurement given in the reference (using the same precision and units). We then put that measurement into 'convert' to get the measurement in other units. Convert can be told how much precision we want in the output value. If desired, 'convert' can flip them into a different order (ie metric first or imperial first) but the number going into the 'convert' should always be the exact number from the book. Regards,  Stepho  talk 23:29, 29 April 2013 (UTC)


 * That's nice. I honestly don't care. He's an idiot and needs to go home. Here's the quote: "Dale Rice, a biologist at the National Marine Mammal Laboratory, however, using only measurements made by scientists, concluded that the longest whale that could be verified was a 98 ft (29.9 m) long female taken by Japanese whalers in the 1946-47 season." (Calambokidis and Steiger, Blue Whales, 1997, WorldLife Library, p. 20). And we're not using any of those damn converters. They always round off figures, as I already pointed out. I honestly can't understand how any of this is even a debate. Some idiot wants to round everything off simply because he's an idiot and I have to deal with it? Morons. All of you. Worthless morons. SHFW70 (talk) 15:26, 30 April 2013 (UTC)


 * If you don't care then I'm not sure why you're here bad mouthing people trying to help. Disagreeing with them is fine - just present your case without the attitude.
 * The book says 98 ft (29.9 m). Taking 98 ft as the true number report by the whalers we get 98 ft. Taking 29.9 m as the true number we get 29.9 m. Since Japan wasn't metric at the time, the US based National Marine Mammal Laboratory also wasn't metric, the ft -> m conversion agrees with the reference and m -> ft is slightly off, then 98 ft is likely to be the original measurement. The length is supposed to be a record, not just a typical value, so more precision than rounding to 100 ft is required. Rounding to the foot is equivalent to rounding to 30cm, so rounding to a whole metre is a bit too loose but rounding to 10 cm is equivalent to rounding to $1⁄3$ of a foot. To my mind, 98 ft, which gives 98 ft, fulfils most of the expectations of a world record measurement and matches the reference. As an option, we could round to 50 cm (close to $1 1⁄2$ ft) by using 98 ft to give 98 ft. Since most of the article is metric first, there are also options to swap the displayed order around, ie 98 ft gives 98 ft and 98 ft gives 98 ft. As you can see, those 'damn' converters don't always round off wrongly, we have very fine control of what they do.  Stepho  talk 23:58, 30 April 2013 (UTC)