[Juris-M] Translator coding questions


First of all, I'd like to state up front that I have no idea what I'm doing and that everything I've done so far has been the result of a long series of trial and errors.

I have a problem with a translator I've been working on for canlii.org .

I'm trying to use it to send to Juris-M cases from that website. Almost everything works, but I still have a few problems.

While most of my problems are Juris-M specific (court names not being right and not knowing how to import into the alternate language fields), there is one problem I have which is closer to the base Zotero functions, which is why I'm here to ask for help.

Simply put, I cannot get two items linked by "seeAlso" in the translator to show up as "related" in the actual Juris-M interface.

In order to conform to how Juris-M handles parallel citations, the translator I've working on creates two items for any cases that require the use of parallel citations. I've got it working to output two items, but I cannot get "seeAlso" to link them in the actual Juris-M interface. In Scaffold, when I run tests, they will show up with a correct value of "seeAlso", but once I try to use it to bring things into Juris-M itself, the "related" tab is always empty.

If anyone wants a peak at the mess of a translator that I code, here it is : https://github.com/Droitslinguistiques/translators/blob/master/CanLII.js

I'm warning you though. I don't know what I'm doing. The translator mostly works right now, but I am certain that anyone more experienced than me might have a hernia looking at my terrible messy code.

Thank you.
  • Hi, I'm far behind you with my attempts at translators but I think, I can at least point you at a working example: https://github.com/Droitslinguistiques/translators/blob/master/BAILII.js for British cases seems to do that nicely. Relevant lines are probably 612 and following, especially l. 650.
  • Thank you!

    I did just realize that I made a mistake. For some reason, my code hasn't uploaded to github, and the file I linked had a very old version of the translator on it.

    It should be better now. I'll work on it tomorrow and try and see if I can use your code to guide me on how to do this.
  • Just to make sure that there is no misunderstanding: it's not my code, I just found it :)
  • Ah, I see now, ok.

    The portion of the code for seeAlso is beyond my ability to understand right now.

    However, the neutral court code identifier thing at the top is wonderful. That is definitely something I'll see if I can use to solve the court name vs LRR name problem I've been having with courts.

    The other problem I'll have left is to find a way to scrape the info of the other language (if I'm scraping a french decision, get the english version, and vice-versa) and add that info the Juris-M multilingual fields.

    One problem at a time though. For now, I just want to make sure that I can get parallel citations to import correctly through seeAlso. I'll save the rest of my ambition for once I've solved that puzzle.
  • edited February 19, 2021
    Update: I just tried to use that translator you linked to import some cases from Bailii.org, and while the cases did import correctly, they were not linked in "related". So it seems that the "seeAlso" troubles I've been having with my code are also in this code as well.

    At this point, I'm wondering if that's a Juris-M issue, or a Zotero one.

    I tested a few different Zotero translators who have a seeAlso code, but none of them linked the items correctly.

    At this point, I'll try to raise an issue in Zotero's GitHub and hope for an answer there.
  • That's not good. I'm not at my computer at the moment, so I can't test right now. But it definitely worked on 22 October 2020 with Jurism on this page: http://www.bailii.org/uk/cases/UKSC/2019/41.html — altogether, 7 items were created and linked automatically.
  • edited February 19, 2021
    Hmmm I can't even get that to load the translator with Jurism. The Zotero translator loads fine, although it doesn't link the items, but the only jurism translator that loads is the web-page with snapshot one.

    Edit 1 : The translator runs fine in Scaffold, but from my browser, it doesn't detect a case or run properly.

    Edit 2 : I've replicated this problem in both Edge and Chrome. I'll test on another computer and see if the issue might just be my own computer or something else.
  • Just popping back in to say that I did end up getting a hold of my laptop and testing that page you sent me. 7 items were sent to Zotero, but they are not linked in the "related" tab.
  • I can confirm the same behaviour. Now I doubt that it was done automatically back in October. Although I don't remember doing so, I might well have linked them by hand.
  • Where would be the best place to raise this issue to get some attention? I tried to create an issue in the Zotero translator repository, but I'm not sure if that's the best place.
  • I think, you’re already using the right resources. But Frank is probably not be the right person to ping here. @adamsmith is among those with most experience, pershaps he might know whom to ask? As you remarked that it doesn’t work in Zotero either it’s most probably something around the translator infrastructure or the communication between the translator and Zotero. One place that might be better to ask for attention could be the Zotero-dev mailing list which is developer-oriented: https://groups.google.com/g/zotero-dev?pli=1
  • Thanks! I'll ask there then.

    I'm still learning as I go, so a lot of times, I'm not sure if an issue is worth bugging Frank over, since it might be a bug or might be my own lack of coding knowledge that is the problem, or if Frank is even the right person to ask. That dev mailing list looks to be a perfect solution to that problem!
  • Yeah, I had a quick look a couple of days back and this certainly doesn't appear to work as advertised in the documentation. I don't know if it's generally broken or just doesn't work for web translators
  • @adamsmith Hello! I'm just checking back in to see if you had a chance to look into this?
  • It's broken for all translators, both import and web, as far as I can tell, which means @dstillman or someone else from the core dev team would need to look at it.
  • I see. Well, at least I'm glad to know that it wasn't just a mistake on my part then.
  • edited April 14, 2021
    So, while my knowledge of any of this barely extends beyond a surface level understanding of how CSL works, I did find this :


    In this merge, the code for adding related items from seeAlso was commented out of translate_items. I think. Again, I know nothing.

    @dstillman was the ability to relate items through translators removed or changed to something else I haven't found yet?
  • Hello!

    I'm sorry to keep bumping this thread, but I would like to know if anyone has had a chance to look at this question.

    In Juris-M, linking together related items is a major part of how parallel citations are handled. If the "seeAlso" translator function was intentionally removed or replaced, I would like to know so that I can start figuring out another way to import parallel citations.
  • edited May 28, 2021
    Hello, me again.

    So, since I assumed that the developpers are quite busy, and that fixing adding related through web translators, I attempted to fix this myself.

    Thanks to the awesome documentation on tinkering with the Zotero source code, I managed to write something to replace the commented-out code and get related to work on web translators.

    Should I submit a pull request directly in Github, or is there some other way to get this fix looked at and considered for the main Zotero build?

    What I ended up doing is replacing the commented out _handleRelated function in translate_items with the following :

    "_handleRelated": function (item, newItem) {
    // add to ID map
    if (item.itemID || item.id) {
    this._IDMap[item.itemID || item.id] = newItem;

    // add see alsos
    if(item.seeAlso) {
    for(related in item.seeAlso) {
    if(this._IDMap[related]) {

    In the test suite I ran, it worked perfectly. Items were sent to Zotero connected like they should be.

    However, I don't know if me doing this broke anything else. As I've said over and over, I know nothing about coding or any of this. So I'm not sure how to run the bundled tests and make sure I didn't accidentally break something else...

    @fbennett @dstillman This is the part where I could really use a reply and some guidance please. I want to help, but aside from brute forcing solutions through trial and error, I've reached the limit of my knowledge on how any of this works.
  • Nevermind, looks like I spoke too soon...

    This code relates the second item to the first, the third item to the first and second, but it doesn't do it vice-versa.

    Back to the drawing board I guess.
  • Ok now it actually works and related ALL items together. I submitted pull requests to both Zotero and Juris-M
Sign In or Register to comment.