Server-side Zotero translation
Currently supports import, export, and web translation
The recommended version of translation-server for production use is available from Docker Hub:
docker run --rm -p 1969:1969 zotero/translation-server
git clone --recursive https://github.com/zotero/translation-server
cd translation-server
docker build -t translation-server .
docker run --rm -p 1969:1969 translation-server
You can test changes without rebuilding the image each time. First, run ./fetch_sdk once to install the Firefox SDK. (The SDK won’t be used in your build, but it’s required by the build script.) Then, after each change, run the build script and a modified docker run:
./build.sh && docker run -ti --rm -v `pwd`/build/app/:/opt/translation-server/app/ translation-server
This will copy files from src, modules/zotero/build, modules/zotero-connectors into build and mount that directory in the container in place of the directory created during the docker build step above.
If you’re changing files in the main Zotero repository, be sure to run npm start there and leave it running as you make changes to keeps its build subdirectory up to date. If you already have Zotero or Zotero Connector repositories on your system, you can pass -d ~/zotero-client/build or -c ~/zotero-connectors to ./build.sh above to use those directories instead of the submodules used by default.
To inspect the container before running the server, include --entrypoint /bin/bash in the docker run command.
To run translator tests, add -test /tmp/results.json to the end of the docker run line. You can specify individual tests to run by adding translator labels (e.g., "ACM Digital Library") to the includeTranslators array in chrome/content/zotero/tools/testTranslators/translatorTester.js in the main Zotero repo.
When you’re done, ensure your changes are applied to modules/zotero and modules/zotero-connector (either manually or by updating the submodule to point to your own fork of those repos) and rebuild the translation-server image to incorporate your changes.
Install required libraries (e.g., by installing Firefox)
git clone --recursive https://github.com/zotero/translation-server
cd translation-server
./fetch_sdk
./build.sh
Run the server:
$ build/run_translation-server.sh
zotero(3)(+0000000): HTTP server listening on *:1969
$ curl -d '{"url":"http://www.tandfonline.com/doi/abs/10.1080/15424060903167229","sessionid":"abc123"}' \
--header "Content-Type: application/json" \
127.0.0.1:1969/web
Supported endpoints are: /web, /import, /export, and /refresh.
Read server_translation.js for more information.
Translates a web page
/webPOSTurl and a random sessionidcurl -X POST --header 'Content-Type: application/json' -d '{
"url": "http://papers.ssrn.com/sol3/papers.cfm?abstract_id=1664470",
"sessionid": "abc123"
}' 127.0.0.1:1969/web
Converts input in any format Zotero can import (RIS, BibTeX, etc.) to items in Zotero API JSON format
/importPOSTcurl -X POST -d 'TY - JOUR
TI - Die Grundlage der allgemeinen Relativitätstheorie
AU - Einstein, Albert
PY - 1916
SP - 769
EP - 822
JO - Annalen der Physik
VL - 49
ER -' 127.0.0.1:1969/import
Converts items in Zotero API JSON format to a supported export format (RIS, BibTeX, etc.)
/exportPOSTformat, which must be a supported export formatContent type
Image
Digest
Size
242.1 MB
Last updated
over 9 years ago
docker pull zuphilip/translation-server