https://github.com/demberto/tkinter-msgcat
Create multilingual interfaces for your tkinter applications
https://github.com/demberto/tkinter-msgcat
gettext i18n tkinter
Last synced: about 1 month ago
JSON representation
Create multilingual interfaces for your tkinter applications
- Host: GitHub
- URL: https://github.com/demberto/tkinter-msgcat
- Owner: demberto
- License: bsd-3-clause
- Created: 2022-04-17T08:14:25.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-19T08:14:17.000Z (about 3 years ago)
- Last Synced: 2025-04-14T07:06:10.451Z (about 1 month ago)
- Topics: gettext, i18n, tkinter
- Language: Python
- Homepage: https://tkmsgcat.rtfd.io
- Size: 19.5 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# tkinter-msgcat
> Create multilingual interfaces for your tkinter applications.
tkinter-msgcat leverages Tk's msgcat to provide a per-instance message catalog
which holds all the translations, while allowing them to be kept in separate
files away from code.## ⏬ Installation
tkinter-msgcat requires Python 3.7+
```
pip install tkinter-msgcat
```## ✨ Getting Started
1. For storing the translation files I recommend this folder hierarchy:
```
project (or src/project)
├── __init__.py
└── msgs
├── __init__.py
├── hi.msg
└── mr.msg
```This layout is recommended by [Tcl][recommended-layout].
2. Add some translations in the `.msg` files, in this case `hi.msg`:
```tcl
::msgcat::mcset hi "Hello" "नमस्ते"
```3. Create a Tkinter window *or instance, technically*.
4. Let's put tkinter-msgcat into action!
```python
from pathlib import Path
from tkmsgcat import *msgsdir = Path(__file__).parent / "msgs"
load(msgsdir)
locale("hi")
get("Hello") # "नमस्ते" 🥳
```## 🤝 Contributing
All contributions are welcome and acknowledged.
Please read the [contributor's guide][contributing].## © License
The code in this project is released under the [3-Clause BSD License][license].
[contributing]: https://github.com/demberto/tkinter-msgcat/blob/master/CONTRIBUTING.md
[docs]: https://tkmsgcat.readthedocs.io/en/latest/?badge=latest
[license]: https://github.com/demberto/tkinter-msgcat/blob/master/LICENSE
[recommended-layout]: https://www.tcl-lang.org/man/tcl/TclCmd/msgcat.htm#M22