[Juris-M] Translator coding questions
Hello,
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.
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.
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.
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.
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.
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.
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!
https://github.com/zotero/zotero/commit/3fc38d750bc0b9efe3273f157019103ba3d52300#diff-c9b8090ac1c78b9c8297c04f22daf965a30d298f44d4cc8e533e37fffb220a5e
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?
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.
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]) {
newItem.addRelatedItem(this._IDMap[related]);
}
}
newItem.save();
}
}
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.
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.