Module talk:nyms
Add topicAlt parameters
[edit]@CodeCat: I thought my implementation of altN
parameters did work – at least in bhukuda. Where wasn't it working? — Eru·tuon 18:46, 14 February 2017 (UTC)
- Your code assumed that
args[1][x]
andargs["alt"][x]
should be paired, which is not necessarily the case. —CodeCat 18:49, 14 February 2017 (UTC)- @CodeCat: You mean
args[2][x]
. That's the way other templates with numbered parameters, such as{{affix}}
, work. What is a case in which it would not hold true? I thoughtargs[2]
was only for terms. — Eru·tuon 18:58, 14 February 2017 (UTC)- Yes, 2 not 1. A case where it would not hold true is:
{{nyms|xx|a|b|c|alt2=x|alt3=y}}
. Note thatalt1
is missing; by default any holes in the numbering are removed, soargs["alt"][2]
is "y", not "x"! —CodeCat 19:04, 14 February 2017 (UTC)- That's why I specified
allow_holes = true
in theparams
table. That solves the problem. — Eru·tuon 19:06, 14 February 2017 (UTC)- Not quite. Because what if someone then writes
{{nyms|xx||b|c|alt1=x|alt2=y}}
? —CodeCat 19:08, 14 February 2017 (UTC)- Then they would get an error because parameter
2
is required. — Eru·tuon 19:10, 14 February 2017 (UTC)- Okay, that's wrong. They would just get a prompt for a term: [Term?]. — Eru·tuon 19:13, 14 February 2017 (UTC)
- You want
args[2]
to be{2 = "b", 3 = "c"}
, andargs["alt"]
to be{1 = "x", 2 = "y"}
. The problem is that your code usesipairs(args[2])
, which expects tables without holes. It literally starts from 1 and counts upwards. But since there is noargs[2][1]
, the loop terminates right away. This is noted in the documentation of Module:parameters:allow_holes
does not play well with functions that expect tables without holes. That's whymaxindex
exists. —CodeCat 19:19, 14 February 2017 (UTC)- Okay, well, I think having error messages for empty terms is useful. It is not desirable to have instances of a nyms template with [Term?] prompts. So I would like to combine the use of
maxindex
with the error message for missing terms. — Eru·tuon 19:32, 14 February 2017 (UTC)- Why would it not be desirable? —CodeCat 19:35, 14 February 2017 (UTC)
- Unless there is a purpose for an empty term parameter in an entry, it's useless, and useless things are undesirable. — Eru·tuon 20:05, 14 February 2017 (UTC)
- It's not useless in
{{m}}
, so whatever motivation applies to it applies here too. —CodeCat 20:07, 14 February 2017 (UTC)
- It's not useless in
- Unless there is a purpose for an empty term parameter in an entry, it's useless, and useless things are undesirable. — Eru·tuon 20:05, 14 February 2017 (UTC)
- Why would it not be desirable? —CodeCat 19:35, 14 February 2017 (UTC)
- Okay, well, I think having error messages for empty terms is useful. It is not desirable to have instances of a nyms template with [Term?] prompts. So I would like to combine the use of
- Then they would get an error because parameter
- Not quite. Because what if someone then writes
- That's why I specified
- Yes, 2 not 1. A case where it would not hold true is:
- @CodeCat: You mean
Testing for singular and plural
[edit]@Erutuon, DTLHS, Wyang: would it be possible to update the module so that it operates as follows?
- If a template has multiple parameters, e.g.,
{{synonyms|en|happy|joyful|mirthful}}
, then display "Synonyms:". - If a template has only one parameter, e.g.,
{{synonyms|en|happy}}
, then display "Synonym:".
— SGconlaw (talk) 09:56, 16 June 2018 (UTC)
- @Sgconlaw Of course, done:
- Wyang (talk) 21:51, 17 June 2018 (UTC)
- Great, thanks! — SGconlaw (talk) 23:54, 17 June 2018 (UTC)
Suggested tweak
[edit]@Erutuon, Jberkel, Rua, Suzukaze-c, Wyang, currently the template {{synonyms}}
displays "Synonym" if there is only one term, which is correct. I think it might be useful to be able to use the template (and {{antonyms}}
, of course) with thesaurus links as well, like this: {{synonyms|en|''see'' [[Thesaurus:happy]]}}
. If you think this is a good idea, would it be possible to tweak the template so that if the only entry is a thesaurus link that begins with ''see''
the template displays the word "Synonyms"? — SGconlaw (talk) 15:26, 5 January 2019 (UTC)
Or, just thinking aloud, another possibility would be for the template to be able to achieve the following:
{{synonyms|en|Thesaurus:happy}}
→ "Synonyms: see Thesaurus:happy"{{synonyms|en|cheerful|joyful|merry|Thesaurus:happy}}
→ "Synonyms: cheerful, joyful, merry; see also Thesaurus:happy"
— SGconlaw (talk) 15:29, 5 January 2019 (UTC)
- I like your last idea more. The module can figure out whether something is a term or a Thesaurus link based on the prefix. It would make the format more universal. There are a few details to work out though:
- What if the Thesaurus link isn't the last one in the list?
- The module allows you to specify qualifiers, alternative display forms and transliterations for each of the items. What happens when someone specifies these for a Thesaurus link?
- —Rua (mew) 17:31, 5 January 2019 (UTC)
- I think it makes sense for the Thesaurus link to always be the last item in a list. I don't know if this can be done automatically by the module – seems like that might be complicated. Maybe we just have to put a note on the appropriate template description pages to tell editors to do so. Qualifiers, alternative display forms and transliterations shouldn't apply to Thesaurus links. — SGconlaw (talk) 19:17, 5 January 2019 (UTC)
Don't know how it's gonna work out, but I like the idea. Per utramque cavernam 19:21, 5 January 2019 (UTC)
- +1 The module could automatically put the thesaurus link at the end, but I think it'd be good editing practice to always put it at the end. – Jberkel 20:45, 5 January 2019 (UTC)
I implemented it: Synonyms: cheerful, joyful, merry; see also Thesaurus:happy. If the Thesaurus link is not the last list item, or if you use named parameters with it, you get an error. —Rua (mew) 21:22, 5 January 2019 (UTC)
- @Rua: Nice & quick! I think it should still handle the case where there's only a thesaurus link. See Special:Diff/51188179/51205143. – Jberkel 03:39, 6 January 2019 (UTC)
- Thanks, @Rua! Yes, my suggestion was also for the situation where there is only a Thesaurus link to be implemented as well. In that case the word before the link should be “see”, not “see also”. — SGconlaw (talk) 10:56, 6 January 2019 (UTC)
- Fixed. —Rua (mew) 11:46, 6 January 2019 (UTC)
- Excellent! Thanks. — SGconlaw (talk) 12:29, 6 January 2019 (UTC)
- Fixed. —Rua (mew) 11:46, 6 January 2019 (UTC)
- Thanks, @Rua! Yes, my suggestion was also for the situation where there is only a Thesaurus link to be implemented as well. In that case the word before the link should be “see”, not “see also”. — SGconlaw (talk) 10:56, 6 January 2019 (UTC)
I've made the template allow multiple thesaurus links as long as they are at the end. This fixes a module error in ineffable, which has {{syn|en|indescribable|inexpressible|unspeakable|Thesaurus:indescribable|Thesaurus:incomprehensible}}
. Either that, or I think a more helpful error message in such a case would be something like "You only get to add one Thesaurus link". — Eru·tuon 20:54, 6 January 2019 (UTC)
- It makes more sense to allow multiple Thesaurus links, if there is already a need for it. —Rua (mew) 21:34, 6 January 2019 (UTC)
Links to entries will now be separated by semicolons rather than commas if any of the entry names contains a comma (see this discussion). Maybe the same should be done for Thesaurus links, but it's an unlikely scenario so I'm not doing it yet. — Eru·tuon 02:52, 8 January 2019 (UTC)
Multiple thesaurus links not arranged alphabetically
[edit]Why does {{synonyms|en|row|scuffle|squabble|Thesaurus:dispute|Thesaurus:fight}}
end up producing this?
- Synonyms: row, scuffle, squabble; see also Thesaurus:dispute, Thesaurus:fight
Shoudn't the thesaurus links be arranged alphabetically? — SGconlaw (talk) 18:08, 3 April 2019 (UTC)
- @Sgconlaw: Well, the order should at least be preserved, not reversed. Fixed. — Eru·tuon 18:14, 3 April 2019 (UTC)
- Thanks! — SGconlaw (talk) 18:15, 3 April 2019 (UTC)
langcode prefix problem
[edit]@Benwing2 the new functionality you implemented does not work properly, where it now requests for a term instead, see for example 月份. – Wpi (talk) 11:50, 24 June 2023 (UTC)