Module talk:Interlinear

Intro
This is an organically grown module: it started out small and simple, but over time various bits got added, then rewritten and trimmed, all at different times and in different styles, so the result is probably quite unreadable. Be warned before approaching the code.

The major items I've got on the to-do list are (sorry, no improvements in readability down the pipe!): All these things are dependent on the presence of external factors, so the main task at the moment is to wait until they become available. – Uanfala (talk) 20:28, 12 December 2017 (UTC)
 * Revamp styles and classes in accordance with mw:Extension:TemplateStyles, whenever that extension becomes available on the English wikipedia (check at Special:Version)
 * Make lang= invoke Module:Lang, whenever that has settled
 * Rewrite the bletcherous parser function. This will make more sense if done at a time when we will be able to use (as an extension or a module) either an XML parser, or at least a proper regex engine.

Automatic transliteration
I really like what the module does. I'm experimenting with using it for Ancient Greek example sentences in User:Erutuon/Ancient_Greek interlinear glossing, though it might not be used in articles anytime soon because it's untraditional – not typically used in teaching Ancient Greek.

So, the Ancient Greek examples have automatically generated transliteration, which I enter by copying the Greek text into in a separate parameter from the Greek text, but I was thinking that perhaps the module could use the transliteration module (Module:Ancient Greek) to automatically generate transliteration, retrieving the name of the module and the name of the exported function for the language from a table. That would be more convenient.

For example, from this method of inputting the example – undefined

– to this –

undefined

– but with the transliteration automatically generated.

Anyway, it's an idea. It is probably not time to try to implement it, as Ancient Greek isn't using the template in entries yet. — Eru·tuon 08:59, 23 January 2018 (UTC)
 * I've added a very tentative version of the functionality you've described. It only works from fs interlinear:

undefined


 * If a line supplied by the template is the string "auto" then that line is replaced by the automatic transliteration of the preceding line. How is that for usability? The alternative from your examples is for the module to guess from the total number of lines supplied (if there are three instead of the expected four) and to assume that it's the first line that needs to be transliterated. These are reasonable assumptions most of the time, but I think they will make it unreasonably difficult to use the feature in other contexts (say, if there are source sentences in more than one language or script, with each needing to be transliterated). What do you think? If the word "auto" can be replaced with something more intuitive, go ahead. The actual transliteration happens in function transliterate. Feel free to pick that up from where I've left it.


 * As it's currently set up, the transliterator is chosen based on the lang code (if the source sentene is the nth unnamed parameter, then first langN is looked up and if it's missing then lang is used). I don't know if it's reasonable to try to make the module guess based on the script used. Ultimately, I guess there should be support for different transliteration schemes, as well as for backward transliteration (from a Roman-based scheme into a foreign script).


 * Given that automatic transliteration is not needed solely in interlinear glosses, I think there should be an umbrella metamodule to handle all automatic tranlsiterations, loading modules for individual scripts/languages as and when required. Any thoughts? – Uanfala (talk) 03:38, 27 January 2018 (UTC)
 * I have corrected the repetitions of "wise" to "just" in the above examples. -- Mirokado (talk) 13:41, 27 January 2024 (UTC)

Argument scenarios
What's the right thing to do when there are fewer than 3 arguments? The documentation is conflicting on this point.

In particular, if there are only 2 arguments (lines), what do the first and second ones most likely represent? I would say native language + gloss, but the current implementation appears to be native language + free translation. (IMO, if you're not actually glossing, why use this template in the first place? The first line would have special spacing for no reason.) Thoughts? &mdash;Gordon P. Hemsley&rarr; &#x2709; 12:35, 11 July 2019 (UTC)
 * The relevant part of the documentation is in the last paragraph of Template:Interlinear. Given that the module can be used with any number of lines, I thought it was simpler to have one rule for all cases of more than one line: 1a) the last line is treated as the free translation and so isn't interlinearised; 1b) to omit a free translation, supply an empty last line. I agree that for two lines it's almost certain the intended use is native language + gloss, so it's possible to add an exception for this case, but doing so would add an extra rule that users may need to know. It will also make it impossible to format two lines as native language + free translation, so we must be completely sure this is never going to be needed. – Uanfala (talk) 22:52, 11 July 2019 (UTC)
 * The conflict is that Template:Interlinear states that the second line will be assumed to be glossing if no glossing line is specified – so the problem arises of what happens when the second line and the last line are the same line. It may turn out that this is simply a matter of clarifying the documentation. (Admittedly, despite multiple attempts to find such information, I missed the part where it says how to force the last line to be interlinearized. It might be worth making that stand out more and/or putting it in multiple sections.) &mdash;Gordon P. Hemsley&rarr; &#x2709; 11:42, 12 July 2019 (UTC)
 * Oh, I see, I hadn't noticed that. So it turns out we have extra complexity either way: either it's assumed the second line contains glosses unless there are altogether only two lines, or the last line is always assumed to be the free translation unless the last line is the second line. So we need to either change the behaviour of the module, or update the documentation. Both changes are trivial to make, so the question is which of the two alternatives results in greater usability. Any thoughts? – Uanfala (talk) 12:36, 12 July 2019 (UTC)
 * You raised an important point earlier about being completely sure that no one is going to want to format two lines as native language + free translation, and that gave me pause. However, I can't think of a valid scenario where you would want to interlinearize a single line of text up against a free translation. Which brings into question why the single line behavior is the way it is—are we able to find examples of single line interlinearization that we can conceive adding a line of free translation to? &mdash;Gordon P. Hemsley&rarr; &#x2709; 21:56, 12 July 2019 (UTC)

Yeah, there's no need to interlinearise if it's just a single line (so that aspect of the behaviour of the template will need to change). I guess the way I had envisaged that two-line use is for a native language sentence + free translation, without glosses. And that's kind of what's done in the two real-world examples I was able to find. In a way, there's no need for using this (or any other) template here. But if you need to use some of this template's bells and whistles (or if you don't, but are forced to for consistency with uses of the template in the same article), that will be difficult to do. An example: fai re-t-o

woman specific.location-near-U

'this woman' fai re-f-o

'this woman very near' – Uanfala (talk) 22:31, 12 July 2019 (UTC)
 * Ah, interesting examples. It seems to me these would more intuitively marked up by leaving the second line blank for these examples—where the glossing is implied by context. What do you think about that inversion (opting out of the second line instead of opting out of the third line)? Other thoughts: (1) I agree there's little reason to use this template for single words, though I suppose there's no way or even reason to stop someone from trying. (2) Should/can we do something to normalize quotation marks around the free translation? &mdash;Gordon P. Hemsley&rarr; &#x2709; 14:42, 13 July 2019 (UTC)
 * Normalising quotation marks, as in making sure across wikipedia only one type is used, I'd assume the single one? I have no opinion on that and won't object if anyone does it.
 * I hadn't thought of marking up the second line as blank, but now that you mention it, it does seem more intuitive in this particular case. But such a rule wouldn't scale up well to cases with more than three lines. An alternative I can think of is to change the default "glossing" line to be not the one that's second (counting from the start), but the one that's last but one. This seems like a good idea anyway: if there are many lines involved, the line with glosses is most likely to be the last one before the free translation, as extra lines are most often used to give several versions of the native text (different writing systems or transliterations, with or without morpheme breaks, etc.). What do you think? – Uanfala (talk) 18:07, 13 July 2019 (UTC)
 * I think that makes sense, from both perspectives. Lines 1 to (n−2) are interlinearized; line (n−1) is the gloss; line n is the free translation. Then n<3 becomes more obvious (n=1 would be free translation only; n=2 would be glossing + free translation), and it is easy to skip any section. Though this does bring back the question of why you would use this template with only one line.
 * Regarding quotation marks, I was pondering whether the free translation should be automatically wrapped in quotation marks, as opposed to added (or not added) by the author. I'm fine if we consider that separately, or not at all. &mdash;Gordon P. Hemsley&rarr; &#x2709; 12:22, 14 July 2019 (UTC)
 * Before you spelt it out, I guess I hadn't completely understood the obvious implication of the "glossing at n-2" rule for the case of n = 2. So that means glosses + free translation? I think that's probably the least likely way to use just two lines of "interlinear" text. But at least it makes the two likelier cases a lot more intuitive: want it without a free translation? – supply an empty last line; don't want a line of glosses? – let the second line be empty.
 * As for n = 1, I don't think anyone would expect interlinear to do anything at all in this case. I've added this functionality because we generally do need a way to easily format a long string containing several grammatical abbreviations (as found in glosses): it's better to have the following example – 1SG.SUBJ-3SG.OBJ-mach-APPL – created like this:
 * , than like that:
 * It's good to have some template do that, and I reckoned it might be easier to let that be the same template that formats multiple-line glosses. It's not that counter-intuitive, and it doesn't get in the way of other people using the template with n>2. What do you think?
 * I don't think quotation marks should be automatically added to the free translation. Because it's not always just a free translation: the last, non-interlinearised, line can also contain explanations (in addition to or instead of a free translation) or references. – Uanfala (talk) 22:56, 16 July 2019 (UTC)
 * I don't think quotation marks should be automatically added to the free translation. Because it's not always just a free translation: the last, non-interlinearised, line can also contain explanations (in addition to or instead of a free translation) or references. – Uanfala (talk) 22:56, 16 July 2019 (UTC)

Proposed changes to behaviour with unusual numbers of lines
Our goals here are two-fold, right? So I think we're in agreement now about what to do with 3 arguments but only two lines: simply skip the one you don't want to use. Code-wise, that means implementing (in the general case) line n as free translation, line n−1 as gloss, lines 1 through n−2 as non-gloss interlinear. For n=1, special case that the single line is gloss. For n=2, where the third argument is not explicitly left blank (to the extent that that's possible to determine), we can special case whatever the most likely scenario is if it differs from the general case.
 * 1) Make the template usage intuitive.
 * 2) Make the common case the default case.

If it makes sense, we could even implement the logic such that the gloss is the core of the template, and the addition of more lines means building up or down. So, n=1 means just the core: glossing; n=2 means build up: non-gloss interlinear, glossing; n=3 means build up then down: non-gloss interlinear, glossing, free translation; n=4 means build up then down then up: non-gloss interlinear, non-gloss interlinear, glossing, free translation; and so on. Does that make sense? &mdash;Gordon P. Hemsley&rarr; &#x2709; 11:41, 18 July 2019 (UTC)
 * I really like the idea of the gloss being the core of the template. This seems to capture all the normal use cases in a single scheme. But I'm a bit concerned about usability: n-1 is an easy rule to remember, n/2 rounded down plus one – not so much so. – Uanfala (talk) 22:10, 21 July 2019 (UTC)
 * I think if the template is built in a logical way, you won't need to remember the rule in order to have accurate intuitions about it. And besides, the rule need only be an implementation detail – I'm sure there are plenty of more easily memorized ways of explaining how to use it, including by making only minimal changes to the existing documentation. If you're on board, I say we go for it. &mdash;Gordon P. Hemsley&rarr; &#x2709; 01:43, 22 July 2019 (UTC)
 * In anticipation of some TDD, I've gone ahead and created Module:Interlinear/testcases and Module talk:Interlinear/testcases. (Documentation is at Lua and Module:UnitTests.) &mdash;Gordon P. Hemsley&rarr; &#x2709; 03:53, 22 July 2019 (UTC)
 * Thanks for starting the test cases: I've been meaning to do that for a long time. As for the new logic, well, count me on board. First, we'll need to have a look at existing uses to see if this won't clash with their logic: I'll tweak the module to populate Category:Pages with interlinear glosses using more than three unnamed parameters, which should supply us with the needed data. If everything looks alright, I can implement the change whenever I get some more free time within the next couple of weeks. Or if you then feel like going ahead with it yourself, by all means do. I see you've started making improvements to the module: thanks for that! I just don't quite get what you did in this edit: isn't the additional code practically redundant to the bit further down, where you've added the newline? – Uanfala (talk) 20:44, 23 July 2019 (UTC)

I admit that that edit is icky, but it was the quickest way to resolve an issue where explicitly specifying the same parameters as the defaults resulted in different output. (It was causing one or two of the new tests to fail.) There's probably a better way to fix that issue, but it would involve a broader refactoring of how things are output, which I didn't want to get into just yet.

I've been running the code through a linter to pick out some potential trouble points, and there are still a couple to address, but after that I'll look into what it would take to implement what we've laid out here. (I'm still working on familiarizing myself with both Lua and your code.) I'll probably start out by writing tests for what we expect the output to be, so we can coordinate on the progress to be made and any unexpected scenarios that may crop up. &mdash;Gordon P. Hemsley&rarr; &#x2709; 12:52, 24 July 2019 (UTC)
 * Oh yeah, I get what the problem was; the solution works for now. I've made a mention of the proposed changes at Template talk:Interlinear, and if no-one objects in a week or two, we can go ahead and implement it? In the meantime, I'll have a more detailed look at the existing uses tracked in the category. Also, I just thought I should mention (not that you won't have noticed already), that the module isn't really among the most readably written ones. – Uanfala (talk) 14:09, 26 July 2019 (UTC)

Development
Given your desire to socialize the change before we make it, I've created Module:Interlinear/testcases/parameters and Module talk:Interlinear/testcases/parameters to keep the development tests out of "production" until we've actually deployed the changes. Can you give them a look and make sure they match our expectations here? &mdash;Gordon P. Hemsley&rarr; &#x2709; 20:15, 28 July 2019 (UTC)

Comment on proposal and parameter choices
You invited comment on "this proposal", which linked only to this page, but I take it you meant the subsection above "Proposed changes to behaviour with unusual numbers of lines"? Now that I've read the entire page, and put that proposal in context, I do have a comment or two.
 * 1) First, congratulations! on just how good the gcl and interlinear are. And sincerely, thanks for all the hard work you've done.
 * 2) Second, I'm so glad to see you inviting (and achieving) productive dialogue with other editors. Seems that Gordon P. Hemsley has already made substantial contributions and will likely have much to offer, both as a linguist user and a coder comfortable with HTML and its styling.  (Particularly impressed by his liking for test-driven development!)
 * 3) On the matter you asked about, as a rule I favour explicit parameters, rather than implicit ones. In the case at hand, that would mean providing an explicit name for each type of line in the interlinear, e.g. thus: {{interlinear[|source= ); this is to allow for non-canonical line orders (say, annotations before source text:  ), and for multiple instances of each line type.
 * Maybe we could have a look at some examples?

{{collapse top|Extended examples}}
 * Two source lines
 * Code in current setup (assuming GPHemsley's proposal is implemented):
 * {{interlinear|italics2=yes
 * |tauna angun kiturkiit
 * |tauna angun kitur-k-iit
 * |that.ABS man.ABS pass.by-PTCP.TR-3PL/3SG
 * |'They passed that man.'}}
 * Code with explicit parameters:
 * {{interlinear
 * |source1 = tauna angun kiturkiit
 * |source2 = tauna angun kitur-k-iit
 * |gloss3 = that.ABS man.ABS pass.by-PTCP.TR-3PL/3SG
 * |free-translation4 = 'They passed that man.'}}
 * Two lines of glosses
 * Code in current setup:
 * {{interlinear|glossing3=yes
 * |tauna angun kitur-k-iit
 * |that.ABS man.ABS pass.by-PTCP.TR-3PL/3SG
 * |Determiner Noun Verb
 * |'They passed that man.'}}
 * Code with explicit parameters:
 * {{interlinear
 * |source1 = tauna angun kitur-k-iit
 * |gloss2 = that.ABS man.ABS pass.by-PTCP.TR-3PL/3SG
 * |annotation3 = Determiner Noun Verb
 * |free-translation = 'They passed that man.'}}
 * Glosses before source text:
 * Code in current setup:
 * {{interlinear|glossing1=yes|italics=2
 * |that.ABS man.ABS pass.by-PTCP.TR-3PL/3SG
 * |tauna angun kitur-k-iit
 * |'They passed that man.'}}
 * Code with explicit parameters:
 * {{interlinear
 * |gloss1 = that.ABS man.ABS pass.by-PTCP.TR-3PL/3SG
 * |source2 = tauna angun kitur-k-iit
 * |free-translation3 = 'They passed that man.'}}

{{collapse bottom}} Both schemes tend to lead to complexity, but in different ways. I will be interested in what others think as well. {{u|GPHemsley}}? As for the overrides in point #4, I don't think I've got a clear picture; yoyo, would you give an example? – Uanfala (talk) 03:04, 9 September 2019 (UTC)

Multiple bugs in Egyptian example
Egyptian language has a bespoke glossing table, reproduced below:

I have attempted to convert this to use Interlinear:

{ }     { }

d(m)ḏ.n.f {tꜣwj n} zꜣ.f nsw.t-bj.t(j) pr-jb.sn(j)

unite.PRF.3SG land.DUAL.PREP son.3SG sedge-bee house-heart.3PL

"He has united the Two Lands for his son, Dual King Peribsen."

However, there are multiple issues with the display: Additionally, attempting to identify the transliteration using either language code egy or script code Egyp results in an error about the transliteration scheme not being recognized, despite both being standard ways to use transl.
 * The most glaring one is that the hieroglyphs (formatted using ) are not properly supported, being correctly shown once and then incorrectly shown again without formatting.
 * Smaller but still consequential issues are the failure to detect the boundaries of  and wikilinks in the glossing line, thereby failing to properly format 3SG and DUAL, respectively.

I have not investigated the cause of these issues, or any potential solutions, but I am happy to help with debugging and/or coding to get them fixed. &mdash;Gordon P. Hemsley&rarr; &#x2709; 19:32, 21 July 2019 (UTC)


 * Well, the module wasn't really meant to be used with text structured in such a complicated way.  outputs html tables and they break the template in several ways. The immediate issue of the repeated hieroglyphs is down to the fact that at the end of the interlinear display the module outputs a hidden element containing the entirety of each line (that's for accessibility reasons). When the module tries to place the hierogyphs line (with all its tables) into a p element, it results in bad html, which gets corrected by moving the whole thing outside that element, and so the text gets exposed. This particular problem can be easily fixed by replacing div:tag("p") with div:tag("div") at line 787 of the current version of the module. However, the visible interlinear display itself uses  elements, so again the hieroglyphs fall out of that, with the result that they will slip out of the scope of any relevant parameters you've applied (like lang1). This can be fixed in a similar manner by making the interlinear display itself be rendered in  elements rather than  elements. I can't think off the top of my head of a reason why this could be a bad idea, but I'm not willing to make such a fundamental change without careful consideration.
 * The real problem is that hieroglyphs, or any other vertical scripts, can never be made to work well within interlinear. You might have noticed that the interlinear lines are vertically not well aligned: in the first word for example they reach a little bit lower than in the second word, that's because the first hieroglyph is a bit taller than the second one. I don't reckon there would be a way to fix that within the existing capabilities of the module. That's probably a case where the old method of doing glossed texts using tables actually works quite well. Of course, we could make the module detect hieroglyphs in the input and specifically format them using tables, but I think it's overall simpler if the few articles that need this just used wiki tables directly, as they do now.
 * As for the refs stopping the gloss from getting formatted, and the standard script identifier not getting recognised – these aren't supposed to be happening. I'll definitely have a look when I have a bit more time. Now, the gloss not getting recognised inside a wikilink: that's not a bug. The parser deliberately avoids doing anything to text within links, partly because it's assumed that a user who manually adds a link might have more specific ideas and so not be happy with the default behaviour, and partly because the risk of accidentally breaking something is greater than the benefit of saving a bit of typing time. You can just enclose "DUAL" in either sc or gcl. – Uanfala (talk) 22:00, 21 July 2019 (UTC)
 * I've just fixed the ref issue . – Uanfala (talk) 23:08, 21 July 2019 (UTC)
 * I can look more deeply into the internals later on, but might CSS flexbox be useful for the vertical alignment issues? Surely support for vertical orthographies is something we should look into handling better (outside of the HTML issues caused by ), no? Also, is repeating the text a second time really the best way to handle accessibility of glossing? I'll spend some time getting more familiar with the output that's generated and see if there's a better way. &mdash;Gordon P. Hemsley&rarr; &#x2709; 01:38, 22 July 2019 (UTC)
 * Incidetally,  is documented at Help:WikiHiero syntax and mw:Extension:WikiHiero. &mdash;Gordon P. Hemsley&rarr; &#x2709; 02:00, 22 July 2019 (UTC)
 * You'll be very welcome to look more closely. I know next to nothing about html, and the current html output is largely copied from another site (as documented here). – Uanfala (talk) 06:34, 22 July 2019 (UTC)
 * I hadn't heard of flexbox before. I take it that you're better acquainted with html than me, so I'll leave that for you: if you come up a way to support vertical text that won't have undesirable consequences, you're welcome to try it out. Personally, I don't see that as a priority, as it's a really niche use: apart from hieroglyphs, I can only think of the Old Uyghur and related scripts that go vertically. I have to admit though, that my initial misgivings about the potential of the html of  to break the template was misplaced. When the module processes wikitext, it sees the hieroglyphs not as html, but as strip markers, so it shouldn't have any more (or less) problems with them than it does with other extension tags, like .
 * As for accessibility, this again is an area in which I know next to nothing, so if you have any suggestions, I'm all ears. Repeating each line in a hidden div was simply copied from the external site I used as a model. And I think it makes sense: in the the template's output, the elements go in the order word 1, gloss 1, word 2, gloss 2, etc. For people with screen readers, this makes the connection between each word and its gloss obvious. What it doesn't make obvious at all, is that the relations can go horizontally as well: word 1, word 2, etc, form a sentence.
 * Just adding that I've been thinking it might be time to switch to using CSS classes (using TemplateStyles), which should remove a lot of the clutter from the html output. – Uanfala (talk) 21:20, 23 July 2019 (UTC)

It'd probably be good to wait until we've done the parameter work before we start on any of these major output changes, but I think we should figure out what the new output should ultimately look like before we start changing anything. I'm happy to take on the HTML and CSS aspects; I do have a lot of experience in those areas. As far as accessibility is concerned, I've been going back and forth between tables and flow content, trying to strike the right balance between semantic markup and display formatting. I haven't settled on a solution, and we'll probably need to iterate on this and solicit feedback, but I expect that duplicating the content is not the right way to go. (I'm not sure that having a screenreader read the content twice, once in each format, would not be the desired behavior, but perhaps I'm wrong.) In any case, we can come back to this later. &mdash;Gordon P. Hemsley&rarr; &#x2709; 12:58, 24 July 2019 (UTC)
 * Your help with the html will be greatly appreciated! I have to say that I wouln't mind even if fundamental aspects of it are re-examined; there certainly are other ways to format interlinear text: Glossa for instance uses  elements rather than divs (example). – Uanfala (talk) 14:23, 26 July 2019 (UTC)

Proposed feature: nested numbering
Current module Interlinear only provides a linear numbering feature. I wish to use this module to write some linguistics examples that are in a nested list form. For example, I can make something like this using a plain table: But this cannot be done using  parameter in the module. It would be great if such feature is implemented to the module. However, I do not have an expertise in Lua language nor do I have the authorization to edit a module, thus, I am leaving a proposal here. Thanks! --Benzenekim (talk) 10:27, 31 May 2020 (UTC)

, you could produce a similar result without using tables, and it's a lot simpler: (1) Jacaltec (Mayan), VAP (VSO) xa' ix te' hum wet an

gave CL:she CL:the book to:me 1

"She gave the book to me." xahtoj naj yiban no' cheh

go:up CL:he on CL:the horse

"He climbed on the horse." The trick is that the parameter accepts any string of characters, not just numbers, and that its name is number (not numbering, though I should probably add that as an alias; to be honest, I'm not completely happy with either parameter name, but haven't been able to come up with anything better). In the example, you can change the alignment by padding with nbsp where necessary, though there probably are more elegant ways of doing that. Does that work for you? If your proposal is to make a single invocation of the template capable of rendering several interlinearly glossed texts, then that is technically possible, but not practicable as it will add way too much complexity. – Uanfala (talk) 15:31, 31 May 2020 (UTC)
 * Thanks for the feedback! Although there will be some inconsistency if the article contains both nested and linear numberings, I think this is a feasible solution in general, at least for now. Thanks! – Benzenekim (talk) 07:13, 1 June 2020 (UTC)
 * I would do it thus:
 * xa' ix te' hum wet an

gave CL:she CL:the book to:me 1

"She gave the book to me." xahtoj naj yiban no' cheh

go:up CL:he on CL:the horse

"He climbed on the horse."
 * Eievie (talk) 04:51, 27 January 2024 (UTC)

tooltip content with links
I was trying to use with three unnamed arguments &mdash; in the example on Woods Cree I wanted   &mdash; but instead of showing argument #2 ("transitive animate") as the tooltip, it was showing the page title from the link ("Algonquian languages"). This seems to be a bug: argument #2 is being ignored. Or is there some other way to do what I wanted? 4pq1injbok (talk) 10:17 22 January 2023 (UTC)
 * Thanks for noticing this. It's definitely a bug. It can be fixed by changing the order in which the html elements are built up in format_gloss, that's between lines 299 and 334 of the current version of the module. However, that's a bit finicky to do right away, so I'll leave it until I set off working on the next version of the module. It's going to be at least a couple of months until then. In the meantime, the somewhat clumsy workaround that you can use is: TA. – Uanfala (talk) 13:27, 22 January 2023 (UTC)


 * Thanks, including for the workaround! 4pq1injbok (talk) 20:17, 24 January 2023 (UTC)

Pages transcluding nonexistent sections
I have traced hundreds of pages in Category:Pages transcluding nonexistent sections to this module. is there any way we can check for the existence of the section before calling #section ? thank you! Frietjes (talk) 22:26, 13 March 2023 (UTC)
 * Hmm, this category didn't exist when I was writing this module.. So, I think the error comes from line 522, when the module transcludes the page it's own looking for one particular WP:LST section (it needs that in order to implement the article-level custom abbreviations). I don't know much about how LST works, is there a way to make it perform the sort of check you're suggesting? – Uanfala (talk) 22:44, 13 March 2023 (UTC)
 * , something like [//en.wikipedia.org/w/index.php?title=Module%3AInterlinear%2Fsandbox&diff=1144637351&oldid=1144598188 this] should work, assuming we don't run into any string processing limitations. is there a page where we could test it?  or, do you have a better idea?  Frietjes (talk) 15:52, 14 March 2023 (UTC)
 * This breaks the functionality. Compare this page (which uses the module sandbox) with the standard version: you can see the errors by the sprinkling of red and by the message "Unknown glossing abbreviation(s)" at the end of each instance of the template. From a quick glance, I can't spot why this doesn't work. – Uanfala (talk) 19:25, 14 March 2023 (UTC)
 * , I fixed some typos, seems to work now? Frietjes (talk) 19:36, 14 March 2023 (UTC)
 * Yep, that works. Feel free to merge the changes out of the sandbox. But I'm wondering, is that how things are going to be in the long run? Until now, the module could just load the section and then do things with it depending on whether it was empty or not. But now before loading the section, the module will have to first load the entire page and search its wikitext. The effect on performance seems to be small (I checked 15 times, and the average slowdown was 4%, probably not enough to make much of a difference at present), but it doesn't seem like the optimal long-term solution. Or is it that I'm using LST in ways it was not designed to be used? – Uanfala (talk) 20:07, 14 March 2023 (UTC)
 * , thanks, now merged! we could experiment with doing the LST using string processing, instead of doing the  which may be faster, since we are now loading the page contents (see, for example, Module:Transcluder).  I could experiment with this if you think it would be useful.  I don't think you are necessarily using LST in a bad way, it's just that we have a new tracking category to find actual bad uses, which we are unable to distinguish from false positives. Frietjes (talk) 20:22, 14 March 2023 (UTC)
 * Thanks, but there's no need now, let's not complicate things. My hope is that if the use of LST here isn't completely unorthodox, then it would be possible in the future to filter out such false positives without having to change actual module code. – Uanfala (talk) 20:36, 14 March 2023 (UTC)
 * , sounds good, this most recent change has cut the number of entries in from about 1200 to about 350.  next to fix is Template:Births and deaths by year for decade and a couple others.  thanks again. Frietjes (talk) 20:42, 14 March 2023 (UTC)

Right-to-left option
When fs interlinear is used with languages that are written right-to-left, I would like an option to align the interlinear that way.

I tested it in Module:Interlinear/sandbox and I got this function working. It uses the param yes. Here's 2 demos:

Can someone sign off on this change before I go ahead and move it to the main Module:Interlinear? Eievie (talk) 06:15, 27 January 2024 (UTC)
 * This conversation follows on from Talk:Sarcophagus of Eshmunazar II There are some issues raised in the linked section which are not addressed yet:
 * The glyph order in each original-language word is still not reversed, which I would think is a major requirement for this change. My first attempt to implement this would be to call the lua  method on each original-language line instead of whatever is currently reversing the word order. (On further investigation, not such a good idea after all!)
 * All the parameter names in are lower-case, so please use rtl or whatever instead of RTL
 * The foreign-language line(s) are not highlighted as such (delimited by lang-specific html spans), even though the template invocation specifies lang
 * The left- or right-alignment of the lines needs to be restricted to a box (html div) with the width of the longest line – this is particularly clear with the Cypriot example. That box does not itself need to be right-aligned on the page, in fact would probably be better left-aligned. I was hoping specifying y would do the trick, but it does not (I'm not sure what determines the width of the box that is provided: update: the template seems not to play nicely with lists, a subsequent edit by Zinnober9 tidied the display up) :


 * -- Mirokado (talk) 14:55, 27 January 2024 (UTC)
 * (additional suggestion removed) I was thinking about also displaying the original line in its original character order, but since the display here is column-based, that would probably be just confusing. -- Mirokado (talk) 20:19, 27 January 2024 (UTC)
 * What do you mean by "original-language word"? The Phoenician is already aligned correctly within the word (I compared it to this for reference, and it's the same). Do you mean the Latinization? Writing the Latinization right-to-left would... be pretty unusual. Do you really think that'd be valuable?
 * I'll change the param case now
 * That is not a thing in the normal left-to-right interlinear either. That might be a reasonable thing to add, but it's outside the scope of my current project.
 * I can look into the logistics of how to do that, but making the template look like it's left-to-right, even though it's actually right-to-left, seems misleading. I think that the right-to-left template should look like its right-to-left somehow, so that people know how to interpret it.
 * Eievie (talk) 01:19, 28 January 2024 (UTC)
 * I'm preparing a response for this. See §Glyph order in words.
 * Thanks, fine now.
 * I agree this is a separate technical issue, so I will create a new section for it, see §Highlighting foreign language text as in template:lang.
 * We can clarify that by making the enclosing box, say, 3em wider than the longest line. It is not the whole template output that should be right-aligned, but the lines within it, with the exception of the final translated line which is left-aligned. The box itself should be left-aligned on the page, at least by default. See §Box width, margin spacing.
 * Off for a late lunch now, more later. -- Mirokado (talk) 13:22, 29 January 2024 (UTC)

Glyph order in words
Hello again Eievie: by "original-language word" I mean 𐤀𐤔𐤌𐤍𐤏𐤆𐤓 (ʾšmnʿzr, ʾèšmūnʿazar, Eshmunazar) etc.

In Kata Biblon which you linked to (the table just above the match for "Phoenician and Greek transliteration") the transliterations are presented as currently in Sarcophagus of Eshmunazar II, with whole sentences in columns for the stages of transcription, transliteration and translation. Here we are considering having successive lines for each stage, with the individual words of the inscription, transliteration and transcription in separate columns, followed by a line for the translation. This makes it easier to see how each word is being transformed (the columns cannot apply to the translation since word disposition may change). This already works nicely for languages written left-to-right, but it becomes confusing for right-to-left languages since the order of letters in the transliteration etc. is reversed compared to the order of the corresponding glyphs in the original language.

Here is a use case where following this glyph-to-letter correspondence is needed:
 * In Sarcophagus of Eshmunazar II, an example of Aramaic usage is given with Hebrew script and the transliteration. I wanted to add the corresponding Phoenician script but it seemed difficult to identify the correspondence. This would have been much easier if the corresponding glyphs and letters were in the same order in vertically aligned words.

Hardly any of our readers will be able to read such inscriptions fluently in the original script, so making it easy to compare one representation with another should have priority in this sort of comparison table. I agree that writing the transcriptions etc back-to-front would not be helpful! Thus reversing the whole original inscription is appropriate, but only in the context of this sort of word split table.

It is probably also important to present the inscription in its original correct form too. Your third example in Talk:Sarcophagus of Eshmunazar II goes some way towards showing that: the display problem there is the excessive misalignment of the first line. -- Mirokado (talk) 17:19, 29 January 2024 (UTC)


 * I still don't understand get what you're asking for here. Within their joint block, the pieces (𐤀𐤔𐤌𐤍𐤏𐤆𐤓; ʾšmnʿzr; ʾèšmūnʿazar; Eshmunazar) can either be left-aligned or right-aligned. I'm happy to do whichever you want.
 * {| class="wikitable"

! left-aligned ! right-aligned <p lang="phn" style="margin: 0px;">𐤀𐤔𐤌𐤍𐤏𐤆𐤓 <p style="margin: 0px; text-align: left;">ʾšmnʿzr <p style="margin: 0px; text-align: left; font-style: italic;">ʾèšmūnʿazar <p style="margin: 0px; text-align: left;">Eshmunazar <p lang="phn" dir="rtl" style="margin: 0px;">𐤀𐤔𐤌𐤍𐤏𐤆𐤓 <p style="margin: 0px; text-align: right;">ʾšmnʿzr <p style="margin: 0px; text-align: right; font-style: italic;">ʾèšmūnʿazar <p style="margin: 0px; text-align: right;">Eshmunazar
 * }
 * Or are you asking to reverse the letters? I think that would be confusing for the majority of readers.
 * {| class="wikitable"

! like this perhaps? <p lang="phn" dir="rtl" style="margin: 0px; text-align: right;">𐤀𐤔𐤌𐤍𐤏𐤆𐤓 <p style="margin: 0px; text-align: right;">rzʿnmšʾ <p style="margin: 0px;font-style: italic;">ʾèšmūnʿazar <p style="margin: 0px;">Eshmunazar
 * }
 * Or do you mean how the words are ordered in the template? That part just takes care of itself.

undefined
 * The "𐤁𐤍 𐤌𐤋𐤊" line is written right-to-left in the template, and the "bn mlk" line is written left-to-right, and the template just takes care of it and pairs the pieces up correctly regardless.
 * Eievie (talk) 03:04, 30 January 2024 (UTC)
 * Thanks again for your response. I have now investigated the template a bit more. If we reduce the width of the window, we can see that the interlinear display flows at smaller widths, thus supporting rather longer texts that in any of the examples we have been using. That means that what I have been thinking of would not work as well as I had hoped, so I have now struck point one above. -- Mirokado (talk) 22:44, 30 January 2024 (UTC)
 * I have looked at a couple of glossing rules (Leipzig, Humboldt) and they both specify left-alignment for the interlinear items. -- Mirokado (talk) 22:44, 30 January 2024 (UTC)
 * They say that, but they also categorically don't mention right-to-left languages, so I'm not sure that's applicable here. Eievie (talk) 01:01, 31 January 2024 (UTC)
 * Basically, I think something about the right-to-left version should visually signal that this is right-to-left. If the overall gloss hugs the left edge of the page (per the  thing), then I think the words should align right within the blocks. Or if not that, then something should align right to make it visually clear. Eievie (talk) 01:21, 31 January 2024 (UTC)
 * Yes, that is a good point. It is particularly noticeable in the Cypriot example. So please go with right-aligned words within the blocks. -- Mirokado (talk) 11:58, 1 February 2024 (UTC)

Box width, margin spacing
In various examples already provided for this change, some lines which are not word-split for the table columns are separated from the table by their alignment to the page margins. This impairs readability and is not good graphic design. It should be corrected by an enclosing box (or whatever depending on implementation) whose width is related to the width of the main table. It would be fine to have left- and/or right-padding for the table to provide a small (say 3em) offset for the margins of the lines outside the table. -- Mirokado (talk) 17:19, 29 January 2024 (UTC)


 * Can you provide an example? I can't quite imagine what you mean by "some lines which are not word-split". Are you referring to Phoenician examples that use dots, rather than spaces, as word delimitators?
 * As for box width:
 * Right now the box has the default  property:   which takes 100% width.
 * The obvious change would be, but that would cause issues elsewhere. It would mean multiple narrow interlinear next to each other would stack up like this:
 * (1) a. <p style="margin: 0px;font-style: italic;">mə <p style="margin: 0px;"><abbr class="gloss-abbr" title="first person, singular" style="font-variant: small-caps; font-variant-numeric: oldstyle-nums; text-transform: lowercase;">1SG <p style="margin: 0px;font-style: italic;">kem <p style="margin: 0px;">see  <p style="margin: 0px;font-style: italic;">men <p style="margin: 0px;">child  <p style="display: none;">mə kem men <p style="display: none;">1SG see child <p style="clear: left;">'I saw the child'     (1) b. <p style="margin: 0px;font-style: italic;">mə <p style="margin: 0px;"><abbr class="gloss-abbr" title="first person, singular" style="font-variant: small-caps; font-variant-numeric: oldstyle-nums; text-transform: lowercase;">1SG  <p style="margin: 0px;font-style: italic;">ke? <p style="margin: 0px;"><abbr class="gloss-abbr" title="negation/negative" style="font-variant: small-caps; font-variant-numeric: oldstyle-nums; text-transform: lowercase;">NEG  <p style="margin: 0px;font-style: italic;">jen <p style="margin: 0px;">see  <p style="margin: 0px;font-style: italic;">men <p style="margin: 0px;">child  <p style="display: none;">mə ke? jen men <p style="display: none;">1SG NEG see child <p style="clear: left;">'I did not see the child'     (1) c. <p style="margin: 0px;font-style: italic;">mə <p style="margin: 0px;"><abbr class="gloss-abbr" title="first person, singular" style="font-variant: small-caps; font-variant-numeric: oldstyle-nums; text-transform: lowercase;">1SG  <p style="margin: 0px;font-style: italic;">do <p style="margin: 0px;"><abbr class="gloss-abbr" title="past tense" style="font-variant: small-caps; font-variant-numeric: oldstyle-nums; text-transform: lowercase;">PAST .<abbr class="gloss-abbr" title="recent past tense" style="font-variant: small-caps; font-variant-numeric: oldstyle-nums; text-transform: lowercase;">REC  <p style="margin: 0px;font-style: italic;">jen <p style="margin: 0px;">see  <p style="margin: 0px;font-style: italic;">men <p style="margin: 0px;">child  <p style="display: none;">mə do jen men <p style="display: none;">1SG PAST.REC see child <p style="clear: left;">'I just saw the child'     (1) d. <p style="margin: 0px;font-style: italic;">mə <p style="margin: 0px;"><abbr class="gloss-abbr" title="first person, singular" style="font-variant: small-caps; font-variant-numeric: oldstyle-nums; text-transform: lowercase;">1SG  <p style="margin: 0px;font-style: italic;">ke <p style="margin: 0px;">??  <p style="margin: 0px;font-style: italic;">njen <p style="margin: 0px;">see  <p style="margin: 0px;font-style: italic;">men <p style="margin: 0px;">child  <p style="display: none;">mə ke njen men <p style="display: none;">1SG ?? see child <p style="clear: left;">'It was me who saw the child'
 * appears to be a pretty good option right now. Not 100% width, but also not stackable because of the narrowness either.
 * <div class="interlinear" style="display:table;margin-left:4em;background-color:#f8f9fa;border:1px solid #eaecf0;padding:1em"> 10. <p lang="cprt" dir="rtl" style="margin: 0px;">𐠀𐠏𐠪𐠃𐠭𐠂 <p dir="rtl" style="margin: 0px;font-style: italic;">a-la-si-o-ta-i <p lang="cprt" dir="rtl" style="margin: 0px;">' <p dir="rtl" style="margin: 0px;font-style: italic;">'  <p lang="cprt" dir="rtl" style="margin: 0px;">𐠂𐠱𐠊𐠂 <p dir="rtl" style="margin: 0px;font-style: italic;">i-tu-ka-i  <p style="display: none;">𐠀𐠏𐠪𐠃𐠭𐠂 ' 𐠂𐠱𐠊𐠂 <p style="display: none;">a-la-si-o-ta-i ' i-tu-ka-i <p style="clear: right;">Alasiotas, for luck.   <div class="interlinear" style="display:table;margin-left:4em;background-color:#f8f9fa;border:1px solid #eaecf0;padding:1em"> 2. <p lang="phn" dir="rtl" style="margin: 0px;">𐤁𐤍 <p dir="rtl" style="margin: 0px;">bn <p dir="rtl" style="margin: 0px;font-style: italic;">bin  <p lang="phn" dir="rtl" style="margin: 0px;">𐤌𐤋𐤊 <p dir="rtl" style="margin: 0px;">mlk <p dir="rtl" style="margin: 0px;font-style: italic;">milk  <p lang="phn" dir="rtl" style="margin: 0px;">𐤕𐤁𐤍𐤕 <p dir="rtl" style="margin: 0px;">tbnt <p dir="rtl" style="margin: 0px;font-style: italic;">tabnīt  <p lang="phn" dir="rtl" style="margin: 0px;">𐤌𐤋𐤊 <p dir="rtl" style="margin: 0px;">mlk <p dir="rtl" style="margin: 0px;font-style: italic;">milk  <p lang="phn" dir="rtl" style="margin: 0px;">𐤑𐤃𐤍𐤌 <p dir="rtl" style="margin: 0px;">ṣdnm <p dir="rtl" style="margin: 0px;font-style: italic;">ṣīdōnīm  <p lang="phn" dir="rtl" style="margin: 0px;">𐤃𐤁𐤓 <p dir="rtl" style="margin: 0px;">dbr <p dir="rtl" style="margin: 0px;font-style: italic;">dabar  <p lang="phn" dir="rtl" style="margin: 0px;">𐤌𐤋𐤊 <p dir="rtl" style="margin: 0px;">mlk <p dir="rtl" style="margin: 0px;font-style: italic;">milk  <p lang="phn" dir="rtl" style="margin: 0px;">𐤀𐤔𐤌𐤍𐤏𐤆𐤓 <p dir="rtl" style="margin: 0px;">ʾšmnʿzr <p dir="rtl" style="margin: 0px;font-style: italic;">ʾèšmūnʿazar  <p lang="phn" dir="rtl" style="margin: 0px;">𐤌𐤋𐤊 <p dir="rtl" style="margin: 0px;">mlk <p dir="rtl" style="margin: 0px;font-style: italic;">milk  <p lang="phn" dir="rtl" style="margin: 0px;">𐤑𐤃𐤍𐤌 <p dir="rtl" style="margin: 0px;">ṣdnm <p dir="rtl" style="margin: 0px;font-style: italic;">ṣīdōnīm  <p lang="phn" dir="rtl" style="margin: 0px;">𐤋𐤀𐤌𐤓 <p dir="rtl" style="margin: 0px;">lʾmr <p dir="rtl" style="margin: 0px;font-style: italic;">līʾmōr  <p lang="phn" dir="rtl" style="margin: 0px;">𐤍𐤂𐤆𐤋𐤕 <p dir="rtl" style="margin: 0px;">ngzlt <p dir="rtl" style="margin: 0px;font-style: italic;">nagzaltī  <p style="display: none;">𐤁𐤍 𐤌𐤋𐤊 𐤕𐤁𐤍𐤕 𐤌𐤋𐤊 𐤑𐤃𐤍𐤌 𐤃𐤁𐤓 𐤌𐤋𐤊 𐤀𐤔𐤌𐤍𐤏𐤆𐤓 𐤌𐤋𐤊 𐤑𐤃𐤍𐤌 𐤋𐤀𐤌𐤓 𐤍𐤂𐤆𐤋𐤕 <p style="display: none;">bn mlk tbnt mlk ṣdnm dbr mlk ʾšmnʿzr mlk ṣdnm lʾmr ngzlt <p style="display: none;">bin milk tabnīt milk ṣīdōnīm dabar milk ʾèšmūnʿazar milk ṣīdōnīm līʾmōr nagzaltī <p style="clear: right;">son of king Tabnit, king of the Sidonians, king Eshmunazar, king of the Sidonians, said as follows: I was carried away
 * Eievie (talk) 17:09, 30 January 2024 (UTC)
 * In your original examples, you had a top line with the original script, and all examples have the bottom line with the English translation. Depending on the various alignment choices, one or other of these could end up separated from the interlinear lines which are shorter than the margin separation for a wide screen (less noticeable on a narrow screen). Your final example here using  is what I was looking for. It behaves nicely as the window is made narrower. Well done! If you are able to implement that (absent any unexpected problems of course) I can strike this point too. -- Mirokado (talk) 22:44, 30 January 2024 (UTC)

Highlighting foreign language text as in template:lang
I think it is desirable to apply the same markup to the foreign script in this template as is applied by. In my view this would be necessary if we are to use this template in articles where all the foreign script is already presented via the lang template(s). The relevant language can already be specified by lang, so not providing this markup may go against a user's expectations. -- Mirokado (talk) 17:19, 29 January 2024 (UTC)


 * I think this should go beyond just lang, to a broader feature where we can wrap each word of $$n$$ line in $$x$$ template. It could default to:
 * fs interlinear
 * line 1: script
 * line 2: transliteration
 * interlinear
 * line 1: lang
 * but alterable with additional parameters, just as the default italics and glossing can be altered. Eievie (talk) 17:18, 30 January 2024 (UTC)
 * Yes, by all means consider a broader feature. You are right that markup is only relevant for the original-language line. As far as I can see, lang should be used for line 1 in both the above cases when that line is in a particular language. -- Mirokado (talk) 22:58, 30 January 2024 (UTC)

Template overhaul
In the file Module:Interlinear/sandbox2, I have been working on a substantially changed version of the Lua code. Testing/examples of it can be seen on Template:Interlinear/sandbox/testcases.

The main categories of changes are:

Eievie (talk) 17:56, 1 February 2024 (UTC)
 * 1) Moving as much of the CSS code as possible out of the Lua file and into the file ../styles.css. Having the CSS code in one place and controlled by classes (rather than  ) makes it cleaner and easier to alter.
 * 2) Adding the right-to-left yes feature
 * 3) (in progress) Integrating the use of other Wikipedia templates into interlinear glosses, namely: script, lang, transliteration, IPA. Ideally there would be a parameter along the same lines as yes — perhaps wrapper$n$ — which would allow a user to specify a template to apply to each word of a line.
 * 4) Creating a yes parameter, as it appears that many people like to format transliteration of inscriptions that way (particularly the Phoenician and Ogham ones)
 * 5) (to do) Clean up the glossing code somehow. Move it to a second module, which is called upon? Not sure what yet, but right now it's the least readable part of the file and it's driving me slightly crazy. Within the broader category of integrating other templates into it, I'm thinking about some form of creating a separate  template or module which is called upon.