Add Python Example Integration for Lingo.dev
- Summary
Lingo.dev currently provides integration examples for JavaScript frameworks (Next.js, Vue, etc.), but there is no example for Python users.
- Proposal
Add a simple Python example that demonstrates how to:
-
Load translation JSON files exported from Lingo.dev
-
Access translations inside a backend / CLI environment
-
Switch languages dynamically
-
Why this is useful
Many backend developers (especially beginners) use Python without any frontend framework. Having a basic example will help them adopt Lingo.dev without needing to learn React or TypeScript.
- Planned Folder Structure
examples/python-basic/ ├── translations/ │ ├── en.json │ └── hi.json ├── translator.py ├── app.py └── README.md
#Request Please confirm if I can proceed with implementing this example. I will open a PR once approved.
Hey everyone 👋
I noticed that Lingo.dev already provides great integration examples for JavaScript-based frameworks like Next.js and Vue, but there isn’t anything yet for Python users. Since a lot of backend developers (including those building small APIs, CLI tools, or automation scripts) primarily work in Python, I thought it might be useful to have a minimal Python example that shows how to load and use translations directly—without needing to touch any frontend code.
What I’m Proposing
I’d like to add a new example under:
examples/python-basic/
Structure
examples/python-basic/ ├── translations/ │ ├── en.json │ └── hi.json ├── translator.py ├── app.py └── README.md
The goal is to show three core things:
1. How to load translation JSON files exported from Lingo.dev
2. How to access translations in a backend or CLI environment
3. How to switch languages dynamically at runtime
---
How It Works
translator.py
A simple `Translator` class that reads JSON files, provides a `.t(key)` helper for fetching translations, and lets you change the active language with `.set_language(lang)`.
```python
import json
import os
class Translator:
def __init__(self, lang="en", translations_path="translations"):
self.translations_path = translations_path
self.set_language(lang)
def set_language(self, lang):
file_path = os.path.join(self.translations_path, f"{lang}.json")
with open(file_path, "r", encoding="utf-8") as f:
self.translations = json.load(f)
self.lang = lang
def t(self, key):
return self.translations.get(key, key)
app.py
A small demo showing how to use it.
from translator import Translator
if __name__ == "__main__":
t = Translator("en")
print(t.t("greeting")) # Hello
t.set_language("hi")
print(t.t("greeting")) # नमस्ते
translations/en.json
{
"greeting": "Hello",
"farewell": "Goodbye"
}
translations/hi.json
{
"greeting": "नमस्ते",
"farewell": "अलविदा"
}
README Overview
The README would include:
- Quick setup steps
- Example usage
- Notes on extending it to Flask or FastAPI if needed later
Example snippet:
# Python Basic Example for Lingo.dev
This example shows how to use translations from Lingo.dev in a simple Python script or backend app.
## Usage
1. Place your exported JSON files in the `translations/` folder
2. Run:
```bash
python app.py
-
Change languages dynamically with:
t.set_language("hi")
Why This Helps
This gives Python users a clear starting point without needing to learn React, TypeScript, or any frontend concepts.
It also shows that Lingo.dev isn’t limited to web frameworks—it can easily integrate with any stack.
If this direction looks good, I’ll go ahead and implement it and open a PR.
Happy to make adjustments if there’s a specific style or format you’d like for the examples folder.
Thanks for considering this!
I find this idea interesting, can I also work on this with you
Hi maintainers! I'm interested in contributing a Python integration example for Lingo.dev to support backend developers who aren't using front-end frameworks.
My Implementation Plan Goal: Make it easy for Python users to:
- Load translation JSONs exported from Lingo.dev
- Access and switch languages inside backend or CLI scripts
- Follow a clear, beginner-friendly folder/sample code layout
Proposed Structure:
examples/python-basic/ ├── translations/ │ ├── en.json │ └── hi.json ├── translator.py ├── app.py └── README.md
How the Example Will Work:
- Load translations via a simple Translator class
- Change languages dynamically (e.g., en ⇄ hi)
- Demo script (app.py) shows real usage: print translated messages in different languages
Why this would help: Many Python developers just want to plug in i18n without the complexity of frameworks. This example would lower the entry barrier and document best practices for real-world use!
I've created a comprehensive Python integration example! 🎉
PR: #1458
What's Included:
✅ Clean Translator class with intuitive API
✅ Multi-language support (English, Hindi, Spanish)
✅ Comprehensive README with Flask, FastAPI, and CLI examples
✅ Zero external dependencies
✅ Full error handling and documentation
The example is production-ready and follows Python best practices. Ready for review!
Hey folks @Adityaraj32 @amankamlesh @1234-ad @sachinm121 @Godxflashh please avoid simply pushing PRs to an issue if it hasn't been assigned to you.
It wastes everyone's time and dilutes enthusiasm.
If you see an open issue that hasn't been claimed by anyone, drop a comment there asking to be assigned, wait for one of the maintainers to assign it to you and then only submit a PR.
If you want to contribute and all the open issues have been taken, please use the app extensively to find any bugs/features and raise a issue on the repo.
Keep this in mind from now on.
Thank you.
And happy contributing.
Hi! I want to work on this issue.
Could you please assign it to me?
I will make sure to prepare the Python example exactly as described and open the PR after you confirm.
Assigning it to you @Adityaraj32
Have fun! 🎉
@Adityaraj32 keep this in mind:
We'll prefer examples that use actual frameworks (e.g., Django), rather than completely custom code.
@Adityaraj32 keep this in mind:
We'll prefer examples that use actual frameworks (e.g., Django), rather than completely custom code.
Got it! I’ll use Django for the examples. Thanks for the clarification
Hi! 👋 I’d like to contribute to this issue by improving or extending the Python example (e.g., adding more languages, CLI usage, or API integration).
Can you please assign this issue to me? Thanks!