Scaffold test results different from results in production

edited December 19, 2022
I want to export the tags that I have for items from Zotero 6.0 to Tana, although I don't think that the destination particularly matters in this case. I have the following code (among a lot of other code) in Scaffold:
"// topics
Zotero.write(" - Topic:: \n");
for (let i = 0; i < item.tags.length; i++) {
Zotero.write(" - [[" + (item.tags[i].tag) + "]]\n");
}"

When I "run do" in Scaffold against a book in my library, the display shows the following results for that code:
" - Topic::
- [[Art]]
- [[Asian]]
- [[Crafts]]
- [[Esthetics]]
- [[Japan]]
- [[Philosophy]]
- [[Theory]]
"
This is the result that I want and was expecting. But, when I save the code (not using Scaffolding since save doesn't appear to work there, but that is another topic) to the translators directory on Windows 10, and then, using the new translator code, export the data for the same book, none of the above output is written. It is as though it just skips the code. All the other data that I am trying to export is written to the export file as I expected.

Anyone have any suggestions about what I am doing wrong and why my test results might not match the production results?
  • Would you mind sharing the full code for testing (gist.github.com or pastebin.com or a similar site)
  • Never mind... {slinks away with tail between legs}

    I forgot that Zotero does not load translators on the fly and that I have to stop and restart Zotero to pick up any changes to the code. Something I knew and then completely forgot for 6 hours today.

    (sigh)
  • Hmm -- export translators should *update* on the fly actually. They just don't load at all if they (i.e. a translator with that ID) don't exist at startup.
    Might have been something else?
  • edited December 20, 2022
    Hmmm, not sure. It's not like I have that much experience. This is only my second translator and both are relatively simple compared to some out there.

    I know I've had the problem before where I've had to close Zotero and re-start it to see changes I've made to the javascript code of an export translator, but is it every time? In retrospect, I doubt it.

    All of the changes to one of the translators would have the same translator ID, since I am just re-saving the same file.

    Could it have something to do with whether or not I've used the translator before to export something during the same session? Could it have something to do with having the translator named in the quick-copy preferences?
  • Some limited further testing shows that it is caused by having used either a quick copy and/or an export that made use of the translator; quite what the sequence is I'm not sure. But somewhere along the way the translator gets loaded and not unloaded until a restart. Didn't test what would happen if I shifted back and forth between export translators. I assume that would also solve the problem, but I don't know that.
  • Might have change for version 6 -- I used to test export translators like that entirely. FWIW, there is a translator reload command that you should be able to run from the Zotero javascript console to avoid restarting, but I'd have to dig to find that -- someone else probably knows, though
  • That would be great if someone could lay their hands on it for me.
  • Try Zotero.Translators.init() in the javacript console (https://www.zotero.org/support/dev/client_coding/javascript_api ).

    It does indeed look like the pre-loading behavior here changed slightly in 6.0
    https://groups.google.com/g/zotero-dev/c/7UE3441sug8/m/Hs9mdwJWAQAJ
Sign In or Register to comment.