We’re in the process of updating the documentation for Zotero 5.0. Some documentation may be outdated in the meantime. Thanks for your understanding.
In Zotero >= 2.0, translators are just javascript files. While Scaffold 2.0 can ease translator development, some prefer to work directly on the filesystem. To do this, one should
One develops a translator to run on/against a given version of Zotero, which runs on/against a given version of Firefox. The easiest way to do this is just to use the current version of Zotero that is running in your current Firefox profile. One can identify the path to one's current Zotero directory using the Zotero UI: select the gear icon to dropdown its menu, and choose Preferences>Advanced>Show Data Directory.
While convenient, using one's current Zotero
To create a separate Zotero development environment,
When developing directly against the filesystem, one's translator development environment is
Zotero installs its translators and related code as files in the subdirectory translators
. I.e.
${FIREFOX_PROFILE}
then the path to your Zotero is
${FIREFOX_PROFILE}/zotero
${FIREFOX_PROFILE}/zotero
then the path to your translators, and hence to your translator development environment, is
${FIREFOX_PROFILE}/zotero/translators
(See above regarding using Zotero UI to identify the path to your current Zotero.)
TODO: how to get alternate/uplevel versions of translators?
At the highest level, a Zotero translator (for versions >= 2.0) consists of
translatorID
, which is the global identifier for the translator.detectWeb
function. This must return a string corresponding to a defined Zotero type. For a list of Zotero type names, see the values of the itemTypes.
* properties in this Zotero property list (or a newer one).doWeb
function. This actually writes an item corresponding to your web resource to your Zotero repository.TODO:
One can generate a completely new translator file using Scaffold 2.0.
translatorID
, but give some values for the label
, creator
, and target
fields. (Note your filename will be based on the value of the label
field: e.g. if you set that to foo
, your file will be named foo.js
)detectWeb
stub, e.g. function detectWeb () { return "book"; }
label
.However it is usually easier to create a new translator by copy/modify-ing an existing one. This can be done in one of several ways, including
translatorID
. Note that any Zotero update to the profile containing that file will overwrite your work.translatorID
for your copy/modified file. Edit the old field randomly, or (better) generate a new value using Scaffold 2.0.label
field match your new filename.detectWeb
and doWeb
functions.label
to match your filename (minus the .js
extension)translatorID
, preferably after generating a new value using Scaffold 2.0.detectWeb
and doWeb
functions as needed.One must
xterm
, terminal
, cmd
)before one can see output from, e.g., Zotero.debug() calls. See detailed instructions for linux, mac, and windows.
Zotero does not currently sense changes to a translator file after it has been loaded. The actions required to reload a modified translator depend on what has been modified: metadata or other code.
If you have made changes to the metadata block of your translator, you must restart the Firefox profile containing your modified translator.
If you have made changes to code outside the metadata block of your translator, you need only restart the page on which you want to run the translator.
Once your translator works on a subset of the sites on which you believe it should work, please contribute your translator to the community.