Template talk:Convert: Difference between revisions
→Plans for new version: good but |
→Suffix parameters for first and second numbers: reply to both |
||
(28 intermediate revisions by 10 users not shown) | |||
Line 22: | Line 22: | ||
}} |
}} |
||
== Indian numbering system: lakhs and crores == |
|||
== Linear feature density == |
|||
:''Moved from [[Module talk:Convert]]. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 01:45, 19 November 2024 (UTC)'' |
|||
At [[Transport in Switzerland#Railways]] I've found a need to convert 122 km/1000 km<sup>2</sup> into imperial (probably something like miles per 100 or 1000 sqmi). Is this something convert can handled? In the article I've gone with separate conversions to come up with {{convert|122|km|disp=out}} per {{convert|1000|km2|disp=out}} which is not ideal. [[User:Thryduulf|Thryduulf]] ([[User talk:Thryduulf|talk]]) 16:58, 19 July 2024 (UTC) |
|||
I request that we enhance the module to include [[lakhs]] and [[crores]]. |
|||
The [[Indian numbering system]] is the main nomenclature used in South Asia to name large numbers. From the lead: |
|||
:Best I can find is <code><nowiki>{{cvt|0.122|km/km2|mi/sqmi|3}}</nowiki></code> to display as {{cvt|0.122|km/km2|mi/sqmi|3}} |
|||
: {{xt|The terms ''[[lakh]]'' or 1,00,000 (one hundred thousand, written as ''100,000'' in Pakistan, and outside the [[Indian subcontinent]]) and ''[[crore]]'' or 1,00,00,000 (ten million, written as ''10,000,000'' outside the subcontinent) are the most commonly used terms in [[Indian English]] to express large numbers in the system.}} |
|||
:In theory we should be able to use e3km2 and e3sqmi but these don't work. <span style="border:1px solid blue;border-radius:4px;color:blue;box-shadow: 3px 3px 4px grey;">[[User:Stepho-wrs|''' Stepho ''']] <span style="font-size:xx-small; vertical-align:top">[[User Talk:Stepho-wrs|talk]] </span></span> 17:22, 19 July 2024 (UTC) |
|||
This is a dimensionless unit, or if you wish, the units are integers. (Hence if implemented, the data item in 'all_units' at [[Module:Convert/data]] could be named <code>["ins"]</code> for 'Indian numbering system'). Note also the main pattern of comma-separation into groups of two and three digits, not just three. |
|||
:Similarly at [[List of prominent mountains of Switzerland#Distribution]] there is {{tpq|approximately 1.09 summits per 100 km<sup>2</sup>}} that I've just left as I can't work out anything sensible (I don't think {{convert|0.0109|/km2|abbr=on}} is particularly useful). [[User:Thryduulf|Thryduulf]] ([[User talk:Thryduulf|talk]]) 17:36, 19 July 2024 (UTC) |
|||
These terms should be converted to standard English terms, mostly with the term ''million'', except for values up to 9 lakh, which could be 900,000. Sample usage in articles: |
|||
::Found a really clumsy and dirty technique: <code><nowiki>{{cvt|122|mi|km0|abbr=values|disp=preunit|km/1000 km<sup>2</sup>|mile/1000 sq mile}}</nowiki></code> displays as {{cvt|122|mi|km|0|abbr=values|disp=preunit|km/1000 km<sup>2</sup>|mile/1000 sq mile}} |
|||
* '''lakh''' – [https://en.wikipedia.org/enwiki/w/index.php?search=lakh+insource%3A%2F%5B0-9%5D%2A+lakhs%3F+%2A%2F+-intitle%3Alakh&title=Special:Search&profile=default&fulltext=1 6,914 articles] |
|||
::This relies on km/km2 converting to mi/sqmi being the same ratio as mi to km - ie km/km2 is same as 1/km and 1/km -> 1/mi being the same ratio as mi -> km. Dirty, very dirty. |
|||
* '''crore''' – [https://en.wikipedia.org/enwiki/w/index.php?search=crore+insource%3A%2F%5B0-9%5D%2A+crores%3F+%2A%2F+-intitle%3Acrore&title=Special:Search&profile=default&fulltext=1 10,809 articles] |
|||
::Sadly, this trick doesn't work for summits per area. <span style="border:1px solid blue;border-radius:4px;color:blue;box-shadow: 3px 3px 4px grey;">[[User:Stepho-wrs|''' Stepho ''']] <span style="font-size:xx-small; vertical-align:top">[[User Talk:Stepho-wrs|talk]] </span></span> 17:57, 19 July 2024 (UTC) |
|||
The plural sometimes has the -s, and sometimes doesn't; so both '2 lakhs' and '2 lahk' are seen; same for crore(s). |
|||
:If there were a heap of these, new units for "1000 km2" and "100 sqmi" and "100 km2" could be defined. I'm not sure how clean the result would be but it might be reasonable. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 03:20, 20 July 2024 (UTC) |
|||
A similar issue arises at [[Scandinavian mountains#Climate, permafrost and glaciers]] where there is a need to convert "1.17 °C /100 m" but the logical <code><nowiki>{{convert|1.17|C-change/e2m}}</nowiki></code> gives an error ({{convert|1.17|C-change/e2m}}). A quick search suggests that "°C /100m" (with that exact spacing) is used in at least three other articles. [[User:Thryduulf|Thryduulf]] ([[User talk:Thryduulf|talk]]) 11:30, 12 September 2024 (UTC) |
|||
This arose at the Rfc at [[Wikipedia talk:Manual of Style/Dates and numbers#RfC Indian numbering conventions|Wikipedia talk:Manual of Style/Dates and numbers]], where in my !vote ([[Special:Diff/1258247883|diff]]) I called for using template {{tl|Convert}}, only to realize after the fact that the template will not handle it. This conversion is badly needed, as it will resolve a sore point about usage of lakhs and crores in many articles. Thanks, [[User:Mathglot|Mathglot]] ([[User talk:Mathglot|talk]]) 23:46, 18 November 2024 (UTC) |
|||
== Combining multiple components with ranges == |
|||
:Earlier discussions. |
|||
:*[[Template talk:Convert/Archive 2#Lakh]] |
|||
:*[[Template talk:Convert/Archive 2#110 crore tonnes]] |
|||
:*[[Template talk:Convert/Archive 3#Crore]] |
|||
:*[[Template talk:Convert/Archive 3#Lakh and crore]] |
|||
:I have not yet examined the RfC at [[WT:Manual of Style/Dates and numbers#RfC Indian numbering conventions]]. The above discussions point out that [[lakh]] and [[crore]] are not units. They are like [[million]] which is also not a unit. However, if convert could do something useful that is not provided by {{tl|lakh}} and {{tl|crore}}, it could be investigated. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 02:03, 19 November 2024 (UTC) |
|||
::The {{tlx|lakh}} and {{tlx|crore}} templates make more sense than overloading {{tlx|convert}}. <span style="border:1px solid blue;border-radius:4px;color:blue;box-shadow: 3px 3px 4px grey;">[[User:Stepho-wrs|''' Stepho ''']] <span style="font-size:xx-small; vertical-align:top">[[User Talk:Stepho-wrs|talk]] </span></span> 23:07, 19 November 2024 (UTC) |
|||
Is it possible to combine the "multiple components" form, like {{tlx|convert|11|ft|2|in|m}} and {{tlx|convert|4|ft|5|in|m}}, with the "range" form? The only way that I've found that works is {{tlx|convert|11+2/12|x|4+5/12|ft|m|7=abbr=on}} - this gives {{convert|11+2/12|x|4+5/12|ft|m|abbr=on}} which is technically correct, but not ideal. --[[User:Redrose64|<span style="color:#a80000; background:#ffeeee; text-decoration:inherit">Red</span>rose64]] 🌹 ([[User talk:Redrose64|talk]]) 15:23, 29 September 2024 (UTC) |
|||
:Sorry, no. The multiple units like feet/inches can have several components (miles, chains, ...) and making them work with a range was beyond me. However, if desperate, there is a dirty trick which I can't really recommend but which gives a reasonable result in this case: |
|||
:*<code><nowiki>{{convert|3.40|x|1.35|m|ftin|order=flip}}</nowiki></code> → {{convert|3.40|x|1.35|m|ftin|order=flip}} |
|||
:*<code><nowiki>{{cvt|3.40|x|1.35|m|ftin|order=flip}}</nowiki></code> → {{cvt|3.40|x|1.35|m|ftin|order=flip}} |
|||
:[[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 23:00, 29 September 2024 (UTC) |
|||
::OK, {{ty}} --[[User:Redrose64|<span style="color:#a80000; background:#ffeeee; text-decoration:inherit">Red</span>rose64]] 🌹 ([[User talk:Redrose64|talk]]) 17:10, 30 September 2024 (UTC) |
|||
== |
== Nautical miles to Kilometers == |
||
It is NOT accurate! 8000 nmi = 14,816 km not 15000. Check google & ref64 [[Bombardier Global 7500]]. |
|||
For [[Reciprocating engine#History]] <nowiki>{{convert|2,300|metric ton|short ton long ton|lk=on}}</nowiki> and <nowiki>{{convert|2,300|metric ton|ST LT|lk=on}}</nowiki> {{convert|2,300|metric ton|short ton long ton|lk=on}} and {{convert|2,300|metric ton|ST LT|lk=on|sigfig=4}} instead of <nowiki>{{convert|2,300|metric ton|short ton|lk=on}}</nowiki> or <nowiki>{{convert|2,300|metric ton|long ton|lk=on|sigfig=4}}</nowiki> {{convert|2,300|metric ton|short ton|lk=on|sigfig=4}} or {{convert|2,300|metric ton|long ton|lk=on|sigfig=4}} [[User:Peter Horn|Peter Horn]] [[User talk:Peter Horn|User talk]] 01:54, 6 October 2024 (UTC) |
|||
The correct multiplier is 1.852 not 1.875 see ref 1 [[Nautical mile]] & for at least half a century (ref 5). [[User:Dave-okanagan|Dave-okanagan]] ([[User talk:Dave-okanagan|talk]]) 04:18, 17 December 2024 (UTC) |
|||
:{{ping|Peter Horn}} When a unit code such as <code>short ton</code> contains a space, use <code>+</code> to separate units: |
|||
:*<code><nowiki>{{convert|2,300|metric ton|short ton+long ton|lk=on}}</nowiki></code> → {{convert|2,300|metric ton|short ton+long ton|lk=on}} |
|||
:[[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 02:09, 6 October 2024 (UTC) [[User:Peter Horn|Peter Horn]] [[User talk:Peter Horn|User talk]] 02:41, 6 October 2024 (UTC) |
|||
::Thanks. [[User:Peter Horn|Peter Horn]] [[User talk:Peter Horn|User talk]] 02:49, 6 October 2024 (UTC) |
|||
:The template sees 3 zeroes at the end and assumes that is the amount of rounding desired. Ie 8000 nmi +/- 500 nmi. It is not assuming 8000 nmi +/- 0.5 nmi. Therefore it rounds the output to a similar amount. |
|||
== Possible bug report re: temperature units == |
|||
:However, you can control the rounding. Eg: |
|||
:*<code><nowiki>{{cvt|8000|nmi|km|0}}</nowiki></code> gives {{cvt|8000|nmi|km|0}} (probably not appropriate if the 8000 is a round number) |
|||
:*<code><nowiki>{{cvt|8000|nmi|km|-1}}</nowiki></code> gives {{cvt|8000|nmi|km|-1}} |
|||
:*<code><nowiki>{{cvt|8000|nmi|km|-2}}</nowiki></code> gives {{cvt|8000|nmi|km|-2}} |
|||
:*<code><nowiki>{{cvt|8000|nmi|km|-3}}</nowiki></code> gives {{cvt|8000|nmi|km|-3}} (probably the most appropriate if the 8000 is a round number) |
|||
:Choose whichever suits the situation best. Be careful of [[false precision]].<span style="border:1px solid blue;border-radius:4px;color:blue;box-shadow: 3px 3px 4px grey;">[[User:Stepho-wrs|''' Stepho ''']] <span style="font-size:xx-small; vertical-align:top">[[User Talk:Stepho-wrs|talk]] </span></span> 04:56, 17 December 2024 (UTC) |
|||
:@[[User:Dave-okanagan|Dave-okanagan]]: this is discussed in the first FAQ at the top of the page as well. <span style="background:#006B54; padding:2px;">'''[[User:Imzadi1979|<span style="color:white;">Imzadi 1979</span>]] [[User talk:Imzadi1979|<span style="color:white;"><big>→</big></span>]]'''</span> 05:41, 17 December 2024 (UTC) |
|||
== Suffix parameters for first and second numbers == |
|||
Input: |
|||
{{Pre|<nowiki>{{Convert|1|K|C F|abbr=~}} |
|||
{{Convert|1|C|F|abbr=~}} |
|||
{{Convert|1|C|F|abbr=off}} |
|||
{{Convert|1|K|C F|abbr=off}} |
|||
{{Convert|1|Celsius|F|abbr=~}} |
|||
{{Convert|1|Fahrenheit|Celsius}} |
|||
{{Convert|1|C|kelvin|abbr=~}}</nowiki>}} |
|||
Can we please get suf1 and suff2 parameters added to this template, like done at [[:Template:Change]], so that we can add references or notes to the first and second numbers in the template, respectively? Cheers, [[User:Hwy43|Hwy43]] ([[User talk:Hwy43|talk]]) 20:10, 26 December 2024 (UTC) |
|||
Output:{{br}} |
|||
{{Convert|1|K|C F|abbr=~}}{{br}} |
|||
{{Convert|1|C|F|abbr=~}}{{br}} |
|||
{{Convert|1|C|F|abbr=off}}{{br}} |
|||
{{Convert|1|K|C F|abbr=off}}{{br}} |
|||
{{Convert|1|Celsius|F|abbr=~}}{{br}} |
|||
{{Convert|1|Fahrenheit|Celsius}}{{br}} |
|||
{{Convert|1|C|kelvin|abbr=~}}{{br}} |
|||
:The purpose of convert is to take a single number and convert it into the equivalent in different units of measurement. All numbers displayed come from that ''single'' input. So why would we need a second reference? |
|||
Semi-expected output:{{br}} |
|||
:Likewise, why would we have different notes for each unit of measurement? Surely a single reference and/or note cover all the units used. Can you give an example? <span style="border:1px solid blue;border-radius:4px;color:blue;box-shadow: 3px 3px 4px grey;">[[User:Stepho-wrs|''' Stepho ''']] <span style="font-size:xx-small; vertical-align:top">[[User Talk:Stepho-wrs|talk]] </span></span> 23:42, 26 December 2024 (UTC) |
|||
1: 1 kelvin [K]{{br}} |
|||
::Good point re: single input. Rather, a suffix parameter is desired just for after the first number because it is the one that can be sourced, whereas the second is a product of the template. Same with notes being based on the first number. See the Flin Flon and Lloydminster rows at [[List of cities in Saskatchewan#List]]. In those two cases, I want the notes to be displayed after the first number, not after the second (conversion) number as currently shown. Cheers, [[User:Hwy43|Hwy43]] ([[User talk:Hwy43|talk]]) 00:29, 27 December 2024 (UTC) |
|||
2: 1 degree Celsius [°C]{{br}} |
|||
3 & 4: N/A, working{{br}} |
|||
5: 1 degree Celsius [°C]{{br}} |
|||
:::Fair enough, this only applies to tables. The {{para|pre}} option (with the ref as the next field) can be twisted into doing what you want. <code><nowiki>{{convert|2.01|km2|sqmi|disp=table|sortable=on|adj=pre|<ref group=SK>col1 note</ref>}}</nowiki></code> gives: |
|||
And last 2, certainly slightly surprising behavior that it outputs the unit names but doesn't recognize some as input. But it does for Celsius. If that's known/intended behavior, ought to be documented somewhere. (There, then it's not a bug, b/c you documented it—now it's a feature {{;)}}) |
|||
{|class="wikitable" |
|||
Contrasted:{{Br}} |
|||
!Column1 km<sup>2</sup> |
|||
{{Convert|1|in|ft cm|abbr=~}}{{br}} |
|||
!Column2 miles<sup>2</sup> |
|||
{{Convert|1|inch|cm}}{{br}} |
|||
{{Convert|1|km|furlong}}{{br}} [[User:Slowking Man|Slowking Man]] ([[User talk:Slowking Man|talk]]) 23:14, 7 October 2024 (UTC) |
|||
:Convert has a lot of quirks due to its long history. The proper documentation is at [[Module:Convert/documentation/conversion data#Temperature]]. Various summaries of the units are available but I don't like the advice they give for temperature because they suggest that <code><nowiki>{{convert|30|°C}}</nowiki></code> is the approved method whereas it should actually be <code><nowiki>{{convert|30|C}}</nowiki></code> on the basis that unit codes are intended to be easy to type and it is not necessary to remember that it is <code>K</code> (kelvin) but <code>°C</code> (degrees Celsius). At any rate, for obscure historical reasons, <code>Celsius</code> was defined as an alias for <code>C</code> but the other names were not defined. If anything, I would recommend removing <code>Celsius</code>. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 01:05, 8 October 2024 (UTC) |
|||
::I started wondering if the OP was more concerned about the fact that <code>abbr=~</code> produces <code>°C [°C]</code>. That option is rarely used. Most units default to showing the name for the input (for example, <code>30 kilograms</code>). Using <code>abbr=~</code> would display <code>30 kilograms [kg]</code>). That is, it shows the symbol as well as the name. It turns out that temperature units default to showing the symbol and you have to use <code>abbr=off</code> to make them show the name. That means you cannot also use <code>abbr=~</code> so it is not possible to show the name and symbol for a temperature unit. That is not ideal but probably is not worth fixing. See [[Template talk:Convert/Archive December 2014#What happened with abbr=~ ?]] for a discussion of whether the option should be deprecated. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 02:08, 8 October 2024 (UTC) |
|||
:::WMF needs to determine your IRL identity and insure your life for $10,000,000 -- the conservative cost of hiring a staff of coders to take over maintenance of convert, should the worst happen. [[User:EEng#s|<b style="color:red;">E</b>]][[User talk:EEng#s|<b style="color:blue;">Eng</b>]] 03:24, 8 October 2024 (UTC) |
|||
::::I would take you up on that great idea if it were not for my nervousness regarding giving someone a $10,000,000 reason for me to disappear! [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 03:55, 8 October 2024 (UTC) |
|||
:::::With the right paperwork, a "reported" death and a new life in Cuba, you could have a rather nice retirement plan :) |
|||
:::::On an unrelated note, I'd completely forgotten that I had commented on this 10 years ago. But having never used it even once, I'm in favour of removing it. Is it used much? |
|||
:::::Sounds like the OP's gripe is that <code>Fahrenheit</code> and <code>kelvin</code> are valid outputs but not valid inputs. Considering we also have meters, miles, feet, inches, etc as inputs, I tend to agree with him. <span style="border:1px solid blue;border-radius:4px;color:blue;box-shadow: 3px 3px 4px grey;">[[User:Stepho-wrs|''' Stepho ''']] <span style="font-size:xx-small; vertical-align:top">[[User Talk:Stepho-wrs|talk]] </span></span> 07:08, 8 October 2024 (UTC) |
|||
:::::Gotta watch out for that template mafia. Extremely groan-worthy memeing attempt: {{syntaxhighlight|lang=wikitext|code=<nowiki>{{that's|how={{{mafia|{{{works}}}}}}}}</nowiki>}} ([https://knowyourmeme.com/memes/thats-how-mafia-works for those not getting it]) --[[User:Slowking Man|Slowking Man]] ([[User talk:Slowking Man|talk]]) 23:14, 8 October 2024 (UTC) |
|||
::Hah, not surprising (I've seen scarier corner cases in old code for sure). Wanted to be helpful mainly and ensure this was known. Certainly understand if people aren't rushing in to overhaul the template code. Would be good to document the behavior somewhere I think. Where do people think is the best place to put that? Wouldn't mind writing up a note in the docs. Thanks for the expert knowledge! {{=)}} --[[User:Slowking Man|Slowking Man]] ([[User talk:Slowking Man|talk]]) 23:14, 8 October 2024 (UTC) |
|||
|- |
|||
== Ranges of ranges of values == |
|||
|{{convert|2.01|km2|sqmi|disp=table|sortable=on}}<ref group=SK>old style note</ref> |
|||
|- |
|||
In technical plant descriptions (e.g. floras), dimensions of plant parts are often given in ranges of ranges: "5-15 x 4-8 mm". Is there a way to get <code><nowiki>{{convert}}</nowiki></code> to handle that appropriately, i.e. "5-15 x 4-8 mm (0.2-0.6 x 0.2-0.3 in)"? At the moment, <code><nowiki>{{convert|5|–|15|×|4|-|8|mm|1|abbr=on}}</nowiki></code> gives "5 mm–15 mm × 4 mm–8 mm (0.2 in–0.6 in × 0.2 in–0.3 in)", which is far too repetitive for readability. |
|||
|{{convert|2.01|km2|sqmi|disp=table|sortable=on|adj=pre|<ref group=SK>col1 note</ref>}} |
|||
|} |
|||
<code><nowiki>{{convert|5|–|15|mm|1|abbr=on}} x {{convert|4|–|8|mm|1|abbr=on}}</nowiki></code> is a little better, giving "5–15 mm (0.2–0.6 in) x 4–8 mm (0.2–0.3 in)", but that's still needlessly repetitive. <code><nowiki>{{convert|5|–|4|mm|1|abbr=on}} x {{convert|15|–|8|mm|1|abbr=on}}</nowiki></code> gives "5–4 mm (0.2–0.2 in) x 15–8 mm (0.6–0.3 in)", which is also still repetitive, and also incorrectly formatted. |
|||
''Notes:'' |
|||
<references group=SK/> |
|||
Any advice? |
|||
:::How is that? <span style="border:1px solid blue;border-radius:4px;color:blue;box-shadow: 3px 3px 4px grey;">[[User:Stepho-wrs|''' Stepho ''']] <span style="font-size:xx-small; vertical-align:top">[[User Talk:Stepho-wrs|talk]] </span></span> 02:35, 27 December 2024 (UTC) |
|||
: -- <span style="font-family:Trebuchet MS;">[[: User:Photosynthetic430|<span class="tmpl-colored-link {{#if:|mw-no-invert|}}" style="color: green ; text-decoration: inherit;">Photosynthetic430</span>]] [[: User talk:Photosynthetic430|<span class="tmpl-colored-link {{#if:|mw-no-invert|}}" style="color: #21bf21 ; text-decoration: inherit;">❧</span>]]</span> 15:37, 11 October 2024 (UTC) |
|||
:Don't sweat, convert is magic. Sorry, but no reference on the output which really should not need one. |
|||
:*<code><nowiki>{{convert|12.3<ref>A wise old man.</ref>|kg}}</nowiki></code> → {{convert|12.3<ref>A wise old man.</ref>|kg}} |
|||
::According to the documentation, <code><nowiki>|x|</nowiki></code> and <code><nowiki>|abbr=on|</nowiki></code> combine to output the unit symbol multiple times, as per [[MOS:UNITSYMBOLS]]. Replace <code><nowiki>|x|</nowiki></code> with <code><nowiki>|xx|</nowiki></code> so that <code><nowiki>{{convert|5|–|15|xx|4|-|8|mm|1|abbr=on}}</nowiki></code> outputs {{convert|5|–|15|xx|4|-|8|mm|1|abbr=on}}. Downside is that xx is deprecated and you will be violating [[MOS:UNITSYMBOLS]]. Perhaps you should raise the question of whether this format should be used at [[Wikipedia talk:Manual of Style/Dates and numbers]]. <span style="border:1px solid blue;border-radius:4px;color:blue;box-shadow: 3px 3px 4px grey;">[[User:Stepho-wrs|''' Stepho ''']] <span style="font-size:xx-small; vertical-align:top">[[User Talk:Stepho-wrs|talk]] </span></span> 15:54, 11 October 2024 (UTC) |
|||
{{reflist-talk}} |
|||
:There must be some way in which<code><nowiki>{{convert|5|–|15|×|4|-|8|mm|1|abbr=values|disp=preunit|mm|in}}</nowiki></code> giving "{{convert|5|–|15|×|4|-|8|mm|1|abbr=values|disp=preunit|mm|in}}" is risky but I haven't figured that out yet. [[User:NebY|NebY]] ([[User talk:NebY|talk]]) 16:00, 11 October 2024 (UTC) Ah - anyone using it for anything but mm would have to take care to change both "mm" - otherwise e.g. changing only the first mm to m as <code><nowiki>{{convert|5|–|15|×|4|-|8|m|1|abbr=values|disp=preunit|mm|in}}</nowiki></code> gives "{{convert|5|–|15|×|4|-|8|m|1|abbr=values|disp=preunit|mm|in}}". [[User:NebY|NebY]] ([[User talk:NebY|talk]]) 16:09, 11 October 2024 (UTC) |
|||
::Many thanks both of you. Both work well. Cheers, [[User:Hwy43|Hwy43]] ([[User talk:Hwy43|talk]]) 03:11, 27 December 2024 (UTC) |
|||
::Discussions here about [[MOS:UNITNAMES]] resulted in the situation shown above where unit symbols are duplicated. There was a fair bit of pressure to remove a workaround which I retained on the principle that a template should not prevent an editor from exercising judgment. The trick is to use <code>xx</code> instead of <code>x</code>. |
|||
::*<code><nowiki>{{convert|5|-|15|x|4|-|8|mm|1|abbr=on}}</nowiki></code> → {{convert|5|-|15|x|4|-|8|mm|1|abbr=on}} |
|||
::*<code><nowiki>{{convert|5|-|15|xx|4|-|8|mm|1|abbr=on}}</nowiki></code> → {{convert|5|-|15|xx|4|-|8|mm|1|abbr=on}} |
|||
::Note that it is better to use a letter <code>x</code> and a hyphen <code>-</code> in the input because they are easier to type and easier for others to copy. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 22:47, 11 October 2024 (UTC) |
|||
:::Thank you! That's exactly what I needed. -- <span style="font-family:Trebuchet MS;">[[: User:Photosynthetic430|<span class="tmpl-colored-link {{#if:|mw-no-invert|}}" style="color: green ; text-decoration: inherit;">Photosynthetic430</span>]] [[: User talk:Photosynthetic430|<span class="tmpl-colored-link {{#if:|mw-no-invert|}}" style="color: #21bf21 ; text-decoration: inherit;">❧</span>]]</span> 08:12, 13 October 2024 (UTC) |
|||
== Pint, half pint, one-third [of an] imperial pint == |
|||
In [[Beer festival]], are instances of pints related to the United Kingdom units of measurement (imperial pints) or just a type of beer glass?-- [[User:Carnby|Carnby]] ([[User talk:Carnby|talk]]) 17:05, 19 October 2024 (UTC) |
|||
:{{replyto|Carnby}} Why are you asking here, and not at [[Talk:Beer festival]]? This is the talk page for discussing improvements to [[Template:Convert]]. --[[User:Redrose64|<span style="color:#a80000; background:#ffeeee; text-decoration:inherit">Red</span>rose64]] 🌹 ([[User talk:Redrose64|talk]]) 21:13, 19 October 2024 (UTC) |
|||
::{{replyto|Redrose64}} My apologies, just a mistake. But there are some problems involving {{tl|convert}} as well: |
|||
::*there is an instance of the measuring unit "half pint" that I need to convert into litres and US pints; |
|||
::*using <code><nowiki>{{convert|1/3|imppt|L USpt|1|spell=in|disp=sqbr}}</nowiki></code> yields one-third imperial pint instead one-third '''of an''' imperial pint; |
|||
::*there is an instance of "tubs of cider and perry"; a tub should be about four gallons, according to the Merriam-Webster. |
|||
::--[[User:Carnby|Carnby]] ([[User talk:Carnby|talk]]) 19:38, 20 October 2024 (UTC) |
|||
:::[[Tub (unit)]] lists different weights for butter/cheese (84 lb), tea (60 lb), camphire (56-86 lb), vermillion (336-448 lb), camphor (130 Dutch lb), coal (100 lb), salt (18 imperial gallons). <span style="border:1px solid blue;border-radius:4px;color:blue;box-shadow: 3px 3px 4px grey;">[[User:Stepho-wrs|''' Stepho ''']] <span style="font-size:xx-small; vertical-align:top">[[User Talk:Stepho-wrs|talk]] </span></span> 20:50, 20 October 2024 (UTC) |
|||
::::But for cider and perry?-- [[User:Carnby|Carnby]] ([[User talk:Carnby|talk]]) 21:06, 20 October 2024 (UTC) |
|||
:::You don't have to use Convert. If it doesn't produce the English phrasing you want, you can obtain and insert the value into your phrasing in any way you want. If you'd rather use Convert than a calculator, perhaps to give other editors confidence, you can use it to give only the output value(s) and unit(s) (or even only a value), e.g. <code>one-third of an imperial pint (<nowiki>{{convert|1/3|imppt|L USpt|1|disp=out}}</nowiki>)</code> -> one-third of an imperial pint ({{convert|1/3|imppt|L USpt|1|disp=out}}). More such options are available at [[Template:Convert/doc#Displaying parts of the result: 2 (1.5)]]. [[User:NebY|NebY]] ([[User talk:NebY|talk]]) 21:29, 20 October 2024 (UTC) |
|||
== More readable fractions == |
|||
Using the fraction function such as {{convert |7 |cm |frac=8}} with some browsers results in hard-to-read small font for the integer of the conversion as well as the fraction numerals. (The only difference is a different vertical position between the integer and numerator. The input value shows correctly in regular font.) Is there a work around to make it more browser-agnostic? Or at least to add whitespace between the integer & the fraction to make the result more readable? [[Special:Contributions/71.230.16.111|71.230.16.111]] ([[User talk:71.230.16.111|talk]]) 05:45, 21 October 2024 (UTC) |
|||
:Here is a comparison with {{tl|frac}}: |
|||
:*<code><nowiki>{{convert|7|cm|frac=8|disp=number}}</nowiki></code> → {{convert|7|cm|frac=8|disp=number}} |
|||
:*<code><nowiki>{{frac|2|3|4}}</nowiki></code> → {{frac|2|3|4}} |
|||
:Using [[Special:ExpandTemplates]] shows the outputs are identical (except that {{tl|frac}} has a self-closing templatestyles). The place to discuss this might be [[Template talk:Fraction]] or [[WP:VPT]]. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 07:13, 21 October 2024 (UTC) |
|||
::I'll take it to [[template talk:fraction]]. The obvious solution is to insert a [[narrow non-breaking space]]. [[User:JMF|𝕁𝕄𝔽]] ([[User talk:JMF|talk]]) 10:12, 21 October 2024 (UTC) |
|||
:::Thanks but for posterity I will mention that the identical output from convert and fraction consists of some magic span tags that separate the numbers (2, 3, 4 in the above fractions). The action takes place in [[Template:Fraction/styles.css]]. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 10:42, 21 October 2024 (UTC) |
|||
== Plans for new version == |
|||
I am slowly planning a new version of the module. This is mainly a result of a discussion at the Ukrainian Wikipedia regarding a bug in the way variable names are handled. Languages such as Ukrainian have more than one plural form for a unit name. Some examples are at [[:uk:User:Johnuniq/convert]] with discussion at its talk. |
|||
I also want to clean up some minor issues: |
|||
* Units <code>mile</code> and <code>miles</code> will set abbr=off for that unit. That means <code><nowiki>{{convert|4|km|miles}}</nowiki></code> would display "4 kilometres (2.5 miles)" rather than the current "4 kilometres (2.5 mi)". This was mentioned in [[Template talk:Convert/Archive 2#Proposal: unit miles will always output "miles"|June 2021]]. |
|||
* Think about whether any other aliases should similarly set abbr=off. I would probably leave that for another time as it is only mile/miles that I have noticed being a problem with a result of "mi" when the editor went to the trouble of typing "miles". |
|||
* Want a fix for <code><nowiki>{{convert|10|e6kg|e6lb|abbr=unit}}</nowiki></code> so result can be "10 million kg (22 million pounds)" rather than the current "10 million kg (22 million lb)". |
|||
* Perhaps add an alias for <code>abbr=~</code> (maybe <code>adj=~</code>?) to avoid the problem mentioned [[#Possible bug report re: temperature units|above]]. That would allow <code><nowiki>{{convert|1|C|K|abbr=off|adj=~}}</nowiki></code> to display "1 degree Celsius [°C] (274 kelvins)". |
|||
The <code>abbr=unit</code> issue has been raised several times. The problem is that <code>abbr=off</code> results in "million kilograms" while <code>abbr=on</code> gives the unappealing "10<span style="margin-left:0.2em">×<span style="margin-left:0.1em">10</span></span><s style="display:none">^</s><sup>6</sup> kg". Using <code>abbr=unit</code> means the units will be abbreviated (kg and lb) while ''million'' will not. |
|||
I haven't been able to think of a clean way to specify that ''million'' should be spelled but I am currently wondering whether this trick would be ok: |
|||
*<code>e6lb</code> would work as it does now (million or engineering notation depending on <code>abbr</code>). |
|||
*<code>E6lb</code> would give million (never engineering notation). |
|||
Thoughts? Any clean alternative syntax? [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 23:34, 21 October 2024 (UTC) |
|||
:Here's a couple ideas on expanding abbr options: |
|||
:# Concatenate the options with a delimiter: <nowiki>{{convert|10|e6kg|e6lb|abbr=innum;inunit;outnum;outunit}}</nowiki> would be equivalent to abbr=on. Using a subset of the options would allow fine-tuning the output. |
|||
:# Add parameters abbrin, abbrout, which allow on, off, unit, num. |
|||
:[[User:Indefatigable|Indefatigable]] ([[User talk:Indefatigable|talk]]) 21:21, 25 October 2024 (UTC) |
|||
::Thanks, they are good ideas. However, I think I'll go with the simple although obscure E6lb. That is a small extra thing for editors to recall as compared with four new keywords. No matter how convert handles it, people will have difficulty knowing what to do and will have to ask or study the long documentation. An implementation difficulty is that I want to continue supporting other languages and the current translation system would need very large changes to accommodate delimited options. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 01:24, 26 October 2024 (UTC) |
|||
== Module version 30 == |
|||
Some changes to the convert modules are in the sandbox and I intend switching the main modules to use the sandbox soon. |
|||
{{#invoke:convert/tester|compare}} |
|||
*Option <code>adj=~</code> is an alias for <code>abbr=~</code> so either may be used to display the input name and symbol. |
|||
**<code><nowiki>{{convert|1|C|K|abbr=off|adj=~}}</nowiki></code> → 1 degree Celsius [°C] (274 kelvins) |
|||
*Option <code>link=...</code> is an alias for <code>lk=...</code> so either may be used to control whether units are linked. |
|||
**<code><nowiki>{{convert|12.3|kn|link=in}}</nowiki></code> → 12.3 [[Knot (unit)|knots]] (22.8 km/h; 14.2 mph) |
|||
*Units can be entered with an engineering factor using "e" or "E", for example, <code>e3km</code> or <code>E3km</code>. Using uppercase <code>E3km</code> displays the factor as a word ("thousand") rather than as <span style="margin-left:0.2em">×<span style="margin-left:0.1em">10</span></span><sup>3</sup>. Using lowercase <code>e3km</code> continues to display the word if <code>abbr=unit</code> is used, or if <code>abbr=off</code> applies to the unit. |
|||
**<code><nowiki>{{convert|10|e3mi|e3km}}</nowiki></code> → 10 thousand miles (16<span style="margin-left:0.2em">×<span style="margin-left:0.1em">10</span></span><s style="display:none">^</s><sup>3</sup> km) |
|||
**<code><nowiki>{{convert|10|e3mi|E3km}}</nowiki></code> → 10 thousand miles (16 thousand km) |
|||
**<code><nowiki>{{convert|10|E6kg|E6lb|abbr=in}}</nowiki></code> → 10 million kg (22 million pounds) |
|||
*For ukwiki (and others), function <code>variable_name</code> has been enhanced to use <code>mw.language.getContentLanguage():convertPlural</code> rather than the inadequate home-grown code that was developed for slwiki in 2014. In addition a bug fix to prevent duplication of the local language's equivalent of "kilo" was implemented. See [[:uk:User:Johnuniq/convert]] and its talk. |
|||
*For ukwiki, a unit can have a pername that will be used if the unit is the second in a "per". For example, the definition for <code>mi</code> can include the names that it normally has, as well as a pername that would be used in a per unit such as <code>$/mi</code>. |
|||
*For ukwiki, the <code>eng_scales</code> table in [[Module:Convert/text]] has been enhanced to allow variable names for factors such as "kilo" that depend on the value. |
|||
*Units <code>mile</code> and <code>miles</code> set <code>abbr=off</code>. |
|||
**<code><nowiki>{{convert|4|km|mi}}</nowiki></code> → 4 kilometres (2.5 mi) |
|||
**<code><nowiki>{{convert|4|km|miles}}</nowiki></code> → 4 kilometres (2.5 miles) |
|||
*[[Module:Convert/makeunits]] |
|||
**The definition for an alias accepts <code>abbr=off</code> to force use of the unit name, not symbol. |
|||
**Unit definitions can include a pername. |
|||
The above examples use fixed wikitext so the outputs won't change in the future. |
|||
For posterity, I will record that [[Module:Convert/extra]] has had unit <code>bit</code> since August 2022. It also had <code>byte</code> but I removed it as it was unused and had a small error, and was not supported in [[Template talk:Convert/Archive 2#Bits and bytes|October 2020]] or in [[Template talk:Convert/Archive 3#Bits and bytes|April 2023]]. Unit <code>bit</code> has a good use in [[Patterned media]] so I intend to keep it. Normally, I would move extra units to the main data module but there would have to be another unit (byte) to be the default output for bit. Therefore, I'm just leaving bit as an extra unit for consideration another time. |
|||
There is a little more information at [[#Plans for new version]] above. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 05:35, 23 October 2024 (UTC) |
|||
:Excellent. I'm looking forward to the miles treatment. <span style="border:1px solid blue;border-radius:4px;color:blue;box-shadow: 3px 3px 4px grey;">[[User:Stepho-wrs|''' Stepho ''']] <span style="font-size:xx-small; vertical-align:top">[[User Talk:Stepho-wrs|talk]] </span></span> 23:52, 25 October 2024 (UTC) |
Revision as of 03:11, 27 December 2024
|
Template:Convert is permanently protected from editing because it is a heavily used or highly visible template. 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 an administrator or template editor to make the requested edit. Usually, any contributor may edit the template's documentation to add usage notes or categories.
Any contributor may edit the template's sandbox. Functionality of the template can be checked using test cases. |
|
|||
This page has archives. Sections older than 42 days may be automatically archived by Lowercase sigmabot III when more than 2 sections are present. |
Related pages |
---|
Indian numbering system: lakhs and crores
- Moved from Module talk:Convert. Johnuniq (talk) 01:45, 19 November 2024 (UTC)
I request that we enhance the module to include lakhs and crores.
The Indian numbering system is the main nomenclature used in South Asia to name large numbers. From the lead:
- The terms lakh or 1,00,000 (one hundred thousand, written as 100,000 in Pakistan, and outside the Indian subcontinent) and crore or 1,00,00,000 (ten million, written as 10,000,000 outside the subcontinent) are the most commonly used terms in Indian English to express large numbers in the system.
This is a dimensionless unit, or if you wish, the units are integers. (Hence if implemented, the data item in 'all_units' at Module:Convert/data could be named ["ins"]
for 'Indian numbering system'). Note also the main pattern of comma-separation into groups of two and three digits, not just three.
These terms should be converted to standard English terms, mostly with the term million, except for values up to 9 lakh, which could be 900,000. Sample usage in articles:
- lakh – 6,914 articles
- crore – 10,809 articles
The plural sometimes has the -s, and sometimes doesn't; so both '2 lakhs' and '2 lahk' are seen; same for crore(s).
This arose at the Rfc at Wikipedia talk:Manual of Style/Dates and numbers, where in my !vote (diff) I called for using template {{Convert}}, only to realize after the fact that the template will not handle it. This conversion is badly needed, as it will resolve a sore point about usage of lakhs and crores in many articles. Thanks, Mathglot (talk) 23:46, 18 November 2024 (UTC)
- Earlier discussions.
- I have not yet examined the RfC at WT:Manual of Style/Dates and numbers#RfC Indian numbering conventions. The above discussions point out that lakh and crore are not units. They are like million which is also not a unit. However, if convert could do something useful that is not provided by {{lakh}} and {{crore}}, it could be investigated. Johnuniq (talk) 02:03, 19 November 2024 (UTC)
Nautical miles to Kilometers
It is NOT accurate! 8000 nmi = 14,816 km not 15000. Check google & ref64 Bombardier Global 7500. The correct multiplier is 1.852 not 1.875 see ref 1 Nautical mile & for at least half a century (ref 5). Dave-okanagan (talk) 04:18, 17 December 2024 (UTC)
- The template sees 3 zeroes at the end and assumes that is the amount of rounding desired. Ie 8000 nmi +/- 500 nmi. It is not assuming 8000 nmi +/- 0.5 nmi. Therefore it rounds the output to a similar amount.
- However, you can control the rounding. Eg:
{{cvt|8000|nmi|km|0}}
gives 8,000 nmi (14,816 km) (probably not appropriate if the 8000 is a round number){{cvt|8000|nmi|km|-1}}
gives 8,000 nmi (14,820 km){{cvt|8000|nmi|km|-2}}
gives 8,000 nmi (14,800 km){{cvt|8000|nmi|km|-3}}
gives 8,000 nmi (15,000 km) (probably the most appropriate if the 8000 is a round number)
- Choose whichever suits the situation best. Be careful of false precision. Stepho talk 04:56, 17 December 2024 (UTC)
- @Dave-okanagan: this is discussed in the first FAQ at the top of the page as well. Imzadi 1979 → 05:41, 17 December 2024 (UTC)
Suffix parameters for first and second numbers
Can we please get suf1 and suff2 parameters added to this template, like done at Template:Change, so that we can add references or notes to the first and second numbers in the template, respectively? Cheers, Hwy43 (talk) 20:10, 26 December 2024 (UTC)
- The purpose of convert is to take a single number and convert it into the equivalent in different units of measurement. All numbers displayed come from that single input. So why would we need a second reference?
- Likewise, why would we have different notes for each unit of measurement? Surely a single reference and/or note cover all the units used. Can you give an example? Stepho talk 23:42, 26 December 2024 (UTC)
- Good point re: single input. Rather, a suffix parameter is desired just for after the first number because it is the one that can be sourced, whereas the second is a product of the template. Same with notes being based on the first number. See the Flin Flon and Lloydminster rows at List of cities in Saskatchewan#List. In those two cases, I want the notes to be displayed after the first number, not after the second (conversion) number as currently shown. Cheers, Hwy43 (talk) 00:29, 27 December 2024 (UTC)
- Fair enough, this only applies to tables. The
|pre=
option (with the ref as the next field) can be twisted into doing what you want.{{convert|2.01|km2|sqmi|disp=table|sortable=on|adj=pre|<ref group=SK>col1 note</ref>}}
gives:
- Fair enough, this only applies to tables. The
Column1 km2 | Column2 miles2 |
---|---|
2.01 | 0.78[SK 1] |
2.01 [SK 2] | 0.78 |
Notes:
- How is that? Stepho talk 02:35, 27 December 2024 (UTC)
- Don't sweat, convert is magic. Sorry, but no reference on the output which really should not need one.
{{convert|12.3<ref>A wise old man.</ref>|kg}}
→ 12.3[1] kilograms (27 lb)
References
- ^ A wise old man.
- Many thanks both of you. Both work well. Cheers, Hwy43 (talk) 03:11, 27 December 2024 (UTC)