Translators are the core logic units that teach Zotero how to extract bibliographic metadata from a specific website, file format, or search result. Each translator is a self-contained JavaScript module paired with a JSON metadata header. TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/zotero/zotero-connectors/llms.txt
Use this file to discover all available pages before exploring further.
Zotero.Translators singleton — defined in src/common/translators.js — manages loading those modules from local storage, keeping them up-to-date by consulting the Zotero desktop client or the remote translator repository, and routing every page visit to the best matching translator so that detection can proceed.
Translator Types
Every translator is assigned a bitmasktranslatorType field. The connector recognises four types, stored in the TRANSLATOR_TYPES enum (aliased from Zotero.Translator.TRANSLATOR_TYPES):
| Type | Description |
|---|---|
import | Reads a structured file format (BibTeX, RIS, MARC, etc.) and produces Zotero items |
export | Serialises Zotero items to a structured format |
web | Detects and scrapes metadata from a live webpage |
search | Takes an identifier (DOI, ISBN, PMID) and queries a remote data source |
import and export. During initialisation, _load() iterates over all stored translators and pushes each one into every _cache bucket whose bit it matches.
Initialisation and the _cache Object
Zotero.Translators.init() is idempotent and promise-cached — subsequent calls return the same promise rather than re-loading.
_cache object maps each type name to a sorted array of Zotero.Translator instances:
priority field so that higher-priority (lower number) translators are tested first.
Translator Code Caching
Translator metadata (title, author, regexp, priority…) is always stored in thetranslatorMetadata preference as a JSON array. The JavaScript code for each translator is cached separately in the extension’s preference storage under the key prefix translatorCode_ followed by the translator’s UUID.
getCodeForTranslator() first checks in-memory (translator.code), then falls back to Zotero.Prefs.get('translatorCode_' + translatorID). On a cache miss it fetches from the Zotero desktop client or the remote repository and stores the result back into prefs for future calls.
URL Matching: getWebTranslatorsForLocation()
The inject script calls getWebTranslatorsForLocation(URI, rootURI) in the background to find which web translators apply to the current tab. Matching works as follows:
Resolve potential proxied URLs
Zotero.Proxies.getPotentialProxies(rootURI) returns a map of candidate unproxied URLs → proxy objects so that translator regexps can be tested against the real host.Test root and frame regexps
For every web translator in
_cache["web"], the code tests the translator’s webRegexp.root against each candidate root URL. Generic translators (no webRegexp.root) are only eligible when they can RUN_MODE_IN_BROWSER.Test frame regexps for iframes
When the current URI is inside a frame (
URI !== rootURI), translators that declare webRegexp.all are additionally tested against the frame URI.The
_fullFrameDetectionWhitelist hard-codes hosts (currently ['resolver.ebscohost.com']) whose frames are treated as root frames, enabling full translator matching even inside an iframe context.Translator Updates: updateFromRemote()
Updates are deduped by a module-level promise. The method accepts a reset flag that forces a full re-fetch rather than a diff:
_doUpdateFromRemote tries two sources in order:
- Zotero desktop client — calls
Zotero.Repo.getTranslatorMetadataFromZotero(), which posts to the connector’sgetTranslatorsendpoint and records the current timestamp inconnector.repo.lastCheck.localTime. - Remote repository — calls
Zotero.Repo.getTranslatorMetadataFromServer(reset), which fetches fromhttps://repo.zotero.org/repo/metadata?version=<ext_version>&last=<repoTime>.
Zotero.Repo: Fetching Translator Code
Zotero.Repo (src/common/repo.js) provides the lower-level fetch primitives:
getTranslatorCode(translatorID)
Tries the Zotero desktop client first (
getTranslatorCode endpoint), then falls back to https://repo.zotero.org/repo/code/<id>?version=<ext_version>. Validates the embedded metadata JSON and triggers Zotero.Translators.updateTranslator() if the fetched code is newer than stored metadata.getTranslatorMetadataFromServer(reset)
Fetches a full or differential metadata list from the repo. The
reset=true path passes last=0; otherwise it sends the Unix timestamp stored in connector.repo.lastCheck.repoTime. The Date response header is used to update that timestamp.Keeping Translators Updated: keepTranslatorsUpdated()
After init() completes, keepTranslatorsUpdated() runs as a self-scheduling async loop:
REPOSITORY_CHECK_INTERVAL: 86400). On failure, the retry interval drops to 1 hour (REPOSITORY_RETRY_INTERVAL: 3600).
Translator Hash Mechanism
When the Zotero desktop client responds to aping request it includes a translatorsHash (or sortedTranslatorHash) in the prefs object. The connector computes its own hash with getTranslatorsHash(sorted):
Zotero.Translators.updateFromRemote() is called immediately to pull the latest metadata from the desktop client.
Key Method Reference
Initialise the translator cache. Loads stored metadata from
translatorMetadata preference, or fetches from remote if this is the first launch. Idempotent.Returns a translator by UUID with code loaded (for
RUN_MODE_IN_BROWSER translators). Returns false if not found.Returns a translator object without loading its code. Useful for metadata-only lookups.
Returns all translators of a given type (
"import", "export", "web", "search") with code loaded. Pass debugMode=true to re-fetch code from Zotero Standalone.Finds web translators matching the given page URL. Returns a tuple of matched translators and corresponding proxy objects.
Converts one or more translator objects to plain JSON-serialisable objects using the supplied list of property names. Used internally with
Zotero.Translator.TRANSLATOR_CACHING_PROPERTIES.Fetches updated translator metadata from the Zotero desktop client, falling back to the remote repository. Pass
reset=true for a full re-fetch.Removes cached code for a translator from both in-memory state and the preferences store (
translatorCode_<id>).