Metadata-Version: 2.5
Name: trujaman
Version: 0.2.0
Summary: Select text anywhere on GNOME and get an offline translation and Spanish spell check.
Author: Edgar Villarreal
License-Expression: AGPL-3.0-only
License-File: LICENSE
Keywords: ctranslate2,gnome-shell,offline,spellcheck,translation
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: X11 Applications :: GTK
Classifier: Intended Audience :: End Users/Desktop
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Desktop Environment :: Gnome
Classifier: Topic :: Text Processing :: Linguistic
Classifier: Typing :: Typed
Requires-Python: >=3.12
Requires-Dist: ctranslate2<5,>=4
Requires-Dist: pyspellchecker>=0.8
Requires-Dist: sacremoses>=0.1
Requires-Dist: sentencepiece<0.3,>=0.2
Requires-Dist: spylls>=0.1.7
Requires-Dist: subword-nmt>=0.3.8
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == 'dev'
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Description-Content-Type: text/markdown

# <picture><source media="(prefers-color-scheme: dark)" srcset=".github/assets/icon-dark.svg"><img src=".github/assets/icon-light.svg" width="36" height="36" alt=""></picture> trujaman

[![PyPI](https://img.shields.io/pypi/v/trujaman)](https://pypi.org/project/trujaman/)
[![Python](https://img.shields.io/pypi/pyversions/trujaman)](https://pypi.org/project/trujaman/)
[![license](https://img.shields.io/github/license/GHEgar/trujaman)](LICENSE)

Select text anywhere on GNOME and get an offline translation and Spanish spell check.

Highlight a word or a sentence in any app and a small window shows its translation next to the
cursor. English becomes Spanish and Spanish becomes English, detected for you. Spanish selections
also get spelling corrections, and the menu has a big area to proofread a whole paragraph. Everything runs on your machine: the models are downloaded once and
no text ever leaves it. A top-bar icon keeps the last query, a quick-settings menu and a small
translator with its own text area.

## Install

```bash
pipx install trujaman
trujaman install
```

`trujaman install` copies the GNOME Shell extension, installs the fonts and downloads the two
translation models (about 400 MB). Then log out and back in, because GNOME on Wayland only scans
extensions at startup.

| You need | Why |
|---|---|
| GNOME Shell 50 (Ubuntu 26.04) | Shell extensions are version-bound; only 50 is tested |
| Python 3.12 or newer | The translation daemon |
| `glib-compile-schemas` (`libglib2.0-bin`) | Compiles the extension settings |

## Quick start

```bash
trujaman doctor      # checks Python, GNOME, the extension and the models
```

Select any text with the mouse. After half a second the translation appears. Click the top-bar
icon for the last query, the switches, the **Traducir texto** box and the **Corregir ortografía**
area (`Ctrl+Enter` runs either).

## How it works

```
select text → extension reads the PRIMARY selection → `python -m trujaman daemon`
            ← JSON lines ← CTranslate2 + Argos models, Hunspell for spelling
```

| Piece | What it does |
|---|---|
| Extension | Watches the selection, draws the window and the top-bar menu |
| Daemon | One long-lived process: detects the language, translates, checks spelling |
| Models | [Argos Translate](https://github.com/argosopentech/argos-translate) models, run with CTranslate2. No PyTorch |
| Spelling | Hunspell Spanish dictionary, with suggestions ranked by word frequency |

## Settings

Open them from the menu (**Ajustes…**) or with `gnome-extensions prefs trujaman@egar`.

| Setting | Default | What it does |
|---|---|---|
| Source language | auto | `auto` detects, or force `es` or `en` |
| Delay | 500 ms | Wait after selecting before translating |
| Max characters | 600 | Longer selections are ignored |
| Auto-close | 8000 ms | `0` keeps the window until you close it |
| Close button | on | The × in the window |
| Font and size | Rotulo Sans, 12 pt | Any installed family |

## Commands

| Command | What it does |
|---|---|
| `trujaman install [--skip-models]` | Installs the extension, fonts and models |
| `trujaman uninstall` | Removes the extension and fonts; models stay |
| `trujaman models [--install]` | Lists or downloads the en/es models |
| `trujaman doctor` | Checks the installation |
| `trujaman daemon` | The daemon the extension starts; not for direct use |

## Known limitations

- Only English and Spanish, and GNOME Shell 50.
- A sentence full of typos is translated as typed, so the translation can be nonsense. The
  corrections show above it.
- Language detection is a heuristic. Force the language in settings when it guesses wrong.
- Quality is that of the small Argos models: good for words and short sentences, weaker on long text.
- The proofreading area takes up to 5000 characters and spends at most 10 seconds on them; longer
  texts are checked only in part, and the result says so.
- Some apps do not update the PRIMARY selection when you select text.

## Development

```bash
python3 -m venv .venv && .venv/bin/pip install -e '.[dev]'
.venv/bin/trujaman models --install
.venv/bin/pytest
.venv/bin/ruff check . && .venv/bin/ruff format --check . && .venv/bin/mypy
```

The extension lives in `src/trujaman/data/extension/`; run `trujaman install` after editing it.

## Contributing

Issues are welcome; please open one before a pull request.

## License

AGPL-3.0-only © GHEgar. The bundled Spanish dictionary keeps its own licenses
(`src/trujaman/data/dict/LICENSE-es.txt`) and the bundled Rotulo fonts are OFL-1.1.
