Module talk:Person height

How can we localize cm, m, ft labels for other wikis?
Is it possible to do that at this stage or should there be a new line of code introduced?--Épine (talk) 16:07, 21 July 2021 (UTC)

Default preference should be conversion to metres, not centimetres
It seems like if the  argument is not set, the module defaults all feet/inches conversions to centimetres. This should be changed to metres instead, which is the more common and international unit of measurement (e.g., in the Olympics, the UN, other international bodies, and in things like BMI calculations, etc.). Getsnoopy (talk) 18:57, 29 August 2021 (UTC)

Forcing number of metric digits
Would it be possible to add an option to force a certain number of digits when using metres? When height is given in feet and inches, the module always outputs 3 digits, e.g.  outputs "". However, when the height is given in metres but with only 1 or 2 digits, the template will output the number as given. In addition, when using m, if the height is supplied in centimetres, any trailing zeroes will be cut off after converting to metres. Would it be possible in such cases to have a way to force three digits to be shown for metres? I have included a table below as a summary. Thanks, S.A. Julio (talk) 08:42, 4 May 2023 (UTC)
 * S.A. Julio, I have added an optional adj to the sandbox which can be ri0, ri1, ri2, ri3. since this is just a wrapper for convert all this does is pass the adj to the call to convert.  this means the ri2 is with respect to the input to the convert template, not the input to the module.  I don't know if this is going to cause any unexpected results in other cases.  another option would be have a more restricted input syntax that only applies to some cases (e.g., cm to round input to the nearest centimeter).  what do you think we should do? Frietjes (talk) 14:55, 4 May 2023 (UTC)
 * The  seems alright, though this impacts the output when height is given in feet and inches, e.g. "5 ft 6 in" outputs "5.00 ft 6.00 in (1.68 m)". Also, this would only be able to be used in conjunction with enforce, otherwise   would round to the nearest metre and   would add the hundredths place to centimetres. As for your second suggestion, would a parameter such as ri be able to simultaneously round to the nearest centimetre or hundredths of a metre, depending on the input, or would cm only work for inputs given in cm? S.A. Julio (talk) 19:28, 4 May 2023 (UTC)
 * S.A. Julio, yes, this is the problem. I think what we want is some parameter to make it round the input to nearest cm (for cm or m) or nearest inch (for inches).  assuming that is what we want, we just need a way to say that in the input. so maybe cmin?  I am completely open to suggestions. Frietjes (talk) 19:41, 4 May 2023 (UTC)
 * That would work, though I am apprehensive on applying this to the nearest inch. Given height in ft/in is less precise, it is useful on some articles to use "5 ft 8.5 in" or "5 ft 8+1/2 in". Maybe ri could accept  or  ? Then, would adj still be needed for the output to go to hundredths of a metre when using m? Also, if "6 ft" was given as an input, could there be an option to force the output of "6 ft 0 in"? S.A. Julio (talk) 20:08, 4 May 2023 (UTC)
 * Would there be any way for this module to pass ri2 to convert only when the input is in metres? S.A. Julio (talk) 01:37, 9 May 2023 (UTC)
 * S.A. Julio, yes, we should be able to do that. but, before doing that, I am going to try to get the default case to preserve the input precision (e.g., the 200 cm and 180 cm cases).  I will work on it later today. Frietjes (talk) 14:01, 9 May 2023 (UTC)


 * S.A. Julio, I fixed the default precision for the 200 cm and 180 cm cases. I have also added ri to force rounding the input to the nearest in or cm (see the table above). right now any value passed to ri makes this happen, but I could restrict it only a set list of valid inputs. Frietjes (talk) 17:41, 15 May 2023 (UTC)
 * Great, looks good! Only issue I can think of is unlike metric height (which is almost always given to the nearest centimetre), some articles use half or quarter inches for greater precision. For example, see Willie Waddell (footballer, born 1919). Would there be any way to not disrupt the formatting in these cases, or even convert something like 3.5 → 3+1/2 (thus displaying $10 1/2$)? S.A. Julio (talk) 20:30, 15 May 2023 (UTC)
 * probably possible in the special case of 1/2 by either internally converting the 10.5 to 10+1/2 before passing it to convert, or supporting 10+1/2 as an input. I will have to think about it.  of course, you can always just use convert directly for these cases (which does support 10+1/2 for input). Frietjes (talk) 00:20, 16 May 2023 (UTC)
 * Alright, there do not seem to be too many infoboxes using that formatting (inches with decimals), so I could adjust the relevant articles manually. So is the change to the module ready to go live? One thing I noticed: when m is set, but no value is given for ri, it will now always output the metric height with two decimals, which is a change in behaviour (see lines 5 to 8 in the table, current output vs. sandbox). Is this intended? S.A. Julio (talk) 06:08, 19 May 2023 (UTC)
 * S.A. Julio, fixed that bug. now, the default output precision should match the input precision.  but, if you use cmin then it will round the input to either the nearest inch or cm depending on if the input is in inches or centimeters or meters.  I could make three cases, in, cm and cmin where each of these does something different.  but, I think generally human height is rounded to the nearest cm or in depending on the base unit of measure. Frietjes (talk) 15:54, 19 May 2023 (UTC)
 * Agreed regarding the height rounding. Everything seems to be working correctly, is the sandbox version ready to be published? S.A. Julio (talk) 18:53, 19 May 2023 (UTC)
 * S.A. Julio, okay, now updated. Frietjes (talk) 19:13, 19 May 2023 (UTC)
 * Wonderful, thank you for your help! S.A. Julio (talk) 19:32, 19 May 2023 (UTC)
 * One other question: this module allows fractions to be passed to convert, e.g.  outputs "". Is there a way to pass "6 ft 1/2 in" to convert (instead of having to write 6 ft 0+1/2 in)? Currently this module will not convert that input. However, convert does handle this, e.g.   outputs "6 ft". Thanks, S.A. Julio (talk) 19:55, 19 May 2023 (UTC)
 * S.A. Julio, sure, now in the sandbox (but only for 1/2 and not other fracs). Frietjes (talk) 20:00, 19 May 2023 (UTC)
 * S.A. Julio, now implemented. Frietjes (talk) 20:05, 19 May 2023 (UTC)
 * Great, thanks! S.A. Julio (talk) 20:10, 19 May 2023 (UTC)

Non-breaking space for units
Hello, I noticed recently that this module does not always include a non-breaking space in between a number and the units. When a conversion template is given as an input to this module, all the units will be abbreviated. However, this leaves a regular space in between the number and the abbreviated unit. This is unlike convert, which always uses a non-breaking space for a separator when units are abbreviated (per Help:Convert). For example, currently  outputs , while it should output. Same thing also happens when inputting. Would it be possible to adjust this? Thanks, S.A. Julio (talk) 18:48, 11 June 2023 (UTC)
 * S.A. Julio, okay, when convert outputs with abbreviated units, we abbreviate them, but we also need to add the non-breaking space. should be fixed now. Frietjes (talk) 15:36, 12 June 2023 (UTC)
 * Great, thank you! One other question, would it be possible to still convert the height if there is an inline cleanup tag present? For example, see the citation needed tag on Andrew Donaldson (Scottish footballer). S.A. Julio (talk) 15:43, 12 June 2023 (UTC)
 * Also, I noticed on Cristian Martínez (Andorran footballer) that the talk page link generated by Dubious is broken. It seems that this module is replacing "foot" in "Andorran footballer" to "ft", could this be fixed? Thanks, S.A. Julio (talk) 16:39, 12 June 2023 (UTC)
 * S.A. Julio, should be fixed now. Frietjes (talk) 21:28, 12 June 2023 (UTC)
 * Great, thanks! S.A. Julio (talk) 00:04, 13 June 2023 (UTC)

Enforcing m or cm
I had one other question regarding this module. Currently, using the m or cm parameters will force the conversion to output into metres or centimetres. However, this does not apply if the height is already converted using a template such as convert or height. In this case, would it be possible for this module to modify the final output to use the units set in the  parameter? Similar to how this module already abbreviates units from the conversion templates. For example, the code  will currently output "184 cm (6 ft 0 in)", would it be possible to instead output "1.84 m (6 ft 0 in)"? And vice versa to output cm if given units in metres. Thanks, S.A. Julio (talk) 17:19, 29 June 2023 (UTC)
 * possible, I will take a look over the next couple days. Frietjes (talk) 18:21, 29 June 2023 (UTC)
 * S.A. Julio, should work now. let me know if you see a problem. Frietjes (talk) 19:22, 3 July 2023 (UTC)
 * Wonderful, thank you! S.A. Julio (talk) 22:12, 3 July 2023 (UTC)