https://github.com/tameronline/jinja-ui
Reusable UI components and macros for Jinja2 templates. Clean, customizable, and ready to use.
https://github.com/tameronline/jinja-ui
Last synced: 5 months ago
JSON representation
Reusable UI components and macros for Jinja2 templates. Clean, customizable, and ready to use.
- Host: GitHub
- URL: https://github.com/tameronline/jinja-ui
- Owner: TamerOnLine
- License: mit
- Created: 2025-06-24T13:19:54.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-24T13:37:03.000Z (about 1 year ago)
- Last Synced: 2025-06-24T14:34:55.465Z (about 1 year ago)
- Language: Jinja
- Size: 13.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐งฉ 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
```bash
pip install jinja-i18n-tools
```
---
## ๐ Usage
Activate your virtual environment, then run:
```bash
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
```bash
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](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](https://www.youtube.com/@mystrotamer) โ 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:
[](https://github.com/TamerOnLine)
[](https://www.linkedin.com/in/tameronline/)
[](https://www.youtube.com/@mystrotamer)
---
> ๐ก **Got feedback or want to collaborate?**
> Open an issue, fork the repo, or just say hi on LinkedIn!