using a self-made translator

I'm struggling to make a translator for the dansih legal site www.retsinformation.dk.

So far, I've managed to scrape metadata from the webpage and into an object that I have constructed with like this:

var newItem = new Zotero.Item("statute");
newItem.title = getTitle(doc, url);
newItem.shortTitle = infoArray[0];
newItem.dateEnacted = statuteInfo[1];
newItem.publicLawNumber = statuteInfo[0];
newItem.complete();

When I 'Run doWeb' in Scaffold I get this output:

10:24:37 Returned item:
{
"itemType": "statute"
"creators": []
"notes": []
"tags": []
"seeAlso": []
"attachments": []
- "title": "Bekendtgørelse af lov om forbud mod forskelsbehandling på arbejdsmarkedet m.v. 1)"
"shortTitle": "Forskelsbehandlingsloven"
"dateEnacted": "16/12/2008"
"publicLawNumber": "LBK nr 1349"
- "libraryCatalog": "Retsinformation"
+ "nameOfAct": "Bekendtgørelse af lov om forbud mod forskelsbehandling på arbejdsmarkedet m.v. 1)"
}
10:24:37 Translation successful


This all look fine to me, but the Zotero icon in the menu doesn't change, it's still set to web page, and I can't choose to save as a statute.
It's probably just some minor oversight on my part, but I'm pretty stumped.
  • My best guess would be that you're not setting a target (or not setting a correct one). In the "Metadata" tab, do you have a Target set. If you click on "Test Regex" do you get "True" when you're on a page you want to detect?

    If that's not it, post the entire translator (not just what you see in Scaffold -- get the whole file from the translator folder in your zotero data directory) to gist.github.com create a private gist, and link to it from here.
  • Thanks for the answer Adamsmith.

    Today it works. Maybe Zotero needed to be restarted in order to 'recognize' the new translator?

    Anyway, the translator can now succesfully scrape a single statute from the webpage, now I just need to make it differentiate between types, and be able to scrape multiple items. You'll probably hear from me again, when I get stumped next time.
  • Ah yes. Zotero loads a list of all targets on Firefox start, so you do need to restart to initialize a new translator. This is not the case of other changes you make. Those will take effect immediately after saving them in Scaffold and (importantly) reloading the page.
Sign In or Register to comment.