Template talk:R:bg:STBR

From Wiktionary, the free dictionary
Latest comment: 7 months ago by Sgconlaw in topic Technical advice
Jump to navigation Jump to search

Technical advice

[edit]

Hi @Benwing2,

I can use your thoughts on a question regarding this template. You may be aware of ways to keep the template logic simple to handle a special case that exists with page numbering.

This is a dictionary template, and Volume 1 of the dictionary has sequential page numbers, except for a sequence of interstitial page numbers 390a - 390д. The page before those 5 is numbered 390, and the page after is numbered 391. This explains the current template logic to compute the right page number for the URL, based on the page number in the text. I haven't checked if there are other such "weird" page ranges in Volume 1 or Volume 2, but so far so good. The problem is that those "special" pages end up not directly addressable by the template.

I can see a few different ways of changing the logic to make sure that all pages - those with "regular" page numbers, and those with "irregular" ones - are accessible via the template:

  • introduce an "override" parameter, e.g. |urlpageno= which, if provided, is used verbatim in constructing the page URL. Allows direct addressing of any "special" page, as long as it has a URL with a page number. Downside: won't be able to use that as the |page= for {{cite-book}}.
  • change |2= (|page=) to handle both numbers and strings. I assume this would require the combination of a switch-statement to handle the "known" string-valued pages, as well as the existing arithmetic. I don't remember if we can write custom template functions, but even so, the downside of this is that it's complicated. Also, I'm not sure if {{cite-book}} would accept a non-numeric page.
  • switch |2= to unconditionally be the URL page number, rather than the printed page number. This would affect all entries in Volume 1 on pages after 390. Volume 2 (AFAIK) has URL/text page parity, so given that, it might be the easiest option. The dictionary consists of only these 2 volumes, there won't be other ones. The only downside is that our other reference templates use the page numbers in the text, so this one would be an outlier. Might be partly mitigated by the fact it's not the dictionary we use most frequently.

Which option sounds best to you?

Thanks,

Chernorizets (talk) 06:26, 7 November 2023 (UTC)Reply

@Chernorizets Personally I think you should do the second option, and allow the page numbers to be specified exactly as they appear on the printed page, and use a switch statement in the template code to handle the four special page numbers. AFAIK this is consistent with how similar situations are handled in other templates; User:Sgconlaw has written a bunch of them and can comment more. If you're not comfortable doing this in wikicode, feel free to write a small module to handle this; see Module:R:it:Olivetti for an example that is in module form so it can URL-encode the argument passed in. I'm pretty sure {{cite-book}} will allow page numbers ending in a letter or other non-digit character, so this shouldn't be an issue. Benwing2 (talk) 07:12, 7 November 2023 (UTC)Reply
@Benwing2 the wikitext didn't end up so bad after all. Done. Chernorizets (talk) 08:50, 7 November 2023 (UTC)Reply
@Chernorizets Looks good! Benwing2 (talk) 08:57, 7 November 2023 (UTC)Reply
@Benwing2, Chernoziets: yes, that’s how I would have done it. Glad you’ve been able to figure out the solution. — Sgconlaw (talk) 10:37, 7 November 2023 (UTC)Reply