mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-11-25 17:31:00 +00:00
Merge pull request #391 from dingedi/feature/clear-root
Make the github root less cluttered.
This commit is contained in:
commit
ad1fbcd54d
17 changed files with 37 additions and 31 deletions
|
@ -1,3 +1,3 @@
|
||||||
.git*
|
.git*
|
||||||
Dockerfile
|
docker
|
||||||
.Dockerfile.swp
|
.Dockerfile.swp
|
||||||
|
|
4
.github/workflows/publish-package.yml
vendored
4
.github/workflows/publish-package.yml
vendored
|
@ -26,7 +26,7 @@ jobs:
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install pytest flake8
|
pip install pytest flake8
|
||||||
pip install .
|
pip install .
|
||||||
python compile_locales.py
|
python scripts/compile_locales.py
|
||||||
|
|
||||||
- name: Check code style with flake8 (lint)
|
- name: Check code style with flake8 (lint)
|
||||||
run: |
|
run: |
|
||||||
|
@ -61,6 +61,6 @@ jobs:
|
||||||
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
|
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
|
||||||
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
|
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
|
||||||
run: |
|
run: |
|
||||||
python compile_locales.py
|
python scripts/compile_locales.py
|
||||||
python setup.py sdist bdist_wheel
|
python setup.py sdist bdist_wheel
|
||||||
twine upload dist/*
|
twine upload dist/*
|
||||||
|
|
6
.github/workflows/run-tests.yml
vendored
6
.github/workflows/run-tests.yml
vendored
|
@ -18,7 +18,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
python-version: ['3.7', '3.8', '3.9', '3.10']
|
python-version: ['3.8', '3.9', '3.10']
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
@ -51,7 +51,7 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Docker build
|
- name: Docker build
|
||||||
run: docker build -t libretranslate .
|
run: docker build -f docker/Dockerfile -t libretranslate .
|
||||||
|
|
||||||
- name: Docker build with some models
|
- name: Docker build with some models
|
||||||
run: docker build -t libretranslate --build-arg models=en,es .
|
run: docker build -f docker/Dockerfile -t libretranslate --build-arg models=en,es .
|
||||||
|
|
0
.gitmodules
vendored
0
.gitmodules
vendored
|
@ -139,7 +139,7 @@ Then open a web browser to http://localhost:5000
|
||||||
### Build with Docker
|
### Build with Docker
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker build [--build-arg with_models=true] -t libretranslate .
|
docker build -f docker/Dockerfile [--build-arg with_models=true] -t libretranslate .
|
||||||
```
|
```
|
||||||
|
|
||||||
If you want to run the Docker image in a complete offline environment, you need to add the `--build-arg with_models=true` parameter. Then the language models are downloaded during the build process of the image. Otherwise these models get downloaded on the first run of the image/container.
|
If you want to run the Docker image in a complete offline environment, you need to add the `--build-arg with_models=true` parameter. Then the language models are downloaded during the build process of the image. Otherwise these models get downloaded on the first run of the image/container.
|
||||||
|
@ -218,7 +218,7 @@ If you're using docker:
|
||||||
|
|
||||||
Start the program with the `--update-models` argument. For example: `libretranslate --update-models` or `./run.sh --update-models`.
|
Start the program with the `--update-models` argument. For example: `libretranslate --update-models` or `./run.sh --update-models`.
|
||||||
|
|
||||||
Alternatively you can also run the `install_models.py` script.
|
Alternatively you can also run the `scripts/install_models.py` script.
|
||||||
|
|
||||||
## Run with WSGI and Gunicorn
|
## Run with WSGI and Gunicorn
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ If you use Gunicorn, make sure to create a directory for storing multiprocess da
|
||||||
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
|
||||||
gunicorn -c gunicorn_conf.py --bind 0.0.0.0:5000 'wsgi:app(metrics=True)'
|
gunicorn -c scripts/gunicorn_conf.py --bind 0.0.0.0:5000 'wsgi:app(metrics=True)'
|
||||||
```
|
```
|
||||||
|
|
||||||
## Language Bindings
|
## Language Bindings
|
||||||
|
@ -384,7 +384,7 @@ First you need to collect data, for example from [Opus](http://opus.nlpl.eu/), t
|
||||||
|
|
||||||
## Localization
|
## Localization
|
||||||
|
|
||||||
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/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.
|
||||||
|
|
|
@ -5,10 +5,10 @@ services:
|
||||||
container_name: libretranslate-cuda
|
container_name: libretranslate-cuda
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: docker/Dockerfile.cuda
|
dockerfile: docker/cuda.Dockerfile
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- 5000:5000
|
- "5000:5000"
|
||||||
deploy:
|
deploy:
|
||||||
resources:
|
resources:
|
||||||
reservations:
|
reservations:
|
||||||
|
|
|
@ -3,10 +3,12 @@ version: "3"
|
||||||
services:
|
services:
|
||||||
libretranslate:
|
libretranslate:
|
||||||
container_name: libretranslate
|
container_name: libretranslate
|
||||||
build: .
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: docker/cuda.Dockerfile
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- 5000:5000
|
- "5000:5000"
|
||||||
## Uncomment above command and define your args if necessary
|
## Uncomment above command and define your args if necessary
|
||||||
# command: --ssl --ga-id MY-GA-ID --req-limit 100 --char-limit 500
|
# command: --ssl --ga-id MY-GA-ID --req-limit 100 --char-limit 500
|
||||||
## Uncomment this section and the `volumes` section if you want to backup your API keys
|
## Uncomment this section and the `volumes` section if you want to backup your API keys
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
FROM python:3.8.14-slim-bullseye as builder
|
FROM python:3.10.9-slim-bullseye as builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
@ -15,14 +15,14 @@ RUN python -mvenv venv && ./venv/bin/pip install --upgrade pip
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Install package from source code, compile translations
|
# Install package from source code, compile translations
|
||||||
RUN ./venv/bin/pip install Babel==2.11.0 && ./venv/bin/python compile_locales.py \
|
RUN ./venv/bin/pip install Babel==2.11.0 && ./venv/bin/python scripts/compile_locales.py \
|
||||||
&& ./venv/bin/pip install . \
|
&& ./venv/bin/pip install . \
|
||||||
&& ./venv/bin/pip cache purge
|
&& ./venv/bin/pip cache purge
|
||||||
|
|
||||||
FROM python:3.8.14-slim-bullseye
|
FROM python:3.10.9-slim-bullseye
|
||||||
|
|
||||||
ARG with_models=false
|
ARG with_models=false
|
||||||
ARG models=
|
ARG models=""
|
||||||
|
|
||||||
RUN addgroup --system --gid 1032 libretranslate && adduser --system --uid 1032 libretranslate && mkdir -p /home/libretranslate/.local && chown -R libretranslate:libretranslate /home/libretranslate/.local
|
RUN addgroup --system --gid 1032 libretranslate && adduser --system --uid 1032 libretranslate && mkdir -p /home/libretranslate/.local && chown -R libretranslate:libretranslate /home/libretranslate/.local
|
||||||
USER libretranslate
|
USER libretranslate
|
||||||
|
@ -33,9 +33,9 @@ WORKDIR /app
|
||||||
RUN if [ "$with_models" = "true" ]; then \
|
RUN if [ "$with_models" = "true" ]; then \
|
||||||
# initialize the language models
|
# initialize the language models
|
||||||
if [ ! -z "$models" ]; then \
|
if [ ! -z "$models" ]; then \
|
||||||
./venv/bin/python install_models.py --load_only_lang_codes "$models"; \
|
./venv/bin/python scripts/install_models.py --load_only_lang_codes "$models"; \
|
||||||
else \
|
else \
|
||||||
./venv/bin/python install_models.py; \
|
./venv/bin/python scripts/install_models.py; \
|
||||||
fi \
|
fi \
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -2,7 +2,7 @@ FROM nvidia/cuda:11.2.2-devel-ubuntu20.04
|
||||||
|
|
||||||
ENV ARGOS_DEVICE_TYPE cuda
|
ENV ARGOS_DEVICE_TYPE cuda
|
||||||
ARG with_models=true
|
ARG with_models=true
|
||||||
ARG models=
|
ARG models=""
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
@ -27,14 +27,14 @@ RUN if [ "$with_models" = "true" ]; then \
|
||||||
pip3 install -e .; \
|
pip3 install -e .; \
|
||||||
# initialize the language models
|
# initialize the language models
|
||||||
if [ ! -z "$models" ]; then \
|
if [ ! -z "$models" ]; then \
|
||||||
./install_models.py --load_only_lang_codes "$models"; \
|
./scripts/install_models.py --load_only_lang_codes "$models"; \
|
||||||
else \
|
else \
|
||||||
./install_models.py; \
|
./scripts/install_models.py; \
|
||||||
fi \
|
fi \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install package from source code
|
# Install package from source code
|
||||||
RUN pip3 install Babel==2.11.0 && python3 compile_locales.py \
|
RUN pip3 install Babel==2.11.0 && python3 scripts/compile_locales.py \
|
||||||
&& pip3 install . \
|
&& pip3 install . \
|
||||||
&& pip3 cache purge
|
&& pip3 cache purge
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||||
from babel.messages.frontend import main as pybabel
|
from babel.messages.frontend import main as pybabel
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
|
@ -1,4 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||||
import argparse
|
import argparse
|
||||||
from libretranslate.init import check_and_install_models
|
from libretranslate.init import check_and_install_models
|
||||||
|
|
|
@ -11,7 +11,7 @@ if __name__ == "__main__":
|
||||||
type=str,
|
type=str,
|
||||||
nargs=1,
|
nargs=1,
|
||||||
help="Path to suggestions.db file",
|
help="Path to suggestions.db file",
|
||||||
default='suggestions.db'
|
default='db/suggestions.db'
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--clear",
|
"--clear",
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||||
import re
|
import re
|
||||||
import polib
|
import polib
|
||||||
import json
|
import json
|
5
setup.py
5
setup.py
|
@ -22,16 +22,15 @@ setup(
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
python_requires='>=3.7.0',
|
python_requires='>=3.8.0',
|
||||||
long_description=open('README.md').read(),
|
long_description=open('README.md').read(),
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
install_requires=open("requirements.txt", "r").readlines(),
|
install_requires=open("requirements.txt", "r").readlines(),
|
||||||
tests_require=['pytest==7.1.2'],
|
tests_require=['pytest==7.2.0'],
|
||||||
setup_requires=['pytest-runner'],
|
setup_requires=['pytest-runner'],
|
||||||
classifiers=[
|
classifiers=[
|
||||||
"License :: OSI Approved :: GNU Affero General Public License v3 ",
|
"License :: OSI Approved :: GNU Affero General Public License v3 ",
|
||||||
"Programming Language :: Python :: 3",
|
"Programming Language :: Python :: 3",
|
||||||
"Programming Language :: Python :: 3.7",
|
|
||||||
"Programming Language :: Python :: 3.8",
|
"Programming Language :: Python :: 3.8",
|
||||||
"Programming Language :: Python :: 3.9",
|
"Programming Language :: Python :: 3.9",
|
||||||
"Programming Language :: Python :: 3.10"
|
"Programming Language :: Python :: 3.10"
|
||||||
|
|
Loading…
Reference in a new issue