• Stars
    star
    121
  • Rank 293,002 (Top 6 %)
  • Language
    JavaScript
  • License
    Other
  • Created over 6 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Node.js-based server to run Zotero translators

Zotero Translation Server

Build Status

The Zotero translation server lets you use Zotero translators without the Zotero client.

Installation

Running via Docker

The easiest way to run a local instance of translation-server is via Docker.

docker pull zotero/translation-server
docker run -d -p 1969:1969 --rm --name translation-server zotero/translation-server

This will pull the latest image from Docker Hub and run it as a background process on port 1969. Use docker kill translation-server to stop it.

Running from source

First, fetch the source code and install Node dependencies:

  1. git clone --recurse-submodules https://github.com/zotero/translation-server

  2. cd translation-server

  3. npm install

Once you've set up a local copy of the repo, you can run the server in various ways:

Node.js

npm start

Docker (development)

Build from the local repo and run in foreground:

docker build -t translation-server .
docker run -ti -p 1969:1969 --rm translation-server

AWS Lambda

translation-server can also run on AWS Lambda and be accessed through API Gateway. You will need the AWS SAM CLI to deploy the server.

Copy and configure config file:

cp lambda_config.env-sample lambda_config.env

Test locally:

./lambda_local_test lambda_config.env

Deploy:

./lambda_deploy lambda_config.env

You can view the API Gateway endpoint in the Outputs section of the console output.

User-Agent

By default, translation-server uses a standard Chrome User-Agent string to maximize compatibility. This is fine for personal usage, but for a deployed service, it’s polite to customize User-Agent so that sites can identify requests and contact you in case of abuse.

You can do this by setting the USER_AGENT environment variable:

USER_AGENT='my-custom-translation-server/2.0 ([email protected])' npm start

If you find that regular requests are being blocked with a fully custom user-agent string, you can also add an identifier and contact information to the end of a standard browser UA string:

export USER_AGENT='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 my-custom-translation-server/2.0 ([email protected])'
npm start

Proxy Support

You can configure translation-server to use a proxy server by setting the HTTP_PROXY and HTTPS_PROXY environment variables:

HTTP_PROXY=http://proxy.example.com:8080 HTTPS_PROXY=http://proxy.example.com:8080 npm start

If your proxy server uses a self-signed certificate, you can set NODE_TLS_REJECT_UNAUTHORIZED=0 to force Node to ignore certificate errors.

It’s also possible to opt out of proxying for specific hosts by using the NO_PROXY variable. See the Node request library documentation for more details.

Running tests

npm test

Endpoints

Web Translation

Retrieve metadata for a webpage:

$ curl -d 'https://www.nytimes.com/2018/06/11/technology/net-neutrality-repeal.html' \
   -H 'Content-Type: text/plain' http://127.0.0.1:1969/web

Returns an array of translated items in Zotero API JSON format

Retrieve metadata for a webpage with multiple results:

$ curl -d 'https://www.ncbi.nlm.nih.gov/pubmed/?term=crispr' \
   -H 'Content-Type: text/plain' http://127.0.0.1:1969/web

Returns 300 Multiple Choices with a JSON object:

{
	"url": "https://www.ncbi.nlm.nih.gov/pubmed/?term=crispr",
	"session": "9y5s0EW6m5GgLm0",
	"items": {
		"u30044970": {
			"title": "RNA Binding and HEPN-Nuclease Activation Are Decoupled in CRISPR-Cas13a."
		},
		"u30044923": {
			"title": "Knockout of tnni1b in zebrafish causes defects in atrioventricular valve development via the inhibition of the myocardial wnt signaling pathway."
		},
		// more results
	}
}

To make a selection, delete unwanted results from the items object and POST the returned data back to the server as application/json.

Search Translation

Retrieve metadata from an identifier (DOI, ISBN, PMID, arXiv ID):

$ curl -d 10.2307/4486062 -H 'Content-Type: text/plain' http://127.0.0.1:1969/search

Export Translation

Convert items in Zotero API JSON format to a supported export format (RIS, BibTeX, etc.):

$ curl -d @items.json -H 'Content-Type: application/json' 'http://127.0.0.1:1969/export?format=bibtex'

Import Translation

Convert items in any import format to the Zotero API JSON format:

$ curl --data-binary @data.bib -H 'Content-Type: text/plain' http://127.0.0.1:1969/import

More Repositories

1

zotero

Zotero is a free, easy-to-use tool to help you collect, organize, annotate, cite, and share your research sources.
JavaScript
9,904
star
2

translators

Zotero Translators
JavaScript
1,229
star
3

zotero-connectors

Chrome, Firefox, Edge, and Safari extensions for Zotero
JavaScript
503
star
4

zotero-android

Zotero for Android
Kotlin
276
star
5

dataserver

Zotero Data Server
PHP
270
star
6

zotero-ios

Zotero for iOS
Swift
223
star
7

web-library

JavaScript
142
star
8

reader

PDF/EPUB/HTML reader for Zotero
JavaScript
121
star
9

zotero-standalone-build

Zotero client build utility
C++
120
star
10

citeproc-rs

CSL processor in Rust.
Rust
70
star
11

zoterobib

ZoteroBib is a free online bibliography generator from the makers of Zotero
JavaScript
68
star
12

zotero-libreoffice-integration

Zotero LibreOffice integration
Java
64
star
13

citeproc-js-server

Web service to generate citations and bibliographies using citeproc-js
JavaScript
60
star
14

zotero-bits

CSL-related community feedback for Zotero
56
star
15

make-it-red

Sample plugin for Zotero 7
JavaScript
47
star
16

zotero-word-for-windows-integration

Zotero Word for Windows integration
C++
46
star
17

zotero-schema

JSON representation of the Zotero data model
JavaScript
43
star
18

scaffold

Zotero translator creation IDE
Shell
38
star
19

translation-server-old

Server-side Zotero translation based on Mozilla xpcshell (deprecated)
JavaScript
35
star
20

publications

Easily display Zotero items on a webpage
JavaScript
32
star
21

zotero-google-docs-integration

JavaScript
32
star
22

note-editor

Note editor for Zotero
JavaScript
31
star
23

zotero-api-node

Zotero API client for Node.js
JavaScript
29
star
24

safari-app-extension

Swift
29
star
25

web-components

JS components used throughout zotero.org outside the web library
JavaScript
28
star
26

zotero-hello-world

Sample plugin for Zotero for Firefox
JavaScript
25
star
27

zotero-word-for-mac-integration

Zotero Word for Mac integration
Objective-C
23
star
28

pdf-worker

JavaScript
22
star
29

translate

Browser standalone zotero translator
JavaScript
17
star
30

cross-poppler

Compiles modified Poppler PDF tools for macOS, Windows and Linux
C++
15
star
31

styles-repo

Zotero styles page
PHP
13
star
32

zotero-build

Zotero client build scripts
Python
11
star
33

bundled-styles

CSL styles bundled with Zotero client
Shell
10
star
34

utilities

Zotero utility code
JavaScript
10
star
35

stream-server

Zotero Streaming API Server
JavaScript
9
star
36

cross-xpdf

C++
9
star
37

arkivo

JavaScript
8
star
38

epub.js

JavaScript
7
star
39

s3-full-text-indexer

JavaScript
5
star
40

full-text-indexer

Lambda functions to process full text from S3 and index in Elasticsearch
JavaScript
5
star
41

attachment-proxy

Allows online viewing of Zotero attachments
JavaScript
4
star
42

arkivo-sufia

A Zotero/Arkivo plugin to connect to Project Hydra services
JavaScript
3
star
43

provo

Zotero translator test automation
Shell
3
star
44

zfs-purge

Purge unused storage files from S3
JavaScript
3
star
45

eslint-config-zotero

ESLint shareable config for Zotero projects
JavaScript
3
star
46

markdown-translator-builder

Builds Markdown translator for Zotero notes export
JavaScript
3
star
47

client-downloads

Generate download links and update manifests for Zotero client
PHP
3
star
48

tinymce-clean-server

Node.js HTTP server to clean HTML using TinyMCE parsing/filtering logic
JavaScript
3
star
49

full-text-es-to-s3-migration

Script to migrate full-text content from Elasticsearch to S3
JavaScript
2
star
50

web-common

JavaScript
2
star
51

full-text-extractor

JavaScript
1
star