Metadata-Version: 2.4
Name: argonaut-translator
Version: 1.4.0
Summary: Minimalist offline document translator (PyQt5 + Argos Translate)
Author-email: Sergio Rodríguez <srodriguez3441@gmail.com>
License-Expression: GPL-3.0-only
Project-URL: Homepage, https://github.com/Nibblex/Argonaut
Project-URL: Issues, https://github.com/Nibblex/Argonaut/issues
Keywords: translation,documents,offline,argos-translate,pdf
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: X11 Applications :: Qt
Classifier: Intended Audience :: End Users/Desktop
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Text Processing :: Linguistic
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: PyQt5
Requires-Dist: argos-translate-lt
Requires-Dist: argos-translate-files>=1.4.4
Requires-Dist: langdetect
Requires-Dist: psutil
Requires-Dist: pymupdf
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Requires-Dist: pytest-qt; extra == "test"
Dynamic: license-file

# Argonaut

[![PyPI](https://img.shields.io/pypi/v/argonaut-translator)](https://pypi.org/project/argonaut-translator/)
[![Python versions](https://img.shields.io/pypi/pyversions/argonaut-translator)](https://pypi.org/project/argonaut-translator/)
[![License: GPL-3.0](https://img.shields.io/github/license/Nibblex/Argonaut)](LICENSE)
[![Release](https://img.shields.io/github/v/tag/Nibblex/Argonaut?label=release)](https://github.com/Nibblex/Argonaut/tags)
[![CI](https://github.com/Nibblex/Argonaut/actions/workflows/ci.yml/badge.svg)](https://github.com/Nibblex/Argonaut/actions/workflows/ci.yml)
[![Coverage](https://raw.githubusercontent.com/Nibblex/Argonaut/badges/coverage.svg)](https://github.com/Nibblex/Argonaut/actions/workflows/ci.yml)

Minimalist document translator with a Qt (PyQt5) interface that uses
[argos-translate-files](https://github.com/LibreTranslate/argos-translate-files)
as an offline translation engine.

Two engines are available from *Settings → Engine*:

- **Argos Translate** (default) — light per-pair models, installed and
  removed from *Settings → Manage language packages…*.
- **NLLB-200** — Meta's
  [nllb-200-distilled-600M](https://huggingface.co/facebook/nllb-200-distilled-600M)
  (int8, CTranslate2), noticeably better quality and direct translation
  between any pair of 32 languages. The model (~630 MB) is downloaded on
  first use and stored under `~/.local/share/argonaut/`. Note that the
  NLLB weights are licensed CC-BY-NC 4.0 (non-commercial).

## Requirements

```bash
pip install PyQt5 argos-translate-lt argos-translate-files langdetect psutil
```

You need at least one language package installed. Open
*Settings → Manage language packages…*, pick the pairs you want and
press "Install selected"; the dialog lists every package from the Argos
index with its version and download size, filters by installation state,
and lets you remove or update the installed ones (a package with a newer
version in the index is flagged and can be updated in place). They can
also be installed from the command line with `argospm install
translate-en_es`.

## Usage

Install it (provides the `argonaut` command):

```bash
pip install argonaut-translator
```

From a checkout, install in editable mode first:

```bash
pip install -e .
python3 -m argonaut
```

## Structure

All modules live in the `src/argonaut/` package:

- `__init__.py` — package version (`__version__`).
- `main.py` — entry point; silences dependency warnings and launches
  the window.
- `window.py` — main window (PyQt5).
- `worker.py` — thread that translates the file list and emits progress signals.
- `pdf.py` — fixed PDF translator (paragraphs, progress, cancellation).
- `translation.py` — language detection, supported formats and the
  progress/cache wrapper.
- `nllb.py` — optional NLLB-200 backend (CTranslate2 + SentencePiece)
  exposing the same duck-typed API as argostranslate.
- `packages.py` — Argos package index, download, installation and removal.
- `package_dialog.py` — dialog to browse, install and remove packages.
- `i18n.py` — interface languages (English by default, Spanish, French,
  German, Italian and Portuguese).

Packaging lives at the top level: `pyproject.toml` (PyPI),
`io.github.nibblex.Argonaut.yml` (Flatpak manifest) and `data/`
(desktop entry, AppStream metainfo and icon for Flathub).

## Interface language

The interface starts in English. In the **Language** menu you can switch
to Spanish, French, German, Italian or Portuguese; the change applies
instantly and the preference is saved (QSettings) for future launches.
To add a language just add its dictionary in `i18n.py` (missing keys fall
back to English). The **Help** menu includes "About Argonaut", showing
the version, a short description of the project, the translation engine,
the supported formats, the author and the license.

## Persistent settings

When the window closes, QSettings stores — besides the interface
language — the source and target languages, the output folder and the
window size/position; everything is restored on the next launch. If a
saved language is no longer installed or the folder no longer exists,
the default value is used. The active engine and the number of CPU
threads (*Settings → CPU threads*, capped at the detected core count and
defaulting to four) are saved as soon as they change.

1. Choose the source and target languages (⇄ button to swap them).
   By default the source is "Detect language": each document's language
   is detected automatically, so you can mix files in different
   languages in the same batch.
2. Drag documents or whole folders onto the window (dropped folders are
   walked recursively) or add them with "Add…". Each file shows its size
   and the list footer shows the batch total.
3. Optionally pick a folder with "Output…" where all translations are
   saved (× returns to the default behaviour: next to each original).
   Tick "Skip files already translated" to leave existing outputs
   untouched, which makes an interrupted batch resumable.
4. Press "Translate". Each translated file is saved with the target
   language suffix (e.g. `report_es.docx`).
5. During translation you can press "Cancel": the operation stops
   (even mid-file) and the files already translated are kept.

Note about PDFs: they are translated paragraph by paragraph while
preserving the layout, so a long document can take a while on CPU.
The bar shows the real percentage of translated paragraphs and an
estimate of the remaining time. Rotated
text (e.g. vertical watermarks) is kept untranslated, and links from
the original document are not preserved in the translated copy.

Supported formats: `.txt` `.docx` `.odt` `.odp` `.pptx` `.epub`
`.html` `.srt` `.pdf`

## Tests

```bash
pip install -e .[test]
pytest
```

The suite runs Qt headless (`QT_QPA_PLATFORM=offscreen`) and needs no
language models: translation engines are faked. Coverage is printed at
the end of the run; CI publishes the badge on every push to `main`.

## Releasing

To publish a new version, bump `__version__` in `src/argonaut/__init__.py`
and add a `<release>` entry in `data/*.metainfo.xml`.

**PyPI**

```bash
pip install build twine
python3 -m build
twine upload dist/*
```

**Flathub**

The manifest is `io.github.nibblex.Argonaut.yml`. Flathub builds
have no network access, so the Python dependencies must be pinned first
with [flatpak-pip-generator](https://github.com/flatpak/flatpak-builder-tools):

```bash
python3 flatpak-pip-generator --requirements-file=requirements.txt \
    --output python3-requirements
```

Test locally, then lint:

```bash
flatpak-builder --user --install --force-clean build-dir \
    io.github.nibblex.Argonaut.yml
flatpak run --command=flatpak-builder-lint org.flatpak.Builder \
    manifest io.github.nibblex.Argonaut.yml
```

First submission: take a screenshot for the metainfo (see the TODO in
`data/*.metainfo.xml`), then open a PR against
[flathub/flathub](https://github.com/flathub/flathub) (branch
`new-pr`) adding the manifest, per the
[submission guide](https://docs.flathub.org/docs/for-app-authors/submission).

## Author and license

© 2026 Sergio Rodríguez.

This project is distributed under the [GNU GPL v3](LICENSE) license,
in line with the license of PyQt5, which the interface depends on.
