Template talk:Plural: Difference between revisions

 

Line 83: Line 83:

:: As for <syntaxhighlight lang=”wikitext” inline>{{{{{|safesubst:}}}…}}</syntaxhighlight>, please check [[Module:Params#Multilevel substitution warning|this warning]]. In the best case scenario template creators will ”’not”’ be able to use {{tl|plural}} within {{mfl|params|call_for_each_group}}; in the worst case scenario, other bugs will emerge in other contexts as well and people will struggle to understand where they come from. [[:mw:Help:Substitution#Multilevel substitution|Mediawiki too]] warns that the argument with an empty name “is sometimes used by modules that call templates or for inserting comments”. If it is true that “it is used in many templates<s> and works just fine as it is</s>”, it should be updated everywhere is found. –[[User:Grufo|Grufo]] ([[User talk:Grufo|talk]]) 20:13, 17 September 2025 (UTC)

:: As for <syntaxhighlight lang=”wikitext” inline>{{{{{|safesubst:}}}…}}</syntaxhighlight>, please check [[Module:Params#Multilevel substitution warning|this warning]]. In the best case scenario template creators will ”’not”’ be able to use {{tl|plural}} within {{mfl|params|call_for_each_group}}; in the worst case scenario, other bugs will emerge in other contexts as well and people will struggle to understand where they come from. [[:mw:Help:Substitution#Multilevel substitution|Mediawiki too]] warns that the argument with an empty name “is sometimes used by modules that call templates or for inserting comments”. If it is true that “it is used in many templates<s> and works just fine as it is</s>”, it should be updated everywhere is found. –[[User:Grufo|Grufo]] ([[User talk:Grufo|talk]]) 20:13, 17 September 2025 (UTC)

::: Likely the test continued to use <code><nowiki>{{#if:}}</nowiki></code> instead of changing to {{tl|P1}}/{{tl|P2}}. Compare <code>|{{#if:|&nbsp;| }}|</code> (using #if) versus <code>|{{P2|&nbps;| }}|</code> (using P2). [[User:Anomie|Anomie]][[User talk:Anomie|⚔]] 21:10, 17 September 2025 (UTC)

::: Likely the test continued to use <code><nowiki>{{#if:}}</nowiki></code> instead of changing to {{tl|P1}}/{{tl|P2}}. Compare <code>|{{#if:|&nbsp;| }}|</code> (using #if) versus <code>|{{P2|&nbps;| }}|</code> (using P2). [[User:Anomie|Anomie]][[User talk:Anomie|⚔]] 21:10, 17 September 2025 (UTC)

:::{{gi|”Not sure what you tested”}}? Yes, I could have been more explicit, so sorry. I tested the live template’s code without the {{code|<nowiki>|&#32;}}</nowiki>}}, as in <code>|}}</code> and <code>| }}</code>, and both tests yielded <code>{{{1}}}{{{2}}}s</code> (loss of space) in the sandbox. What we seem to be up against here is my ignorance, and the fact that the following is also true:

:::* <code><nowiki>{{plural|0|page}}</nowiki></code> returns “{{plural|0|page}}”

:::* <code><nowiki>{{plural|1|page}}</nowiki></code> returns “{{plural|1|page}}”

:::* <code><nowiki>{{plural|2|page}}</nowiki></code> returns “{{plural|2|page}}”

::: …so I’m very sorry about that. You see, while TEs know how to edit templates and some modules, we are sometimes clueless as to the actual value of our edits when we try to help others who get posted to {{Cat|Wikipedia template-protected edit requests}}. In cases like these we need more than obscure warnings in Module /doc pages (and the module is used in relatively few articles and templates) or equally obscure MW paragraphs – we like to see examples of where the actual problem(s) appear. Template {{tl|Plural}} is used on 112,000 pages, which makes it a “high-risk” template. So without more context, for all we know we might be butchering the underlying WP server system with such edits (no offense meant – it’s just that some of us have been badly burned before, and that makes us very careful). Might do this, might do that? Where is the actual problem? – examples, examples, examples… there’s the ticket”!” ””'[[User:Paine Ellsworth|<span style=”font-size:92%;color:darkblue;font-family:Segoe Script”>P.I.&nbsp;Ellsworth</span>]]””’&thinsp;,&nbsp;[[Editor|<span style=”color:black”>ed.</span>]]&nbsp;–&nbsp;[[User talk:Paine Ellsworth|”welcome!”]]&nbsp;–&nbsp;<small>21:20, 17 September 2025 (UTC)</small>

I have fixed this template to correctly handle all plurals, even “ox/oxen”. Anomie 19:59, 5 October 2007 (UTC)[reply]

{{editprotected}} Please make this edit to allow the template to give the expected output when substed. Anomie 17:28, 12 October 2010 (UTC)[reply]

done —TheDJ (talkcontribs) 18:17, 12 October 2010 (UTC)[reply]

Provides the appropriate singular or plural form of a noun preceded by a number

Template parameters[Edit template data]

Parameter Description Type Status
Number 1

A non-negative number

Number required
Name 2

A singular noun

String required
Name (plural) 3

Plural form of Name (not needed if the plural is formed by adding -s)

String optional

ℜob C. alias ÀLAROB 00:07, 2 July 2013 (UTC)[reply]

Not done: {{edit protected}} is usually not required for edits to the documentation, categories, or interlanguage links of templates using a documentation subpage. Use the ‘edit’ link at the top of the green “Template documentation” box to edit the documentation subpage. —Redrose64 (talk) 08:58, 2 July 2013 (UTC)[reply]

I am requesting that this template be updated to allow the option of using a non-breaking space between the number and the text (in place of the current breaking space). The updated code can be found in Template:Plural/sandbox. The following shows an example of how it would work (the output was placed inside a narrow <div> to force a line break).

Example Current output Sandbox output
Non-breaking space: {{plural|20|year|nb=y}}

20 years

20 years

Breaking space (default): {{plural|20|year}}

20 years

20 years

Additional examples can be found at Template:Plural/testcases.
Zyxw (talk) 01:58, 30 September 2013 (UTC)[reply]

Done Except I used {{yesno}} so {{plural|20|year|nb=no}} will do what the user probably expects. Anomie 02:06, 30 September 2013 (UTC)[reply]
Thanks for the quick response and also for adding nb=no to the test cases. — Zyxw (talk) 04:03, 30 September 2013 (UTC)[reply]

Currently this template has two problems:

  1. It uses &#32; to express a space, which looks useless and ugly when the template is substituted
  2. It uses {{{{{|safesubst:}}}...}} to signal multilevel substitutions, but that is dangerous and deprecated in favour of {{safesubst:<noinclude />...}}, because the |= parameter (i.e. the parameter named with an empty string) sometimes might actually be passed as a real parameter.

Would you mind replacing the current code with this version?

<includeonly>{{{1}}}{{safesubst:<noinclude />P{{safesubst:<noinclude />yesno|{{{nb|no}}}|yes=1|no=2}}|&nbsp;| }}{{safesubst:<noinclude />plural:{{{1}}}|{{{2}}}|{{{3|{{{2}}}s}}}|{{{4}}}}}</includeonly><noinclude>{{Documentation}}</noinclude>

Grufo (talk) 19:29, 17 September 2025 (UTC)[reply]

 Not done: have you tested this without the &#32; space code? When I tested it, the space between the {{{1}}} {{{2}}}s disappears and it looks like this:
Can’t have that, can we? As for the method of safe substituting, it is used in many templates and works just fine as it is. Thank you for your concerns, though. Sorry, but I really don’t see a problem here that needs solving. P.I. Ellsworth , ed. – welcome! – 19:50, 17 September 2025 (UTC)[reply]
@Paine Ellsworth: Not sure what you tested. This is a test:
  • {{plural/sandbox|0|page}} returns “0 pages”
  • {{plural/sandbox|1|page}} returns “1 page”
  • {{plural/sandbox|2|page}} returns “2 pages”
As for {{{{{|safesubst:}}}...}}, please check this warning. In the best case scenario template creators will not be able to use {{plural}} within {{#invoke:params|call_for_each_group}}; in the worst case scenario, other bugs will emerge in other contexts as well and people will struggle to understand where they come from. Mediawiki too warns that the argument with an empty name “is sometimes used by modules that call templates or for inserting comments”. If it is true that “it is used in many templates and works just fine as it is”, it should be updated everywhere is found. —Grufo (talk) 20:13, 17 September 2025 (UTC)[reply]
Likely the test continued to use {{#if:}} instead of changing to {{P1}}/{{P2}}. Compare || (using #if) versus | | (using P2). Anomie 21:10, 17 September 2025 (UTC)[reply]
“Not sure what you tested”? Yes, I could have been more explicit, so sorry. I tested the live template’s code without the |&#32;}}, as in |}} and | }}, and both tests yielded {{{1}}}{{{2}}}s (loss of space) in the sandbox. What we seem to be up against here is my ignorance, and the fact that the following is also true:
  • {{plural|0|page}} returns “0 pages”
  • {{plural|1|page}} returns “1 page”
  • {{plural|2|page}} returns “2 pages”
…so I’m very sorry about that. You see, while TEs know how to edit templates and some modules, we are sometimes clueless as to the actual value of our edits when we try to help others who get posted to Category:Wikipedia template-protected edit requests. In cases like these we need more than obscure warnings in Module /doc pages (and the module is used in relatively few articles and templates) or equally obscure MW paragraphs – we like to see examples of where the actual problem(s) appear. Template {{Plural}} is used on 112,000 pages, which makes it a “high-risk” template. So without more context, for all we know we might be butchering the underlying WP server system with such edits (no offense meant – it’s just that some of us have been badly burned before, and that makes us very careful). Might do this, might do that? Where is the actual problem? – examples, examples, examples… there’s the ticket! P.I. Ellsworth , ed. – welcome! – 21:20, 17 September 2025 (UTC)[reply]

Leave a Comment

Your email address will not be published. Required fields are marked *

Exit mobile version