Jump to content

Template talk:Short description/lowercasecheck

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Needs better word extraction than Template:first word

[edit]

This template needs better word extraction than {{first word}}, which includes commas. This means that even though "iOS" is on the whitelist, the short description "iOS, macOS, and tvOS software" fails the check. – Jonesey95 (talk) 23:02, 6 February 2022 (UTC)[reply]

@Jonesey95: Would {{First word|iOS, etc.|sep= ,}} → iOS do the trick? Note the {{{sep}}} parameter treats its inputs as OR i.e. it looks for '_' or ',' not '_,' . ― Qwerfjkltalk 21:55, 9 February 2022 (UTC)[reply]

lcfirst?

[edit]

Why doesn't this template just use lcfirst in a comparison to check if the first character is lowercase?

{{ #ifeq: {{{1}}} | {{lcfirst:{{{1}}}}}
| <!-- lowercase; extract first word and check against allowlist -->
| <!-- uppercase or uncased character; do nothing -->
}}

ディノ千?!☎ Dinoguy1000 18:11, 6 April 2024 (UTC)[reply]

Dinoguy1000, in case there's a situation where a valid lowercase word which is not in the allowlist is used; it's better to spot it in the tracking category than have some editor wonder why they can't fix the short description. — Qwerfjkltalk 19:43, 6 April 2024 (UTC)[reply]
Ignore that last comment, clearly I'm too tired to be editing. Pinging @Jonesey95. — Qwerfjkltalk 19:45, 6 April 2024 (UTC)[reply]
No worries, this made me double-check my own thinking and realize I'd suggested the wrong function for the logic as given. =) ディノ千?!☎ Dinoguy1000 03:38, 7 April 2024 (UTC)[reply]
So is everything OK? It has been a while since I invented this little thing, and I don't remember the logic I chose, but if it ain't broke, probably don't fix it. – Jonesey95 (talk) 07:59, 7 April 2024 (UTC)[reply]
It currently works "fine", yes, but it has an unnecessary (and rather cryptic) dependence on Module:String that this suggested change would do away with. ディノ千?!☎ Dinoguy1000 09:15, 7 April 2024 (UTC)[reply]
Are you sure that your proposed code works? I tried it with "1905 musical" and it said that the two terms were equal. I then ran {{first word}} on "1905 musical" and I got "1905", which results as "default" in the switch test and so would apply the category. I'm pretty sure. – Jonesey95 (talk) 23:02, 7 April 2024 (UTC)[reply]
You're right; the original check I suggested (using ucfirst instead of lcfirst) would work correctly for cases like "1905 musical", but would require the results branches to be swapped. I never actually tested this code, expecting that it would be tested before actually being saved, in which case these mistakes would quickly be caught (this is how I usually approach template development, though in fairness almost all of that development takes place on and for a non-WMF wiki). ディノ千?!☎ Dinoguy1000 23:59, 7 April 2024 (UTC)[reply]