mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-11-28 19:01:02 +00:00
commit
a579da752d
1 changed files with 75 additions and 75 deletions
64
README.md
64
README.md
|
@ -8,12 +8,10 @@ Free and Open Source Machine Translation API, entirely self-hosted. Unlike other
|
||||||
|
|
||||||
![image](https://user-images.githubusercontent.com/64697405/139015751-279f31ac-36f1-4950-9ea7-87e76bf65f51.png)
|
![image](https://user-images.githubusercontent.com/64697405/139015751-279f31ac-36f1-4950-9ea7-87e76bf65f51.png)
|
||||||
|
|
||||||
|
|
||||||
[Try it online!](https://libretranslate.com) | [API Docs](https://libretranslate.com/docs)
|
[Try it online!](https://libretranslate.com) | [API Docs](https://libretranslate.com/docs)
|
||||||
|
|
||||||
## API Examples
|
## API Examples
|
||||||
|
|
||||||
|
|
||||||
### Simple
|
### Simple
|
||||||
|
|
||||||
Request:
|
Request:
|
||||||
|
@ -108,9 +106,9 @@ pip install libretranslate
|
||||||
libretranslate [args]
|
libretranslate [args]
|
||||||
```
|
```
|
||||||
|
|
||||||
Then open a web browser to http://localhost:5000
|
Then open a web browser to <http://localhost:5000>
|
||||||
|
|
||||||
On Ubuntu 20.04 you can also use the install script available at https://github.com/argosopentech/LibreTranslate-init
|
On Ubuntu 20.04 you can also use the install script available at <https://github.com/argosopentech/LibreTranslate-init>
|
||||||
|
|
||||||
## Build and Run
|
## Build and Run
|
||||||
|
|
||||||
|
@ -126,15 +124,14 @@ libretranslate [args]
|
||||||
python main.py [args]
|
python main.py [args]
|
||||||
```
|
```
|
||||||
|
|
||||||
Then open a web browser to http://localhost:5000
|
Then open a web browser to <http://localhost:5000>
|
||||||
|
|
||||||
### Run with Docker
|
### Run with Docker
|
||||||
|
|
||||||
Linux/MacOS: `./run.sh [args]`
|
Linux/MacOS: `./run.sh [args]`
|
||||||
Windows: `run.bat [args]`
|
Windows: `run.bat [args]`
|
||||||
|
|
||||||
Then open a web browser to http://localhost:5000
|
Then open a web browser to <http://localhost:5000>
|
||||||
|
|
||||||
|
|
||||||
### Build with Docker
|
### Build with Docker
|
||||||
|
|
||||||
|
@ -157,7 +154,7 @@ docker-compose up -d --build
|
||||||
```
|
```
|
||||||
|
|
||||||
> Feel free to change the [`docker-compose.yml`](https://github.com/LibreTranslate/LibreTranslate/blob/main/docker-compose.yml) file to adapt it to your deployment needs, or use an extra `docker-compose.prod.yml` file for your deployment configuration.
|
> Feel free to change the [`docker-compose.yml`](https://github.com/LibreTranslate/LibreTranslate/blob/main/docker-compose.yml) file to adapt it to your deployment needs, or use an extra `docker-compose.prod.yml` file for your deployment configuration.
|
||||||
|
>
|
||||||
> The models are stored inside the container under `/home/libretranslate/.local/share` and `/home/libretranslate/.local/cache`. Feel free to use volumes if you do not want to redownload the models when the container is destroyed. To update the models, use the `--update-models` argument.
|
> The models are stored inside the container under `/home/libretranslate/.local/share` and `/home/libretranslate/.local/cache`. Feel free to use volumes if you do not want to redownload the models when the container is destroyed. To update the models, use the `--update-models` argument.
|
||||||
|
|
||||||
### CUDA
|
### CUDA
|
||||||
|
@ -225,15 +222,14 @@ Alternatively you can also run the `scripts/install_models.py` script.
|
||||||
|
|
||||||
## Run with WSGI and Gunicorn
|
## Run with WSGI and Gunicorn
|
||||||
|
|
||||||
```
|
```bash
|
||||||
pip install gunicorn
|
pip install gunicorn
|
||||||
gunicorn --bind 0.0.0.0:5000 'wsgi:app'
|
gunicorn --bind 0.0.0.0:5000 'wsgi:app'
|
||||||
```
|
```
|
||||||
|
|
||||||
You can pass application arguments directly to Gunicorn via:
|
You can pass application arguments directly to Gunicorn via:
|
||||||
|
|
||||||
|
```bash
|
||||||
```
|
|
||||||
gunicorn --bind 0.0.0.0:5000 'wsgi:app(api_keys=True)'
|
gunicorn --bind 0.0.0.0:5000 'wsgi:app(api_keys=True)'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -256,6 +252,7 @@ ltmanage keys add 120
|
||||||
```
|
```
|
||||||
|
|
||||||
If you changed the API keys database path:
|
If you changed the API keys database path:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
ltmanage keys --api-keys-db-path path/to/db/dbName.db add 120
|
ltmanage keys --api-keys-db-path path/to/db/dbName.db add 120
|
||||||
```
|
```
|
||||||
|
@ -276,9 +273,9 @@ ltmanage keys
|
||||||
|
|
||||||
LibreTranslate has Prometheus [exporter](https://prometheus.io/docs/instrumenting/exporters/) capabilities when you pass the `--metrics` argument at startup (disabled by default). When metrics are enabled, a `/metrics` endpoint is mounted on the instance:
|
LibreTranslate has Prometheus [exporter](https://prometheus.io/docs/instrumenting/exporters/) capabilities when you pass the `--metrics` argument at startup (disabled by default). When metrics are enabled, a `/metrics` endpoint is mounted on the instance:
|
||||||
|
|
||||||
http://localhost:5000/metrics
|
<http://localhost:5000/metrics>
|
||||||
|
|
||||||
```
|
```promql
|
||||||
# HELP libretranslate_http_requests_in_flight Multiprocess metric
|
# HELP libretranslate_http_requests_in_flight Multiprocess metric
|
||||||
# TYPE libretranslate_http_requests_in_flight gauge
|
# TYPE libretranslate_http_requests_in_flight gauge
|
||||||
libretranslate_http_requests_in_flight{api_key="",endpoint="/translate",request_ip="127.0.0.1"} 0.0
|
libretranslate_http_requests_in_flight{api_key="",endpoint="/translate",request_ip="127.0.0.1"} 0.0
|
||||||
|
@ -290,7 +287,7 @@ libretranslate_http_request_duration_seconds_sum{api_key="",endpoint="/translate
|
||||||
|
|
||||||
You can then configure `prometheus.yml` to read the metrics:
|
You can then configure `prometheus.yml` to read the metrics:
|
||||||
|
|
||||||
```
|
```yaml
|
||||||
scrape_configs:
|
scrape_configs:
|
||||||
- job_name: "libretranslate"
|
- job_name: "libretranslate"
|
||||||
|
|
||||||
|
@ -306,7 +303,7 @@ To secure the `/metrics` endpoint you can also use `--metrics-auth-token mytoken
|
||||||
|
|
||||||
If you use Gunicorn, make sure to create a directory for storing multiprocess data metrics and set `PROMETHEUS_MULTIPROC_DIR`:
|
If you use Gunicorn, make sure to create a directory for storing multiprocess data metrics and set `PROMETHEUS_MULTIPROC_DIR`:
|
||||||
|
|
||||||
```
|
```bash
|
||||||
mkdir -p /tmp/prometheus_data
|
mkdir -p /tmp/prometheus_data
|
||||||
rm /tmp/prometheus_data/*
|
rm /tmp/prometheus_data/*
|
||||||
export PROMETHEUS_MULTIPROC_DIR=/tmp/prometheus_data
|
export PROMETHEUS_MULTIPROC_DIR=/tmp/prometheus_data
|
||||||
|
@ -317,23 +314,23 @@ gunicorn -c scripts/gunicorn_conf.py --bind 0.0.0.0:5000 'wsgi:app(metrics=True)
|
||||||
|
|
||||||
You can use the LibreTranslate API using the following bindings:
|
You can use the LibreTranslate API using the following bindings:
|
||||||
|
|
||||||
- Rust: https://github.com/DefunctLizard/libretranslate-rs
|
- Rust: <https://github.com/DefunctLizard/libretranslate-rs>
|
||||||
- Node.js: https://github.com/franciscop/translate
|
- Node.js: <https://github.com/franciscop/translate>
|
||||||
- .Net: https://github.com/sigaloid/LibreTranslate.Net
|
- .Net: <https://github.com/sigaloid/LibreTranslate.Net>
|
||||||
- Go: https://github.com/SnakeSel/libretranslate
|
- Go: <https://github.com/SnakeSel/libretranslate>
|
||||||
- Python: https://github.com/argosopentech/LibreTranslate-py
|
- Python: <https://github.com/argosopentech/LibreTranslate-py>
|
||||||
- PHP: https://github.com/jefs42/libretranslate
|
- PHP: <https://github.com/jefs42/libretranslate>
|
||||||
- C++: https://github.com/argosopentech/LibreTranslate-cpp
|
- C++: <https://github.com/argosopentech/LibreTranslate-cpp>
|
||||||
- Swift: https://github.com/wacumov/libretranslate
|
- Swift: <https://github.com/wacumov/libretranslate>
|
||||||
- Unix: https://github.com/argosopentech/LibreTranslate-sh
|
- Unix: <https://github.com/argosopentech/LibreTranslate-sh>
|
||||||
- Shell: https://github.com/Hayao0819/Hayao-Tools/tree/master/libretranslate-sh
|
- Shell: <https://github.com/Hayao0819/Hayao-Tools/tree/master/libretranslate-sh>
|
||||||
- Java: https://github.com/suuft/libretranslate-java
|
- Java: <https://github.com/suuft/libretranslate-java>
|
||||||
-
|
|
||||||
## Discourse Plugin
|
## Discourse Plugin
|
||||||
|
|
||||||
You can use this [discourse translator plugin](https://github.com/LibreTranslate/discourse-translator) to translate [Discourse](https://discourse.org) topics. To install it simply modify `/var/discourse/containers/app.yml`:
|
You can use this [discourse translator plugin](https://github.com/LibreTranslate/discourse-translator) to translate [Discourse](https://discourse.org) topics. To install it simply modify `/var/discourse/containers/app.yml`:
|
||||||
|
|
||||||
```
|
```yaml
|
||||||
## Plugins go here
|
## Plugins go here
|
||||||
## see https://meta.discourse.org/t/19157 for details
|
## see https://meta.discourse.org/t/19157 for details
|
||||||
hooks:
|
hooks:
|
||||||
|
@ -350,10 +347,11 @@ Then issue `./launcher rebuild app`. From the Discourse's admin panel then selec
|
||||||
|
|
||||||
## Mobile Apps
|
## Mobile Apps
|
||||||
|
|
||||||
- [LibreTranslator](https://gitlab.com/BeoCode/libretranslator) is an Android app [available on the Play Store](https://play.google.com/store/apps/details?id=de.beowulf.libretranslater) and [in the F-Droid store](https://f-droid.org/packages/de.beowulf.libretranslater/) that uses the LibreTranslate API.
|
- [LibreTranslator](https://codeberg.org/BeoCode/LibreTranslator) is an Android app [available on the Play Store](https://play.google.com/store/apps/details?id=de.beowulf.libretranslater) and [in the F-Droid store](https://f-droid.org/packages/de.beowulf.libretranslater/) that uses the LibreTranslate API.
|
||||||
- [LiTranslate](https://github.com/viktorkalyniuk/LiTranslate-iOS) is an iOS app [available on the App Store](https://apps.apple.com/us/app/litranslate/id1644385339) that uses the LibreTranslate API.
|
- [LiTranslate](https://github.com/viktorkalyniuk/LiTranslate-iOS) is an iOS app [available on the App Store](https://apps.apple.com/us/app/litranslate/id1644385339) that uses the LibreTranslate API.
|
||||||
|
|
||||||
## Web browser
|
## Web browser
|
||||||
|
|
||||||
- [minbrowser](https://minbrowser.org/) is a web browser with [integrated LibreTranslate support](https://github.com/argosopentech/argos-translate/discussions/158#discussioncomment-1141551).
|
- [minbrowser](https://minbrowser.org/) is a web browser with [integrated LibreTranslate support](https://github.com/argosopentech/argos-translate/discussions/158#discussioncomment-1141551).
|
||||||
- A LibreTranslate Firefox addon is [currently a work in progress](https://github.com/LibreTranslate/LibreTranslate/issues/55).
|
- A LibreTranslate Firefox addon is [currently a work in progress](https://github.com/LibreTranslate/LibreTranslate/issues/55).
|
||||||
|
|
||||||
|
@ -375,7 +373,6 @@ URL |
|
||||||
[lt.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion](http://lt.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion/)|
|
[lt.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion](http://lt.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion/)|
|
||||||
[lt.vern.i2p](http://vernf45n7mxwqnp5riaax7p67pwcl7wcefdcnqqvim7ckdx4264a.b32.i2p/)|
|
[lt.vern.i2p](http://vernf45n7mxwqnp5riaax7p67pwcl7wcefdcnqqvim7ckdx4264a.b32.i2p/)|
|
||||||
|
|
||||||
|
|
||||||
## Adding New Language Models
|
## Adding New Language Models
|
||||||
|
|
||||||
To add new languages you first need to train an Argos Translate model. See [this video](https://odysee.com/@argosopentech:7/training-an-Argos-Translate-model-tutorial-2022:2?r=DMnK7NqdPNHRCfwhmKY9LPow3PqVUUgw) for details.
|
To add new languages you first need to train an Argos Translate model. See [this video](https://odysee.com/@argosopentech:7/training-an-Argos-Translate-model-tutorial-2022:2?r=DMnK7NqdPNHRCfwhmKY9LPow3PqVUUgw) for details.
|
||||||
|
@ -387,7 +384,8 @@ First you need to collect data, for example from [Opus](http://opus.nlpl.eu/), t
|
||||||
The LibreTranslate Web UI is available in all the languages for which LibreTranslate can translate to. It can also (roughly) [translate itself!](https://github.com/LibreTranslate/LibreTranslate/blob/main/scripts/update_locales.py) Some languages might not appear in the UI since they haven't been reviewed by a human yet. You can enable all languages by turning on `--debug` mode.
|
The LibreTranslate Web UI is available in all the languages for which LibreTranslate can translate to. It can also (roughly) [translate itself!](https://github.com/LibreTranslate/LibreTranslate/blob/main/scripts/update_locales.py) Some languages might not appear in the UI since they haven't been reviewed by a human yet. You can enable all languages by turning on `--debug` mode.
|
||||||
|
|
||||||
To help improve or review the UI translations:
|
To help improve or review the UI translations:
|
||||||
- Go to https://hosted.weblate.org/projects/libretranslate/app/#translations. All changes are automatically pushed to this repository.
|
|
||||||
|
- Go to <https://hosted.weblate.org/projects/libretranslate/app/#translations>. All changes are automatically pushed to this repository.
|
||||||
- Once all strings have been reviewed/edited, open a pull request and change `libretranslate/locales/{code}/meta.json`:
|
- Once all strings have been reviewed/edited, open a pull request and change `libretranslate/locales/{code}/meta.json`:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
|
@ -453,9 +451,11 @@ In short, no. [You need to buy an API key](https://portal.libretranslate.com). Y
|
||||||
### Can I use LibreTranslate behind a reverse proxy, like Apache2 or Caddy?
|
### Can I use LibreTranslate behind a reverse proxy, like Apache2 or Caddy?
|
||||||
|
|
||||||
Yes, here are config examples for Apache2 and Caddy that redirect a subdomain (with HTTPS certificate) to LibreTranslate running on a docker at localhost.
|
Yes, here are config examples for Apache2 and Caddy that redirect a subdomain (with HTTPS certificate) to LibreTranslate running on a docker at localhost.
|
||||||
```
|
|
||||||
|
```bash
|
||||||
sudo docker run -ti --rm -p 127.0.0.1:5000:5000 libretranslate/libretranslate
|
sudo docker run -ti --rm -p 127.0.0.1:5000:5000 libretranslate/libretranslate
|
||||||
```
|
```
|
||||||
|
|
||||||
You can remove `127.0.0.1` on the above command if you want to be able to access it from `domain.tld:5000`, in addition to `subdomain.domain.tld` (this can be helpful to determine if there is an issue with Apache2 or the docker container).
|
You can remove `127.0.0.1` on the above command if you want to be able to access it from `domain.tld:5000`, in addition to `subdomain.domain.tld` (this can be helpful to determine if there is an issue with Apache2 or the docker container).
|
||||||
|
|
||||||
Add `--restart unless-stopped` if you want this docker to start on boot, unless manually stopped.
|
Add `--restart unless-stopped` if you want this docker to start on boot, unless manually stopped.
|
||||||
|
|
Loading…
Reference in a new issue