Metadata-Version: 2.4
Name: pylyglot
Version: 1.0.0
Summary: A lightweight, extensible i18n utility for Python projects
Author: Aaquinas
License: MIT License
        
        Copyright (c) 2025 Aaquinas
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in
        all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
        THE SOFTWARE.
        
Project-URL: Homepage, https://gitlab.com/Aaquinas/pylyglot
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# PyLyglot

**PyLyglot** est une bibliothèque Python de traduction simple, extensible et thread-safe, utilisant le pattern singleton pour centraliser la gestion des langues. Elle permet la traduction de clés hiérarchiques avec gestion du fallback et formatage dynamique.

## 📦 Fonctionnalités

- Chargement automatique de fichiers JSON de traduction.
- Détection automatique de la langue du système.
- Fallback intelligent vers des langues plus générales (ex: `fr-CA` → `fr` → `en`).
- Clés hiérarchiques via la notation `dot.key`.
- Formatage avec `str.format()`.
- Gestion personnalisée des clés manquantes.

## 🛠 Installation

```bash
pip install pylyglot
```
Ou ajoute-le directement à ton pyproject.toml si tu utilises Poetry.

## 📁 Structure des fichiers
Les fichiers de langue doivent être placés dans un répertoire lang/ à la racine de ton projet.
Exemple :
```pgsql
lang/
├── en.json
├── fr.json
```
Exemple de fichier en.json :
```json
{
    "_meta": {
      "version": "1.0",
      "author": "Your Name"
    },
    "menu": {
        "start": "Start",
        "quit": "Quit"
    },
    "welcome": "Welcome, {username}!"
}
```
## 🚀 Utilisation
 - 1 Créer le dossier /lang à la racine de votre proket
 - 2 ajouter les fichiers de langues
```python
from pylyglot import PyLyglot

def missing_key_handler(key):
    return f"<<{key}>>"

pl = PyLyglot(missing_key_handler=missing_key_handler)

print(pl("menu.start"))              # Start
print(pl("menu.quit"))               # Quit
print(pl("welcome", username="Alice"))  # Welcome, Alice!
```
