Skip to content

Commit

Permalink
Merge pull request #380 from pierotofy/loc
Browse files Browse the repository at this point in the history
Localization Support
  • Loading branch information
pierotofy committed Jan 6, 2023
2 parents a17ef40 + 4af4454 commit cb3ee55
Show file tree
Hide file tree
Showing 23 changed files with 2,385 additions and 206 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
python -m pip install --upgrade pip
pip install pytest flake8
pip install .
python compile_locales.py
- name: Check code style with flake8 (lint)
run: |
Expand Down Expand Up @@ -60,5 +61,6 @@ jobs:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python compile_locales.py
python setup.py sdist bdist_wheel
twine upload dist/*
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ RUN python -mvenv venv && ./venv/bin/pip install --upgrade pip

COPY . .

# Install package from source code
RUN ./venv/bin/pip install . \
# Install package from source code, compile translations
RUN ./venv/bin/pip install Babel==2.11.0 && ./venv/bin/python compile_locales.py \
&& ./venv/bin/pip install . \
&& ./venv/bin/pip cache purge


FROM python:3.8.14-slim-bullseye

ARG with_models=false
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.8
1.3.9
2 changes: 2 additions & 0 deletions babel.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[python: **.py]
[jinja2: **/templates/**]
16 changes: 16 additions & 0 deletions compile_locales.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env python
import sys
import os
from babel.messages.frontend import main as pybabel

if __name__ == "__main__":
locales_dir = os.path.join("libretranslate", "locales")
if not os.path.isdir(locales_dir):
os.makedirs(locales_dir)

print("Compiling locales")
sys.argv = ["", "compile", "-f", "-d", locales_dir]
pybabel()



3 changes: 2 additions & 1 deletion docker/Dockerfile.cuda
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ RUN if [ "$with_models" = "true" ]; then \
fi

# Install package from source code
RUN pip3 install . \
RUN pip3 install Babel==2.11.0 && python3 compile_locales.py \
&& pip3 install . \
&& pip3 cache purge

# Depending on your cuda install you may need to uncomment this line to allow the container to access the cuda libraries
Expand Down
Loading

0 comments on commit cb3ee55

Please sign in to comment.