CLI tool for syncing localization files with Batre Translator API
Project description
🧩 Batre Translator CLI
Batre Translator CLI is a lightweight command-line tool for automating localization workflows in Batre Translator.
It clones your frontend project, aggregates translation files, commits them to Git, and uploads updates to
the Batre Translator API — with full GitLab/GitHub merge request automation.
🚀 Features
- 🔄 Automatically clones full repositories (no sparse-checkout)
- 📁 Aggregates
.jsand.jsonlocale files into a unified structure - 🧠 Encodes and uploads translations to the Batre Translator API (Base64)
- 🪄 Automatically creates Merge Requests for exported translations
- 🧰 Fully scriptable via
makeor direct CLI commands - 💾 Safe local
.batre.ymlconfiguration per project
📦 Installation
Install the latest release from PyPI:
python3 -m venv .venv
source .venv/bin/activate
pip install batre-translator-cli
To install the latest development version directly from GitLab:
pip install git+https://gitlab.com/collabwire/batre/batre-cli.git@develop
⚙️ Quick Commands
| Command | Description |
|---|---|
batre sync |
Full workflow: clone repo → aggregate → upload base locale folder to API |
batre export |
Fetch translated files from API → destructure them into locale folder write → to repo → create MR |
Example:
batre sync --dry-run
Output:
🔄 Cloning project repository...
📦 Aggregating translations from src/locales/en-GB...
🌍 Sending translation data to Batre Translator API...
✅ Upload successful!
⚙️ Configuration (.batre.yml)
Create a .batre.yml file in your project root:
# Project configuration for Batre Translator CLI
project_id: project-app
repo_url: git@gitlab.com:yourcompany/project/project-app.git
branch: develop
repo_path: tmp/project-app
base_path: src/locales/en-GB
export_path: src/locales/dist
api_url: https://translator.batre.io/api/v1
api_token: <CLIENT_TOKEN>
gitlab_token: <GITLAB_PAT>
vcs: gitlab # or github / bitbucket
Explanation
| Key | Description |
|---|---|
project_id |
ID of the project in Batre Translator |
repo_url |
Git repository URL (SSH or HTTPS) |
branch |
Branch to pull from |
repo_path |
Local folder for temporary clone |
base_path |
Path to your localization source files |
export_path |
Folder where new translations are written |
api_url |
Batre Translator API endpoint |
api_token |
Client API token for authentication |
gitlab_token |
Personal Access Token for creating merge requests |
vcs |
Repository provider (gitlab, github, or bitbucket) |
🧩 Usage
1️⃣ Aggregate translations locally
Collect and combine all translation files into a single aggregated.json.
The aggregated file is now saved one level above the language folder — e.g.:
src/locales/aggregated.json
Run manually:
batre aggregate
Or via make:
make aggregate
Example output:
📁 Using base path from .batre.yml: src/locales/en-GB
✅ Parsed: auth/login.js
✅ Parsed: auth/reset-password.js
✅ Aggregated file saved to: src/locales/aggregated.json
2️⃣ Full sync (clone → aggregate → upload)
This command:
- Clones or updates the full Git repository (no sparse-checkout)
- Aggregates all translation files
- Uploads them as Base64 to the Batre Translator API
batre sync
Or via Makefile:
make sync
Example:
🔄 Updating repo at tmp/project-app...
📦 Aggregating translations from src/locales/en-GB...
✅ Aggregated file saved to: src/locales/aggregated.json
🌍 Sending en-GB translation data to https://translator.batre.io/api/v1 (Base64 mode)...
✅ Upload successful!
3️⃣ Export from API → Git → Merge Request
The batre export command fetches translations from the API, writes them into your repo,
and automatically creates a Git branch + Merge Request.
batre export
Example:
📦 Processing en-GB...
✅ Wrote en-GB/auth/login.js
✅ Wrote en-GB/auth/reset-password.js
🌿 Creating branch: batre/export/20251024-2142
✅ Commit created successfully.
🚀 Pushing branch to remote...
✅ Merge Request created successfully!
🔗 https://gitlab.com/yourcompany/project/-/merge_requests/12
Developers only need to review and merge the MR.
🧱 Developer setup
Clone the CLI project locally and use make commands:
git clone https://gitlab.com/collabwire/batre-translator-cli.git
cd batre-translator-cli
make install-dev
Available commands:
make venv - create Python virtual environment
make install - install runtime dependencies
make install-dev - install dev tools (black, isort, build, twine)
make lint - format code
make aggregate - run local aggregator
make sync - full clone + aggregate + upload
make export - export from API to repo + create MR
make build - build wheel and sdist packages
make publish - publish to PyPI or GitLab
make clean - remove venv and caches
🧪 Build & Publish
Build package
make build
Publish to PyPI
make publish
or manually:
twine upload dist/*
🔧 Developer Notes
- Full Git clone is now used — no sparse-checkout logic remains.
- Aggregated files are saved to
src/locales/aggregated.json. - The CLI automatically commits translation exports and opens a Merge Request.
- Merge Requests are created using your configured
gitlab_token(PAT). - The tool can also work with GitHub or Bitbucket if configured under
vcs.
🧰 Requirements
- Python 3.12+
- Git (CLI)
- Access to your GitLab/GitHub repository
- Valid Batre Translator API credentials
🪪 License
MIT License © Collabwire
🧰 Authors
Collabwire
Architecture: Alex
AI Assistant: Ania (GPT-5)
🌍 Maintainer
Collabwire
Warsaw, Poland
📧 hello@collabwire.io
🌐 https://collabwire.io
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file batre_translator_cli-0.1.18.tar.gz.
File metadata
- Download URL: batre_translator_cli-0.1.18.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48435d290686132a8d3a3a42a4b9e47b34014139e0db91478b4a67f5260c1cf3
|
|
| MD5 |
8bf25111dc696564a260762723d5cf57
|
|
| BLAKE2b-256 |
81d95f42b5b2ade319856dfe8d10f77d2845948fbdb89de1d445b14d3c43c14d
|
File details
Details for the file batre_translator_cli-0.1.18-py3-none-any.whl.
File metadata
- Download URL: batre_translator_cli-0.1.18-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7da899966ad1055207e46a40f5525b6b3ea6dc80a9b16d8de22573058705630
|
|
| MD5 |
08ff01773ab62bcc5af8225f7a6815d2
|
|
| BLAKE2b-256 |
675c9cf20893ac72fa35345bfe323213577e30397fbc9cf730bd6214f0612733
|