Template talk:Convert/Archive August 2017

Section on spelling of unit name
The section Template:Convert is misleading (or at least seriously incomplete). Spellings such as "metre" or "litre" are not just en-UK, they are the correct SI spellings. It happens that en-UK, like many other variants of English, uses the correct spelling of SI units, unlike en-US. I attempted to correct this, but was reverted. I don't care about the exact wording, but I do care that editors are told that the default spelling for SI units is the SI spelling, not specifically en-UK. The section title should be "Spelling of unit name: SI metre or US meter?". Peter coxhead (talk) 21:04, 21 August 2017 (UTC)


 * ISO and CGPM are not the ultimate arbiters of US English spelling, even for the units that they standardize. Kendall-K1 (talk) 21:10, 21 August 2017 (UTC)


 * My understanding is that only the symbols are standardized in all languages. When units are spelled out, the spelling varies from language to language. Jc3s5h (talk) 21:32, 21 August 2017 (UTC)


 * (ec) I did the revert . First of all, the option US is not to allow "follow SI spelling" versus "deviate from SI spelling". It is to allow an article to be consistently written in en-UK or in en-US language, both inside and outside of . This is an WP:ENGVAR policy. The documentation text reflects this by showing "UK" and "US" next to each other. Which one is SI is not relevant for this.
 * Secondly, I doubt whether SI prescibes (defines) words in one of the spellings (eg, en-UK metre as Peter coxhead states). First of all, in general there might be units not in SI at all that take variant spellings. These too would be set using sp, clearly without any SI definition at all (because of this parameter generality, I don't see a need to supply examples). Second, SI does not define the name of a unit . It just uses an English name (and a French name). While OTOH, the symbol is strictly prescibed, including capitalisation, roman/italic?, font variants allowed?, etc. (to compare, the name's formatting & writing is governed by grammar and editorial style like typefont freedom!, pluralisation). A name can also be in Russian/Cyrillic, a symbol does not change. In short: SI does not interfere with language (names), and concentrates on the algebraic format of quantity values (measurements), numbers & unit symbols.
 * ISO/IEC 80000 says (7.2.1; bolding added): The rule for writing unit symbols with a capital initial is not applicable for unit names, which differ from language to language. For this issue, I dare saying that en-UK and en-US may be considered different languages.


 * TL;DR: The option that US/UK introduces is to support WP:ENGVAR per article. SI does prescribe symbol writing, not name writing (which is guided by language, grammar, editorial style, and then ENGVAR style). Unit names are language-dependent, and en-UK vs. en-US may be considered different languages in this issue. Omitting SI name-writing in this section is not "misleading" nor "seriously incomplete". SI is not relevant in there. -DePiep (talk) 22:25, 21 August 2017 (UTC)

Module version 19
Some changes to the convert modules are in the sandbox, and I intend switching the main modules to use the sandbox soon.

The examples use fixed wikitext for the output to show what the new version would produce so they will not change in the future.

Release notes for earlier versions are listed here. My motivation for adding the new chain units was that during the earlier discussion I had a feeling that convert had a method to always link a unit, and which would not double-link the unit with. I found the method and thought it worth trying. Johnuniq (talk) 05:57, 15 August 2017 (UTC)
 * Units
 * Add unit  (rutherford) as it was added to Module:Convert/extra and is used in articles. Discussed here.
 * → 12,300 rutherfords (12,300 megabecquerels)
 * → 12,300 Rd (12,300 MBq)
 * Add unit  (chain) which is always linked (use   for chain with no link); with abbr=on, "ch" is displayed. Discussed here.
 * Add unit  (chain) which is always linked (use   for chain with no link); with abbr=on, "chain" is displayed.
 * Add units  and   which can be used as output units to display miles and chains, where "chains" is linked.
 * Units  and   can be used as combination input units with miles.
 * → 12.3 kilometres (610 ch)
 * → 12.3 kilometres (610 chains)
 * → 50 miles 49 chains (81.5 km)
 * → 50 miles 49 chains (81.5 km)
 * → 3,652 yards (2 mi 6.0 ch)
 * → 3,652 yards (2 miles 6.0 chains)
 * → 3,652 yards (2 mi 6.0 chain)
 * Errors can be detected
 * Error messages include  so   can detect when convert generates an error. Discussed here.
 * input=...
 * As a special case for infoboxes, a length can be specified in feet and inches. When valid input is given, a conversion occurs. Otherwise, the output is a copy of the input. Discussed here.
 * → 5 feet 10 1&frasl;2 inches (1.791 m)
 * → five ft ten in
 * A new  parameter can be used to track articles using convert with   where the input was not interpreted by convert. The category is Category:Convert tracking and the   parameter specifies the category sort key.
 * → five ft ten in
 * So when "input was not interpreted by convert" category Category:Convert tracking is added. Is this also an #iserror status? And, more in general, is each and every 'warning/issue' situation classified as error? (Would be irrespective of categories and[maintenance tag] addings I understand) -DePiep (talk) 18:52, 16 August 2017 (UTC)
 * No, "input was not interpreted by convert" is not regarded as an error. That is the fundamental point of, namely that it can be used in an infobox and it will never be an error—it will either work or will show the input as given. An exception is that if a Wikidata property like   is used, an error fetching the property causes convert to display nothing, and it is not an error. That allows an infobox to display a property if it exists for the current page, but to show nothing if it doesn't.
 * The tracking category allows a template designer to choose to add a tracking category if convert fails to interpret the input.
 * Whenever convert shows a warning or error,  is used in the message and #iferror will detect it. Examples:
 * → 1.5 m
 * → 1.5 m
 * Johnuniq (talk) 01:31, 17 August 2017 (UTC)
 * Johnuniq (talk) 01:31, 17 August 2017 (UTC)
 * Johnuniq (talk) 01:31, 17 August 2017 (UTC)


 * The new version is now live. Johnuniq (talk) 01:48, 17 August 2017 (UTC)
 * Topics input, tracking,  might need some documentation. All are more relevant for template-editors, not article-editors. -DePiep (talk) 22:31, 21 August 2017 (UTC)

Something has been left out
To abbreviate both:
 * → 1 lb
 * → 1 lb

There should be a "To spell out both:" header between these two lines of code. --Khajidha (talk) 16:46, 23 August 2017 (UTC)
 * Thanks. That refers to Template:Convert/doc. I'm hoping someone will check that. Johnuniq (talk) 01:47, 24 August 2017 (UTC)

Displaying a formatted value?
Is there a way that this template could be used to show (fetched from Wikidata) as 56°18', without including any conversion factors? Or is there another template that could do that? Thanks. Mike Peel (talk) 01:27, 11 August 2017 (UTC)


 * This was discussed at Template talk:Convert/Archive September 2015 but didn't go anywhere. Can you give us some examples of where this would be useful? Kendall-K1 (talk) 02:13, 11 August 2017 (UTC)
 * I do not know of any such templates although I have recently been patching some modules at bnwiki and noticed some code that deals with such things. Rather than further complicate their enwiki equivalents, it might be better to add something to val which would need code similar to convert's to access Wikidata (or call it), and code to convert a decimal angle to DM or DMS and display it. I would prefer that rather than adding more gumph to convert. I can guess what you're up to, but per Kendall-K1, please give a couple of examples to focus my mind. Johnuniq (talk) 04:15, 11 August 2017 (UTC)
 * The motivation for my request is the 'slope' parameter in the infobox at Pyramid of Unas, where spelling out 'degrees' doesn't look great, and the other articles that use Infobox pyramid (which I'm currently converting to use Wikidata). Another example I just came across where this is useful is from lvwiki, where they only use metric units, so for infoboxes ported there it would be useful to still keep the formatting that convert shows but not to do the conversion from metric to imperial. Thanks. Mike Peel (talk) 10:54, 11 August 2017 (UTC)
 * That has typical Wikidata nonsense where anything can be used in a field: has 0.1272±0 for  whereas  has 56.3 degree. It will be a few days before I can think about this.
 * For lvwiki, it may be possible to provide convert modules with the units removed, then rely on defining units in Module:Convert/wikidata/data such as is done for things like:  → undefined undefined Johnuniq (talk) 11:15, 11 August 2017 (UTC)
 * I couldn't find the right property on Wikidata, so I slightly misused an existing one as a temporary measure, sorry. ;-) I've already proposed a new property to use for angles, at d:Wikidata:Property proposal/angle, hopefully that will be implemented soon and I can use that more consistently. Thanks. Mike Peel (talk) 11:43, 11 August 2017 (UTC)
 * My snark was directed at the underlying design which puts all the work and responsibility of interpreting results in each of the hundred modules that try to access Wikidata, in each of the hundred Wikipedias that use it. Sorry if it looked like I was being pointy about an editor! Johnuniq (talk) 23:42, 11 August 2017 (UTC)
 * Hear, hear. I can add: Wikidata is available to outside websites too. (Anyone can read WD data and show it). That means those interpretations are outside of any Wiki control even. Meanwhile, we can not add the iconic standard atomic weight as a, nor specify it unambiguously otherwise. -DePiep (talk) 09:27, 12 August 2017 (UTC)
 * No worries, I just want to get things to work right. Interpretation is always subjective, and Wikidata does just present the facts rather than the context, but that's both a pro and a con. Have you seen the constraints on property values that try to keep the values they contain consistent with each other? I think there's a background to the atomic weight point that I'm not aware of? Thanks. Mike Peel (talk) 22:37, 13 August 2017 (UTC)


 * I mentioned the atomic weight only to illustrate the Wikidata issue Johnuniq mentioned, outside of the question you asked. That said, this is not about 'context' that Wikidata does not include. Wikidata omits (essential) properties of its data. -DePiep (talk) 18:56, 16 August 2017 (UTC)
 * Aah, I see that atomic weights are complicated... Thanks. Mike Peel (talk) 21:42, 16 August 2017 (UTC)

As a thought with the metric-only measurements, maybe the converted value could be hidden if the input and output units are the same. E.g. km undefined at South Pole Telescope currently returns "2.8 km (2.8 km)", maybe it could just return "2.8 km" in that case. I think that would also work OK on other language Wikipedias. Thanks. Mike Peel (talk) 00:38, 29 August 2017 (UTC)
 * That is a problem. I put it at the top of my convert to-do. Johnuniq (talk) 00:55, 29 August 2017 (UTC)
 * Thank you. Mike Peel (talk) 00:57, 29 August 2017 (UTC)

input = value1 value2 ftin
I have updated the sandbox to test the proposal to allow  with. There is also a new  parameter to append a tracking category with sort key   if 'input=...' does not result in a conversion. can be any non-empty text. In that case, Category:Convert tracking is appended, but only in articles. I will create the category if we agree it is useful. Examples:
 * Update: I substituted the  examples because I'm planning to replace that with something possibly better. That is,   will not work. See below. Johnuniq (talk) 05:55, 30 July 2017 (UTC)
 * → 5 feet 9 1&frasl;2 inches (1.765 m)
 * → 5 ft 9 1&frasl;2 in (176.5 cm)
 * → 2 feet 6 inches (30 inches)
 * → 5 9½ ftin
 * → 5 9½ ftin )
 * The third example shows that  is translated to a space. Multiple spaces are the same as a single space.
 * The 5 V example would make more sense if the input were from a Wikidata property.
 * The third example shows that  is translated to a space. Multiple spaces are the same as a single space.
 * The 5 V example would make more sense if the input were from a Wikidata property.

This needs to be tested to see if it works and is useful. I also need to slowly check the changes I made because it's a bit rushed at the moment. Johnuniq (talk) 09:43, 29 July 2017 (UTC)
 * Looks great, a fine setup. Will be testing later on. Initial question:
 * With fractions, requires a "+" be added. However, this is not the RL formatting. Since we can expect fractions in the sources correctly being used as "9 1/2" (/ or &frasl;), it would be great if this input format adds that "+" sign internally. The other option is to pre-process the input value, or by documentation add the requirement (or outlawing fractions). -DePiep (talk) 11:39, 29 July 2017 (UTC)
 * I plan to put that in another module. I will probably use Module:Biglist to experiment. We can later decide whether it is useful, and where to put it. I'm still not sure people will want conversions in that template, but we'll see. Johnuniq (talk) 06:04, 30 July 2017 (UTC)
 * OK. Other preprocessing (= edit input in MyTemplate before entering it into this option): what if ft is 0 or blank? in is 0 or blank? However, this is easy to check and/or can be outlawed in MyTemplate documentation (when not realistic situations). Just mentioning this in case you're interested.
 * wrt Template:NFL predraft: When the current layout changes are accepted & live, I'll testcase and promote the adding, using this new option. BTW, the option could also simplify & enhance Convinfobox. -DePiep (talk) 09:44, 30 July 2017 (UTC)

New plan It occurred to me that there is no need to use a fake  because it is just as easy for the extra code to process separate   and. I assume this is better and I should forget about the earlier ? Johnuniq (talk) 05:55, 30 July 2017 (UTC)
 * Yes. -DePiep (talk) 09:44, 30 July 2017 (UTC)

Preprocess fraction input
I have done a quick experiment for a preprocessor to pass parameters to convert. I parked it in Module:Biglist but it can be moved later if needed. I have not tried it apart from what follows and I expect it will need tweaking. Johnuniq (talk) 11:10, 30 July 2017 (UTC)
 * Update: I replaced  with   in the following so I can remove the temporary experiment from Module:Biglist. Johnuniq (talk) 10:12, 8 August 2017 (UTC)
 * Allow me:


 * Input like "½" as a character is not expected from keyboard, but might occur by: copy-pasting, accepted usage in article titles, other lang-wikis (where it might be accepted in text).
 * Input like "½" as a character is not expected from keyboard, but might occur by: copy-pasting, accepted usage in article titles, other lang-wikis (where it might be accepted in text).
 * Input like "½" as a character is not expected from keyboard, but might occur by: copy-pasting, accepted usage in article titles, other lang-wikis (where it might be accepted in text).
 * Input like "½" as a character is not expected from keyboard, but might occur by: copy-pasting, accepted usage in article titles, other lang-wikis (where it might be accepted in text).
 * Input like "½" as a character is not expected from keyboard, but might occur by: copy-pasting, accepted usage in article titles, other lang-wikis (where it might be accepted in text).
 * Input like "½" as a character is not expected from keyboard, but might occur by: copy-pasting, accepted usage in article titles, other lang-wikis (where it might be accepted in text).
 * Input like "½" as a character is not expected from keyboard, but might occur by: copy-pasting, accepted usage in article titles, other lang-wikis (where it might be accepted in text).
 * Input like "½" as a character is not expected from keyboard, but might occur by: copy-pasting, accepted usage in article titles, other lang-wikis (where it might be accepted in text).
 * Input like "½" as a character is not expected from keyboard, but might occur by: copy-pasting, accepted usage in article titles, other lang-wikis (where it might be accepted in text).
 * Input like "½" as a character is not expected from keyboard, but might occur by: copy-pasting, accepted usage in article titles, other lang-wikis (where it might be accepted in text).
 * Input like "½" as a character is not expected from keyboard, but might occur by: copy-pasting, accepted usage in article titles, other lang-wikis (where it might be accepted in text).




 * -DePiep (talk) 12:43, 30 July 2017 (UTC)
 * Thanks for the testcases. I fixed some problems. I agree with "not expected" but articles use fractions, for example Eric Berry has "height in = 11⅝". Johnuniq (talk) 23:05, 30 July 2017 (UTC)
 * Yes it's good these are covered. It all looks good & smart. BTW, how is module:Biglist a logical place to add this?  And, maybe "preprocess" is too generic, while it is quite specific: "normaliseInputForConvertWhenFractionsAreUsed" or so. -DePiep (talk) 10:51, 31 July 2017 (UTC)
 * I've added two testcases (bare ½, ⅞), late, to the list. They test OK. -DePiep (talk) 21:28, 31 July 2017 (UTC)
 * When a sandbox NFL template has been accepted, or at least not rejected, we can work out the details. Do you have a suggestion about where preprocess could go, or what better name could be used? Self-explanatory names are good, but normaliseInputForConvertWhenFractionsAreUsed is too long. There could be a Module:Convert/helper which was not used by the main module but which held functions related to convert, starting with preprocess. Or, I was thinking of Module:Sport at one time when I noticed some very convoluted templates causing articles to run into template limits. I forget where that was, but I could find it in a tracking category. Johnuniq (talk) 02:30, 1 August 2017 (UTC)
 * I was doing some computer clean-up and noticed something that made me think the article that might need Module:Sport is List of Olympic medalists in athletics (men). That's not relevant here, but I'm noting it for my future reference. Johnuniq (talk) 04:39, 1 August 2017 (UTC)
 * If you find module:Convert/helper acceptable, that's OK then. Function then could be named "formatfrac" or "normalisefrac". Name "preprocess" might be too generic (later other preprocess jobs could be added). -DePiep (talk) 10:22, 1 August 2017 (UTC)
 * What about just "number" or "fraction" which would make sense in ? Johnuniq (talk) 10:55, 1 August 2017 (UTC)
 * I myself would add a hint to the formatting/normalisation process (a verb). But go as you think best, too much detail. -DePiep (talk) 11:15, 1 August 2017 (UTC)
 * OK, in 24 hours should do. Let's not debate the name much more but to explain my opinion, there is no simple phrase that would describe the function, so just using an English word related to the function makes it easy to remember and use. For example, formatfrac suggests an equivalent of frac, and normalisefrac might suggest reducing $12 3/8$ to $12 3/8$. Johnuniq (talk) 11:28, 1 August 2017 (UTC)
 * module:Convert/helper name is good. I'll see what happens and then adjust the sandbox into the new name. I'm off for now. btw, could you check &rarr;  (expect 12+3/8 right? was OK above). -DePiep (talk) 11:53, 1 August 2017 (UTC)
 * That was a blunder which I have now fixed, thanks. My comment at 11:10, 30 July 2017 above shows I thought it worked. In fact it did work for a while but I tweaked the module and broke it. I'll look at convert/helper soonish. Johnuniq (talk) 05:31, 2 August 2017 (UTC)
 * (Not a blunder, thing happen when you're working -DePiep (talk) 10:34, 2 August 2017 (UTC)
 * OK, in 24 hours should do. Let's not debate the name much more but to explain my opinion, there is no simple phrase that would describe the function, so just using an English word related to the function makes it easy to remember and use. For example, formatfrac suggests an equivalent of frac, and normalisefrac might suggest reducing $3/8$ to $3/8$. Johnuniq (talk) 11:28, 1 August 2017 (UTC)
 * module:Convert/helper name is good. I'll see what happens and then adjust the sandbox into the new name. I'm off for now. btw, could you check &rarr;  (expect 12+3/8 right? was OK above). -DePiep (talk) 11:53, 1 August 2017 (UTC)
 * That was a blunder which I have now fixed, thanks. My comment at 11:10, 30 July 2017 above shows I thought it worked. In fact it did work for a while but I tweaked the module and broke it. I'll look at convert/helper soonish. Johnuniq (talk) 05:31, 2 August 2017 (UTC)
 * (Not a blunder, thing happen when you're working -DePiep (talk) 10:34, 2 August 2017 (UTC)


 * I suggest adding ⅓ and ⅔ to module:convert/helper for completeness. I'm not sure if there are more fraction characters (the 1/8 series is complete).
 * -DePiep (talk) 08:51, 29 August 2017 (UTC)
 * @DePiep: Done. Johnuniq (talk) 09:31, 29 August 2017 (UTC)
 * -DePiep (talk) 08:51, 29 August 2017 (UTC)
 * @DePiep: Done. Johnuniq (talk) 09:31, 29 August 2017 (UTC)

Tests & implementations

 * So far, I've test-implemented some new features (see Template:NFL predraft/sandbox & /testcases). Notes:
 * Using number to normalise fraction input for.
 * Using the "class=error" (now added in general in ).
 * Not used: option 5 ft 9 in. Since the template has ft and in input separated over 2 parameters, it can control more ("no ft input, inch only"). So it uses classic x ft with/without the ft parameters.
 * Not done: check time values "5.44 s" for numeric input.
 * Pro tip: a result is calculated only once, then a subtemplate tests that value for  output. In this template, case bad = return raw input+maintenance category (this will evade any further  error handling: no tagging, no convert-categorisation).
 * Todo: Keep testing; at Template talk:NFL predraft, find support to add the metric values; completify in-template error handling (add maintenance category); wait for both new features to go live.
 * Long term: Check convinfobox in templates that could benefit from the new options (check for elaborate error checking, accept easier frac input). Note that the ft in option is not thoroughly tested any more.
 * -DePiep (talk) 10:34, 2 August 2017 (UTC)
 * Sounds good. I set up the module so this should work:
 * Johnuniq (talk) 11:39, 2 August 2017 (UTC)
 * Works in testcases. -DePiep (talk) 12:04, 2 August 2017 (UTC)
 * Works in testcases. -DePiep (talk) 12:04, 2 August 2017 (UTC)

Could be wrapper Convert/pre
Not all rare features need to be added into Convert but, instead, could use a wp:wrapper template such as {convert/pre}. For example, some infoboxes need range +/- as the parameter 1 input value; example mountain elevation: Many mountain articles could use plus/minus in parameter 1, but ftin also could be in a wrapper {convert/pre} to not impact {convert}. We have trouble in Italian Wikipedia, where "e" means both "and" or unit "e" or exponent-notation. Example: So there are issues. -Wikid77 (talk) 07:52, 1 August 2017 (UTC)
 * {convert|5,610-5,650|m|ft} &rarr; 5,610-5,650 m
 * {convert|5,630+/-20|m|ft} &rarr; 5,630+/-20 m
 * {convert|5 and 6|m|ft} &rarr; 5 and 6 m
 * {convert|5e6|m|ft} &rarr; 5e6 m
 * A wrapper could be useful but I'm not sure how it would work with the NFL template.
 * The 1e5 issue at itwiki is a bit odd—it:Special:ExpandTemplate shows:
 * → 5 × 106 metri (1,6 × 107 ft)
 * → 5 e 6 metri (16 e 20 ft)
 * However, "5 and 6" (with spaces) or "5|and|6" (with pipes) are required at enwiki, and "5and6" would be an error. Similarly, "5,630 +/- 20' (with spaces or pipes) are needed to avoid an error. Johnuniq (talk) 10:55, 1 August 2017 (UTC)