A Django REST backend that powers Localis, a web tool for translating product content — JSON language files and Word documents — into 30+ languages in a single batch, with live progress tracking and zip-bundled downloads.
Live API: https://localisbe.onrender.com
Frontend: Localis (React client)
- Batch JSON translation — upload a
key: valueJSON file and translate every string value into any combination of 20+ languages in one request, returned as a single.zipof per-language JSON files. - In-place DOCX translation — translates
.docxWord documents by rewriting the text runs inside the document XML, so headings, styles, tables, and layout are preserved instead of being flattened into plain text. - Dual translation engines — a Google Translate pipeline (via
deep-translator) and an Azure AI Translator pipeline, exposed as separate endpoints so the client can choose the engine per request. - Async, concurrent translation — uses
asynciowith a bounded semaphore (10 concurrent calls) to translate many strings in parallel instead of sequentially, cutting job time significantly on large files. - Live progress polling — an in-memory progress store is updated as each string finishes translating, so the frontend can poll a
/translation_progress/endpoint and render a real progress bar. - CORS-ready — configured for a decoupled SPA frontend, with allowed origins for local dev and the deployed frontend.
Python · Django 5.1 · django-cors-headers · deep-translator (Google Translate) · azure-ai-translation-text · python-docx · gunicorn · SQLite (dev) / dj-database-url (prod-ready)
| Method | Endpoint | Description |
|---|---|---|
POST |
/translate_json_files_new/ |
Translate a JSON file into one or more target languages via Google Translate. Returns a .zip of translated JSON files. |
POST |
/translate_json_files_new_azure/ |
Same as above, via Azure AI Translator. |
POST |
/translate_and_download_document/ |
Translate a .docx document into one or more target languages, preserving formatting. Returns a .zip of translated .docx files. |
GET |
/translation_progress/ |
Returns the current job's { progress, status } for polling. |
Request body (JSON translation) — multipart/form-data
file: the JSON file to translatetranslate_to: one or more language names (repeatable field), e.g.Hindi,Tamil,French
Request body (Document translation) — multipart/form-data
document: the.docxfile to translatetranslate_to: one or more language names
22 Indian languages (Hindi, Tamil, Telugu, Marathi, Kannada, Bengali, Odia, Assamese, Punjabi, Malayalam, Gujarati, Urdu, Sanskrit, Nepali, Bodo, Maithili, Sindhi, Kashmiri, Konkani, Dogri, Goan Konkani, Santali) plus English, Arabic, Spanish, French, Italian, Japanese, Korean, Portuguese, and Russian.
- Python 3.10+
- An Azure Translator resource (key, endpoint, region) if using the Azure endpoint
git clone https://github.com/Abhinav0915/LocalisBE.git
cd LocaliseBE
python -m venv env
source env/bin/activate # Windows: env\Scripts\activate
pip install -r requirements.txtCreate a .env (or export directly) with:
AZURE_TRANSLATOR_KEY=your_azure_key
AZURE_TRANSLATOR_ENDPOINT=https://api.cognitive.microsofttranslator.com/
AZURE_TRANSLATOR_REGION=your_region
DJANGO_SECRET_KEY=your_secret_key
These currently live as hardcoded values in
settings.pyfor local convenience — swap them foros.environ.get(...)reads before deploying or open-sourcing this repo (see note below).
python manage.py migrate
python manage.py runserverThe API will be available at http://127.0.0.1:8000/.
Configured for Render via gunicorn and dj-database-url. Update ALLOWED_HOSTS and CORS_ALLOWED_ORIGINS in settings.py for your own domains.
LocaliseBE/
├── manage.py
├── requirements.txt
└── LocaliseBE/
├── settings.py # Django settings, CORS, Azure config
├── urls.py # API route definitions
└── views.py # Translation logic (Google + Azure, JSON + DOCX)
- Move translation progress state to Redis for multi-worker/production safety
- Add authentication + per-user job history
- Support additional file types (PDF, XLSX, CSV)
- Persist secrets via environment variables only
Add a license of your choice (MIT is a common default for portfolio projects).