Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localization Support #380

Merged
merged 23 commits into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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