Local-first translation app: React + Vite frontend, FastAPI backend, and a local GGUF model via llama-cpp-python.
Browser (React) ⇄ FastAPI Server ⇄ TranslateGemma (GGUF via llama.cpp)
- Python 3.11+
- Node.js 18+
uvandpnpm
- Copy env file:
cp .env.example .env
- Install deps:
- Backend:
cd backend && uv sync --extra dev --extra llama - Frontend:
cd frontend && pnpm install
- Backend:
- Run:
make dev
- Open:
- Frontend:
http://127.0.0.1:5173
- Frontend:
Note: the backend automatically loads the repo-root .env file in dev.
If pnpm install warns about ignored build scripts (e.g. esbuild) and Vite can’t start, run pnpm approve-builds.
Set LOCALLINGUA_MODEL_PATH in .env to your .gguf file.
Recommended folder:
~/Models/LocalLingua/
Example:
LOCALLINGUA_MODEL_PATH=/Users/you/Models/LocalLingua/translategemma-4b-q4_k_m.gguf
Q4_K_M: recommended default (smaller + faster; great for demos).Q8_0: higher fidelity but larger + typically slower.
If you want to develop the UI without a model, set:
LOCALLINGUA_ALLOW_FAKE_TRANSLATOR=1
- If the backend reports
MODEL_NOT_CONFIGURED, confirmLOCALLINGUA_MODEL_PATHpoints to an existing.gguf. - If you see
LLAMA_CPP_NOT_INSTALLED, install backend deps viauv sync. - Performance: Apple Silicon + Metal generally performs best with quantized models (e.g.
Q4_K_M).
- TranslateGemma GGUF may emit fenced output (
text ...); the backend strips fences and returns plain text. - If Vite fails with
vite: command not found, runcd frontend && pnpm install.
- Paste a paragraph of text.
- Set target language (e.g. Spanish).
- Click Translate and copy the result.
- Open History and restore a previous translation.
Built with AI assistance