Jump to content

Module talk:Person height

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Frietjes (talk | contribs) at 14:01, 9 May 2023 (Forcing number of metric digits). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

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)[reply]

Default preference should be conversion to metres, not centimetres

It seems like if the prefer_m 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)[reply]

Forcing number of metric digits

@Frietjes: 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. {{#invoke:person height|main|5 ft 7 in}} outputs "5 ft 7 in (170 cm)". 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 |enforce=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)[reply]

S.A. Julio, I have added an optional |adj= to the sandbox which can be |adj=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 |adj=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., |ri=cm to round input to the nearest centimeter). what do you think we should do? Frietjes (talk) 14:55, 4 May 2023 (UTC)[reply]
@Frietjes: The |adj= 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 ri0 would round to the nearest metre and ri2 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 |ri=cm only work for inputs given in cm? S.A. Julio (talk) 19:28, 4 May 2023 (UTC)[reply]
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 |ri=cmin? I am completely open to suggestions. Frietjes (talk) 19:41, 4 May 2023 (UTC)[reply]
@Frietjes: 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 cm or cmin? Then, would |adj= still be needed for the output to go to hundredths of a metre when using |enforce=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)[reply]
@Frietjes: Would there be any way for this module to pass |adj=ri2 to {{convert}} only when the input is in metres? S.A. Julio (talk) 01:37, 9 May 2023 (UTC)[reply]
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)[reply]
Summary of outputs when using the code
{{#invoke:person height|main|<input>|enforce=m}}
Input Current output Desired output Sandbox Sandbox (adj=ri2)
2 m 2 m (6 ft 7 in) 2.00 m (6 ft 7 in) 2 m (6 ft 7 in) 2 m (6 ft 7 in)
1.8 m 1.8 m (5 ft 11 in) 1.80 m (5 ft 11 in) 1.8 m (5 ft 11 in) 1.8 m (5 ft 11 in)
1.803 m 1.803 m (5 ft 11 in) 1.80 m (5 ft 11 in) 1.803 m (5 ft 11 in) 1.803 m (5 ft 11 in)
1.809 m 1.809 m (5 ft 11 in) 1.81 m (5 ft 11 in) 1.809 m (5 ft 11 in) 1.809 m (5 ft 11 in)
200 cm 2 m (6 ft 7 in) 2.00 m (6 ft 7 in) 2.00 m (6 ft 7 in) 2.00 m (6 ft 7 in)
180 cm 1.8 m (5 ft 11 in) 1.80 m (5 ft 11 in) 1.80 m (5 ft 11 in) 1.80 m (5 ft 11 in)
180.3 cm 1.803 m (5 ft 11 in) 1.80 m (5 ft 11 in) 1.803 m (5 ft 11 in) 1.803 m (5 ft 11 in)
180.9 cm 1.809 m (5 ft 11 in) 1.81 m (5 ft 11 in) 1.809 m (5 ft 11 in) 1.809 m (5 ft 11 in)
6 ft 6 ft (1.83 m) 6 ft 0 in (1.83 m) 6 ft (1.83 m) 6 ft (1.83 m)