Skip to content

Commit 09e36da

Browse files
gHashTagona-agent
andcommitted
feat: Add offline translator app (PyQt6 + argos-translate + Tesseract OCR)
Desktop translator with text and image translation, 14 languages, dark theme UI. Build .dmg on macOS via ./build_dmg.sh Co-authored-by: Ona <no-reply@ona.com>
1 parent 7a41967 commit 09e36da

6 files changed

Lines changed: 648 additions & 0 deletions

File tree

translator-app/README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Offline Translator
2+
3+
Desktop translator app that works completely offline. Supports text translation and OCR from images.
4+
5+
## Features
6+
7+
- **Offline text translation** between 14 languages (argos-translate / OpenNMT)
8+
- **OCR from images** — drag-and-drop or open image files (Tesseract)
9+
- **Dark theme** UI
10+
- **Auto-download** of language models on first use (~50MB per pair)
11+
- Pivot translation through English for unsupported direct pairs
12+
13+
## Supported Languages
14+
15+
English, Russian, Spanish, French, German, Chinese, Japanese, Korean, Portuguese, Italian, Arabic, Turkish, Hindi, Ukrainian
16+
17+
## Requirements (macOS)
18+
19+
- macOS 12+
20+
- Python 3.10+
21+
- Homebrew
22+
23+
## Quick Start (Development)
24+
25+
```bash
26+
cd translator-app
27+
chmod +x run_dev.sh
28+
./run_dev.sh
29+
```
30+
31+
## Build .dmg
32+
33+
```bash
34+
cd translator-app
35+
chmod +x build_dmg.sh
36+
./build_dmg.sh
37+
```
38+
39+
Output: `dist/OfflineTranslator-1.0.0.dmg`
40+
41+
## Install
42+
43+
1. Open the `.dmg` file
44+
2. Drag "Offline Translator" to Applications
45+
3. Launch from Applications
46+
4. First translation will download the language model (~50MB)
47+
48+
## How It Works
49+
50+
1. **Text**: Paste text in the left panel, select languages, click Translate
51+
2. **Image**: Drag an image onto the drop area (or click "Open Image") — OCR extracts text, then translate
52+
3. Language models download automatically on first use and are cached locally
53+
54+
## Tech Stack
55+
56+
| Component | Library |
57+
|-----------|---------|
58+
| Translation | argos-translate (OpenNMT) |
59+
| OCR | Tesseract via pytesseract |
60+
| GUI | PyQt6 |
61+
| Packaging | PyInstaller |

translator-app/build_dmg.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
# Build Offline Translator as macOS .dmg
3+
# Run this on your Mac (requires Python 3.10+, Homebrew)
4+
5+
set -e
6+
7+
APP_NAME="Offline Translator"
8+
DMG_NAME="OfflineTranslator-1.0.0"
9+
10+
echo "=== Step 1: Install system dependencies ==="
11+
brew install tesseract tesseract-lang
12+
13+
echo "=== Step 2: Create virtual environment ==="
14+
python3 -m venv .venv
15+
source .venv/bin/activate
16+
17+
echo "=== Step 3: Install Python dependencies ==="
18+
pip install --upgrade pip
19+
pip install -r requirements.txt
20+
21+
echo "=== Step 4: Download default language packages (en<->ru) ==="
22+
python3 -c "
23+
import argostranslate.package
24+
argostranslate.package.update_package_index()
25+
available = argostranslate.package.get_available_packages()
26+
for pkg in available:
27+
if (pkg.from_code == 'en' and pkg.to_code == 'ru') or \
28+
(pkg.from_code == 'ru' and pkg.to_code == 'en'):
29+
print(f'Installing {pkg.from_code} -> {pkg.to_code}')
30+
pkg.install()
31+
print('Language packages installed.')
32+
"
33+
34+
echo "=== Step 5: Build .app with PyInstaller ==="
35+
pyinstaller translator.spec --noconfirm
36+
37+
echo "=== Step 6: Create .dmg ==="
38+
# Create a temporary DMG directory
39+
DMG_DIR="dmg_temp"
40+
rm -rf "$DMG_DIR"
41+
mkdir -p "$DMG_DIR"
42+
43+
# Copy .app bundle
44+
cp -R "dist/${APP_NAME}.app" "$DMG_DIR/"
45+
46+
# Create symlink to Applications
47+
ln -s /Applications "$DMG_DIR/Applications"
48+
49+
# Create DMG
50+
hdiutil create -volname "$APP_NAME" \
51+
-srcfolder "$DMG_DIR" \
52+
-ov -format UDZO \
53+
"dist/${DMG_NAME}.dmg"
54+
55+
# Cleanup
56+
rm -rf "$DMG_DIR"
57+
58+
echo ""
59+
echo "=== BUILD COMPLETE ==="
60+
echo "DMG location: dist/${DMG_NAME}.dmg"
61+
echo ""
62+
echo "To install:"
63+
echo " 1. Open dist/${DMG_NAME}.dmg"
64+
echo " 2. Drag 'Offline Translator' to Applications"
65+
echo " 3. Launch from Applications"
66+
echo ""
67+
echo "First launch will download translation models (~50MB per language pair)."

translator-app/requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
PyQt6>=6.6.0
2+
argostranslate>=1.9.0
3+
pytesseract>=0.3.10
4+
Pillow>=10.0.0
5+
pyinstaller>=6.0.0

translator-app/run_dev.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
# Quick run for development/testing (no packaging)
3+
# Run this on your Mac to test the app before building .dmg
4+
5+
set -e
6+
7+
# Install Tesseract if not present
8+
if ! command -v tesseract &> /dev/null; then
9+
echo "Installing Tesseract OCR..."
10+
brew install tesseract tesseract-lang
11+
fi
12+
13+
# Create venv if needed
14+
if [ ! -d ".venv" ]; then
15+
python3 -m venv .venv
16+
fi
17+
18+
source .venv/bin/activate
19+
pip install -q -r requirements.txt
20+
21+
echo "Starting Offline Translator..."
22+
python3 translator.py

0 commit comments

Comments
 (0)