diff --git a/.dockerignore b/.dockerignore index 6b4c5ef..b94de4f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,9 +1,3 @@ .git* -docker* +docker .Dockerfile.swp - -chart/ -.editorconfig -*.yaml -*.md -!README.md diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml deleted file mode 100644 index e8bdd99..0000000 --- a/.github/dependabot.yaml +++ /dev/null @@ -1,7 +0,0 @@ ---- -version: 2 -updates: - - package-ecosystem: github-actions - directory: / - schedule: - interval: daily diff --git a/.github/workflows/issue-triage.yml b/.github/workflows/issue-triage.yml deleted file mode 100644 index 6af6281..0000000 --- a/.github/workflows/issue-triage.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Issue Triage -on: - issues: - types: - - opened -jobs: - issue_triage: - runs-on: ubuntu-latest - permissions: - issues: write - steps: - - uses: pierotofy/issuewhiz@v1 - with: - ghToken: ${{ secrets.GITHUB_TOKEN }} - openAI: ${{ secrets.OPENAI_TOKEN }} - model: gpt-4o-2024-08-06 - filter: | - - "#" - variables: | - - Q: "A question about using a software or seeking guidance on doing something?" - - B: "Reporting an issue, an exception, a stack trace, or a software bug?" - - T: "Reporting a problem with an inaccurate, awkward or erroneous translation?" - - E: "Reporting about some missing feature or functionality?" - - SC: "Describes an issue related to compiling or building source code?" - logic: | - - "Q and (not B) and (not E) and (not SC)": [comment: "Could we move this conversation over to the forum at https://community.libretranslate.com? :pray: The forum is the right place to ask questions (we try to keep the GitHub issue tracker for feature requests and bugs only). Thank you! :+1:", close: true, stop: true] - - "B and (not T) and (not E) and (not SC)": [label: "possible bug", stop: true] - - "T and (not E)": [label: "model improvement", stop: true] - - "E": [label: "enhancement", stop: true] - - "SC": [label: "possible bug"] - - signature: "p.s. I'm just an automated script, not a human being." diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index 8ca45a8..a2b5ebb 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -12,16 +12,16 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Repository - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + uses: docker/setup-buildx-action@v1 - name: Login to Docker Hub - uses: docker/login-action@v3 + uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} @@ -33,7 +33,7 @@ jobs: echo ::set-output name=gh-username-lower::$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') - name: Build and push Image - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v2 with: file: ./docker/Dockerfile platforms: linux/amd64,linux/arm64 @@ -44,24 +44,8 @@ jobs: env: TAG: ${{ startsWith(github.ref, 'refs/tags/') && steps.get-variables.outputs.version || 'latest' }} - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@main - with: - # this might remove tools that are actually needed, - # if set to "true" but frees about 6 GB - tool-cache: false - - # all of these default to true, but feel free to set to - # "false" if necessary for your workflow - android: true - dotnet: true - haskell: true - large-packages: true - docker-images: true - swap-storage: true - - name: Build and push Cuda Image - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v2 with: file: ./docker/cuda.Dockerfile platforms: linux/amd64 diff --git a/.github/workflows/publish-package.yml b/.github/workflows/publish-package.yml index fc14341..a68ae51 100644 --- a/.github/workflows/publish-package.yml +++ b/.github/workflows/publish-package.yml @@ -18,9 +18,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v4 with: python-version: '3.8' - name: Install dependencies diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index e39c792..2703870 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -22,9 +22,9 @@ jobs: python-version: ['3.8', '3.9', '3.10'] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} @@ -41,7 +41,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v3 - name: Docker build run: docker build -f docker/Dockerfile -t libretranslate . diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 82e8946..55e8f4b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,6 +9,15 @@ repos: name: " ✔️ Check TOML" - id: check-json name: " ✔️ Check JSON" + - id: trailing-whitespace + name: " ✂️ Trim trailing whitespaces" + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.0.277 + hooks: + - id: ruff + name: " ⚡️ Formatting code with Ruff" + args: + - --fix ci: autofix_commit_msg: 🎨 [pre-commit] Auto format diff --git a/.well-known/funding-manifest-urls b/.well-known/funding-manifest-urls deleted file mode 100644 index b419350..0000000 --- a/.well-known/funding-manifest-urls +++ /dev/null @@ -1,2 +0,0 @@ -https://libretranslate.com/funding.json - diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ee4ded6..4bd0221 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -134,7 +134,3 @@ This prevents pip packages from being installed system-wide. This way, there are References: * [Python venv documentation](https://docs.python.org/library/venv.html) - -## Other Languages - -- [Español (CONTRIBUTING)](docs/CONTRIBUTING.es.md) \ No newline at end of file diff --git a/README.md b/README.md index 9eaa2ee..2e7a5fd 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,14 @@ # LibreTranslate -[Try it online!](https://libretranslate.com) | [API Docs](https://libretranslate.com/docs) | [Community Forum](https://community.libretranslate.com/) | [Bluesky](https://bsky.app/profile/libretranslate.com) +[Try it online!](https://libretranslate.com) | [API Docs](https://libretranslate.com/docs) | [Community Forum](https://community.libretranslate.com/) [](https://pypi.org/project/libretranslate) [](https://github.com/LibreTranslate/LibreTranslate/actions?query=workflow%3A%22Run+tests%22) [](https://github.com/LibreTranslate/LibreTranslate/actions/workflows/publish-docker.yml) [](https://github.com/LibreTranslate/LibreTranslate/actions/workflows/publish-package.yml) [](https://codeberg.org/teaserbot-labs/delightful-humane-design) Free and Open Source Machine Translation API, entirely self-hosted. Unlike other APIs, it doesn't rely on proprietary providers such as Google or Azure to perform translations. Instead, its translation engine is powered by the open source [Argos Translate](https://github.com/argosopentech/argos-translate) library. - + + +[Try it online!](https://libretranslate.com) | [API Docs](https://libretranslate.com/docs) ## API Examples @@ -20,9 +22,9 @@ const res = await fetch("https://libretranslate.com/translate", { body: JSON.stringify({ q: "Hello!", source: "en", - target: "es", + target: "es" }), - headers: { "Content-Type": "application/json" }, + headers: { "Content-Type": "application/json" } }); console.log(await res.json()); @@ -36,8 +38,6 @@ Response: } ``` -List of language codes: https://libretranslate.com/languages - ### Auto Detect Language Request: @@ -48,9 +48,9 @@ const res = await fetch("https://libretranslate.com/translate", { body: JSON.stringify({ q: "Ciao!", source: "auto", - target: "en", + target: "en" }), - headers: { "Content-Type": "application/json" }, + headers: { "Content-Type": "application/json" } }); console.log(await res.json()); @@ -68,7 +68,7 @@ Response: } ``` -### HTML +### HTML (beta) Request: @@ -79,9 +79,9 @@ const res = await fetch("https://libretranslate.com/translate", { q: '
Hello!
', source: "en", target: "es", - format: "html", + format: "html" }), - headers: { "Content-Type": "application/json" }, + headers: { "Content-Type": "application/json" } }); console.log(await res.json()); @@ -95,38 +95,6 @@ Response: } ``` -### Alternative Translations - -Request: - -```javascript -const res = await fetch("https://libretranslate.com/translate", { - method: "POST", - body: JSON.stringify({ - q: "Hello", - source: "en", - target: "it", - format: "text", - alternatives: 3, - }), - headers: { "Content-Type": "application/json" }, -}); - -console.log(await res.json()); -``` - -Response: - -```javascript -{ - "alternatives": [ - "Salve", - "Pronto" - ], - "translatedText": "Ciao" -} -``` - ## Install and Run You can run your own API server with just a few lines of setup! @@ -140,14 +108,6 @@ libretranslate [args] Then open a web browser toHello!
', - source: "en", - target: "es", - format: "html", - }), - headers: { "Content-Type": "application/json" }, -}); - -console.log(await res.json()); -``` - -Respuesta: - -```javascript -{ - "translatedText": "¡Hola!
" -} -``` - -### Traducciones Alternativas - -Solicitud: - -```javascript -const res = await fetch("https://libretranslate.com/translate", { - method: "POST", - body: JSON.stringify({ - q: "Hello", - source: "en", - target: "it", - format: "text", - alternatives: 3, - }), - headers: { "Content-Type": "application/json" }, -}); - -console.log(await res.json()); -``` - -Respuesta: - -```javascript -{ - "alternatives": [ - "Salve", - "Pronto" - ], - "translatedText": "Ciao" -} -``` - -## Instalar y Ejecutar - -Puedes ejecutar tu propio servidor API con solo unas pocas líneas de configuración! - -Asegúrate de tener instalado Python (se recomienda la versión 3.8 o superior) y, a continuación, simplemente ejecuta: - -```bash -pip install libretranslate -libretranslate [args] -``` - -Luego abra un navegador web para