Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Localis BE — Localization & Translation API

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)


Features

  • Batch JSON translation — upload a key: value JSON file and translate every string value into any combination of 20+ languages in one request, returned as a single .zip of per-language JSON files.
  • In-place DOCX translation — translates .docx Word 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 asyncio with 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.

Tech Stack

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)

API Endpoints

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 translate
  • translate_to: one or more language names (repeatable field), e.g. Hindi, Tamil, French

Request body (Document translation)multipart/form-data

  • document: the .docx file to translate
  • translate_to: one or more language names

Supported Languages

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.

Getting Started

Prerequisites

  • Python 3.10+
  • An Azure Translator resource (key, endpoint, region) if using the Azure endpoint

Setup

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.txt

Environment variables

Create 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.py for local convenience — swap them for os.environ.get(...) reads before deploying or open-sourcing this repo (see note below).

Run

python manage.py migrate
python manage.py runserver

The API will be available at http://127.0.0.1:8000/.

Deployment

Configured for Render via gunicorn and dj-database-url. Update ALLOWED_HOSTS and CORS_ALLOWED_ORIGINS in settings.py for your own domains.

Project Structure

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)

Roadmap Ideas

  • 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

License

Add a license of your choice (MIT is a common default for portfolio projects).

About

Backend for Localis, a localization tool offering JSON file translation and file translation into Indian languages. Powered by Google Translator, it ensures accurate translations, making localization seamless for developers and content creators targeting diverse Indian audiences.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages