Skip to main content

Automated i18n tool for Jinja2 projects using Babel and Google Translate

Project description

🧩 jinja-i18n-tools

Automated i18n tool for Jinja2-based projects using Babel and Google Translate.

📦 Features

  • 🔍 Extract translatable strings from your Jinja2 templates.
  • 🌐 Initialize .po files for multiple languages.
  • 🤖 Auto-translate using Google Translate via deep_translator.
  • 🛠️ Compile .po files into .mo.
  • 🧹 Automatically cleans up temporary files like messages.pot and babel.cfg.

⚙️ Installation

pip install jinja-i18n-tools

🚀 Usage

Activate your virtual environment, then run:

jinja-i18n full

This will:

  1. Copy babel.cfg to your project root.
  2. Extract translatable strings from your templates.
  3. Initialize translation files for each language.
  4. Auto-translate all strings.
  5. Compile .po files into .mo.
  6. Clean up temporary files.

🛠️ CLI Commands

jinja-i18n extract
jinja-i18n init
jinja-i18n translate --lang ar
jinja-i18n translate-all
jinja-i18n compile
jinja-i18n full --lang all --force

🌍 Languages

By default, the following languages are supported:

  • ar – Arabic
  • de – German

You can customize this in the source by editing the LANGUAGES list.


📁 Project Structure

Your Jinja2 templates and Python files must be located where your babel.cfg expects them. Here's a recommended configuration:

[python: **.py]
[jinja2: templates/**.html]
[jinja2: templates/**.j2] 
extensions=jinja2.ext.i18n

This configuration instructs pybabel to:

  • Extract translation strings from all Python files recursively.
  • Extract translatable content from all .html templates under the templates/ folder.
  • Enable the jinja2.ext.i18n extension to support {% trans %} blocks.

Make sure this file (babel.cfg) is located in your project root temporarily, or is copied automatically by the tool before running pybabel extract.


🧼 Cleanup

Temporary files like babel.cfg and messages.pot are deleted automatically after the process finishes.


📜 License

This project is licensed under the MIT License.
You are free to use, modify, and distribute it with attribution.
Feel free to explore and build upon it!


👨‍💻 About the Author

🎯 Tamer OnLine – Developer & Architect
A dedicated software engineer and educator with a focus on building multilingual, modular, and open-source applications using Python, Flask, and PostgreSQL.

🔹 Founder of Flask University – an initiative to create real-world, open-source Flask projects
🔹 Creator of @TamerOnPi – a YouTube channel sharing tech, tutorials, and Pi Network insights
🔹 Passionate about helping developers learn by building, one milestone at a time

Connect or contribute:

GitHub
LinkedIn
YouTube


💡 Got feedback or want to collaborate?
Open an issue, fork the repo, or just say hi on LinkedIn!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jinja_i18n_tools-0.1.2.tar.gz (12.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jinja_i18n_tools-0.1.2-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file jinja_i18n_tools-0.1.2.tar.gz.

File metadata

  • Download URL: jinja_i18n_tools-0.1.2.tar.gz
  • Upload date:
  • Size: 12.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for jinja_i18n_tools-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c3b35cbf9742f962e7422041a4bdfd987bda2601150549b41cbfad9adf92494f
MD5 6dc69c7c28fca9ead242a5135e298df4
BLAKE2b-256 36263c84e338265f9f0f36ae5c01b9a9ed87a043e6564147e8537b433b720985

See more details on using hashes here.

File details

Details for the file jinja_i18n_tools-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for jinja_i18n_tools-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 78cccec5d4bb77dcbbd66d45e38d5f7d656d44ea98adaa8ce1f70237aec8d321
MD5 023e2dc1e2659ac222d0a5e7f04de642
BLAKE2b-256 8e9300614f5865297694d4458bc7a4e5052b6855e1f19fefe089c3e8c9b21302

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page