Template talk:Convert: Difference between revisions
→Suffix parameters for first and second numbers: reply to both |
|||
(14 intermediate revisions by 6 users not shown) | |||
Line 21: | Line 21: | ||
| caption2 = ... and in reality |
| caption2 = ... and in reality |
||
}} |
}} |
||
== A new double conversion == |
|||
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) |
|||
:{{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) |
|||
== Possible bug report re: temperature units == |
|||
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>}} |
|||
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}} |
|||
Semi-expected output:{{br}} |
|||
1: 1 kelvin [K]{{br}} |
|||
2: 1 degree Celsius [°C]{{br}} |
|||
3 & 4: N/A, working{{br}} |
|||
5: 1 degree Celsius [°C]{{br}} |
|||
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 {{;)}}) |
|||
Contrasted:{{Br}} |
|||
{{Convert|1|in|ft cm|abbr=~}}{{br}} |
|||
{{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 == |
|||
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. |
|||
<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. |
|||
Any advice? |
|||
: -- <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) |
|||
::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) |
|||
: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) |
|||
::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) |
|||
:This version is now live. {{ping|Slowking Man}} <code><nowiki>{convert|1|C|K|abbr=off|adj=~}}</nowiki></code> now works (example above). [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 23:18, 26 October 2024 (UTC) |
|||
::I suppose it's a coincidence that the power just went out in a 10-mile radius around me? [[User:EEng#s|<b style="color:red;">E</b>]][[User talk:EEng#s|<b style="color:blue;">Eng</b>]] 00:39, 27 October 2024 (UTC) |
|||
:::👍 Best feature - ever! <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> 00:51, 27 October 2024 (UTC) |
|||
::::Hey EEng, I'm disappointed. You mean a {{convert|10|mile|adj=on}} radius. Anyway, I'm glad you noticed. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 02:42, 27 October 2024 (UTC) |
|||
::::A 10-mile radius centred exactly on you? Spoookyy... --[[User:Redrose64|<span style="color:#a80000; background:#ffeeee; text-decoration:inherit">Red</span>rose64]] 🌹 ([[User talk:Redrose64|talk]]) 08:19, 27 October 2024 (UTC) |
|||
== Multiple values, shorter abbreviation? == |
|||
Is it possible to display a shorter version than |
|||
:{{tlc|convert|149.6x71.5x8.25|2|mm|2}} |
|||
:{{convert|149.6x71.5x8.25|mm|2}} |
|||
Or? |
|||
:{{tlc|convert|149.6x71.5x8.25|mm|2|5=abbr=on}} |
|||
:{{convert|149.6x71.5x8.25|mm|2|abbr=on}} |
|||
In some infoboxes (eg, {{tl|Infobox mobile phone}}), where space is limited, it is desired to list the dimensions of some object, and its conversion, but it seems unnecessary to list the “mm” and the “in” three times. I might be missing something, but I would like an option to display something like: |
|||
:149.6 × 71.5 × 8.25 mm (5.89 × 2.82 × 0.32 in) |
|||
<span style="font-family:Avenir, sans-serif">— <span style="border-radius:5px;padding:.1em .4em;background:#faeded">[[User:HTGS|HTGS]]</span> ([[User talk:HTGS|talk]])</span> 23:14, 6 November 2024 (UTC) |
|||
:Use <code>xx</code> instead of <code>x</code>. |
|||
:{{tlc|convert|149.6xx71.5xx8.25|mm|2|abbr=on}} gives {{convert|149.6xx71.5xx8.25|mm|2|abbr=on}} |
|||
:Beware that this technically violates [[MOS:UNITSYMBOLS]]. <code>|by|</code> is an option that obeys the MOS (but looks clumsier). |
|||
:{{tlc|convert|149.6|by|71.5|by|8.25|mm|2|abbr=on}} gives {{convert|149.6|by|71.5|by|8.25|mm|2|abbr=on}} <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:49, 6 November 2024 (UTC) |
|||
::Thank you! I might actually ask at MOSNUM, because this feels like an oversight (for use in small spaces), and I’d like to standardise this across a lot of infoboxes. <span style="font-family:Avenir, sans-serif">— <span style="border-radius:5px;padding:.1em .4em;background:#faeded">[[User:HTGS|HTGS]]</span> ([[User talk:HTGS|talk]])</span> 00:06, 7 November 2024 (UTC) |
|||
==Troy weight== |
|||
I'm not sure if this is the right place to discuss this, but is it possible to integrate [[troy weight]] into this template? Basically another obscure, antiquated unit of mass that still sticks around out of tradition in the precious metals industry. <b>[[User:TheTechnician27|<span style="color: #00a9ff"><i>TheTechnician27</i></span>]]</b> [[User talk:TheTechnician27|<span style="color: blue">(Talk page)</span>]] 12:23, 10 November 2024 (UTC) |
|||
:{{replyto|TheTechnician27}} It's already provided, e.g. {{tlx|convert|1|ozt|g|3}} → {{convert|1|ozt|g|3}}. See [[Template:Convert/list of units/mass|full list of mass units]]. --[[User:Redrose64|<span style="color:#a80000; background:#ffeeee; text-decoration:inherit">Red</span>rose64]] 🌹 ([[User talk:Redrose64|talk]]) 15:48, 10 November 2024 (UTC) |
|||
::{{re|Redrose64}} Oooh, thank you! I was trying to use 'oz t' with no success. <b>[[User:TheTechnician27|<span style="color: #00a9ff"><i>TheTechnician27</i></span>]]</b> [[User talk:TheTechnician27|<span style="color: blue">(Talk page)</span>]] 17:26, 10 November 2024 (UTC) |
|||
== Indian numbering system: lakhs and crores == |
== Indian numbering system: lakhs and crores == |
||
Line 213: | Line 43: | ||
:*[[Template talk:Convert/Archive 3#Lakh and 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) |
: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) |
|||
== 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). [[User:Dave-okanagan|Dave-okanagan]] ([[User talk: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: |
|||
:*<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 == |
|||
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) |
|||
: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? <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) |
|||
::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) |
|||
:::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: |
|||
{|class="wikitable" |
|||
!Column1 km<sup>2</sup> |
|||
!Column2 miles<sup>2</sup> |
|||
|- |
|||
|{{convert|2.01|km2|sqmi|disp=table|sortable=on}}<ref group=SK>old style note</ref> |
|||
|- |
|||
|{{convert|2.01|km2|sqmi|disp=table|sortable=on|adj=pre|<ref group=SK>col1 note</ref>}} |
|||
|} |
|||
''Notes:'' |
|||
<references group=SK/> |
|||
:::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) |
|||
: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}} |
|||
{{reflist-talk}} |
|||
::Many thanks both of you. Both work well. Cheers, [[User:Hwy43|Hwy43]] ([[User talk:Hwy43|talk]]) 03:11, 27 December 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)