# Templates i18n - Application Skill

> Ces templates génèrent les fichiers de traduction pour les 4 langues obligatoires.

---

## STRUCTURE DES FICHIERS

```
web/smartstack-web/src/i18n/locales/
├── fr/$module.json    # Français (langue principale)
├── en/$module.json    # English
├── it/$module.json    # Italiano
└── de/$module.json    # Deutsch
```

---

## TEMPLATE: FRANÇAIS (fr/$module.json)

```json
{
  "title": "$TITLE_FR",
  "subtitle": "$SUBTITLE_FR",

  "columns": {
    "name": "Nom",
    "description": "Description",
    "status": "Statut",
    "createdAt": "Créé le",
    "updatedAt": "Modifié le",
    "actions": "Actions"
  },

  "form": {
    "title": {
      "create": "Créer $ENTITY_FR",
      "edit": "Modifier $ENTITY_FR"
    },
    "fields": {
      "name": {
        "label": "Nom",
        "placeholder": "Entrez le nom",
        "required": "Le nom est requis"
      },
      "description": {
        "label": "Description",
        "placeholder": "Entrez une description (optionnel)"
      },
      "isActive": {
        "label": "Actif",
        "description": "Activer ou désactiver cet élément"
      }
    },
    "buttons": {
      "submit": "Enregistrer",
      "cancel": "Annuler",
      "delete": "Supprimer"
    }
  },

  "detail": {
    "title": "Détail $ENTITY_FR",
    "tabs": {
      "general": "Général",
      "history": "Historique"
    },
    "sections": {
      "info": "Informations générales",
      "metadata": "Métadonnées"
    }
  },

  "list": {
    "empty": "Aucun $ENTITY_FR_PLURAL trouvé",
    "loading": "Chargement...",
    "error": "Erreur lors du chargement des $ENTITY_FR_PLURAL"
  },

  "messages": {
    "createSuccess": "$ENTITY_FR créé avec succès",
    "updateSuccess": "$ENTITY_FR mis à jour avec succès",
    "deleteSuccess": "$ENTITY_FR supprimé avec succès",
    "deleteConfirm": "Êtes-vous sûr de vouloir supprimer ce $ENTITY_FR ?",
    "error": "Une erreur est survenue"
  },

  "filters": {
    "searchPlaceholder": "Rechercher $ENTITY_FR_PLURAL...",
    "status": {
      "all": "Tous",
      "active": "Actifs",
      "inactive": "Inactifs"
    },
    "dateRange": {
      "label": "Période",
      "all": "Toutes",
      "today": "Aujourd'hui",
      "week": "Cette semaine",
      "month": "Ce mois"
    }
  }
}
```

---

## TEMPLATE: ENGLISH (en/$module.json)

```json
{
  "title": "$TITLE_EN",
  "subtitle": "$SUBTITLE_EN",

  "columns": {
    "name": "Name",
    "description": "Description",
    "status": "Status",
    "createdAt": "Created",
    "updatedAt": "Updated",
    "actions": "Actions"
  },

  "form": {
    "title": {
      "create": "Create $ENTITY_EN",
      "edit": "Edit $ENTITY_EN"
    },
    "fields": {
      "name": {
        "label": "Name",
        "placeholder": "Enter name",
        "required": "Name is required"
      },
      "description": {
        "label": "Description",
        "placeholder": "Enter description (optional)"
      },
      "isActive": {
        "label": "Active",
        "description": "Enable or disable this item"
      }
    },
    "buttons": {
      "submit": "Save",
      "cancel": "Cancel",
      "delete": "Delete"
    }
  },

  "detail": {
    "title": "$ENTITY_EN Detail",
    "tabs": {
      "general": "General",
      "history": "History"
    },
    "sections": {
      "info": "General Information",
      "metadata": "Metadata"
    }
  },

  "list": {
    "empty": "No $ENTITY_EN_PLURAL found",
    "loading": "Loading...",
    "error": "Error loading $ENTITY_EN_PLURAL"
  },

  "messages": {
    "createSuccess": "$ENTITY_EN created successfully",
    "updateSuccess": "$ENTITY_EN updated successfully",
    "deleteSuccess": "$ENTITY_EN deleted successfully",
    "deleteConfirm": "Are you sure you want to delete this $ENTITY_EN?",
    "error": "An error occurred"
  },

  "filters": {
    "searchPlaceholder": "Search $ENTITY_EN_PLURAL...",
    "status": {
      "all": "All",
      "active": "Active",
      "inactive": "Inactive"
    },
    "dateRange": {
      "label": "Period",
      "all": "All",
      "today": "Today",
      "week": "This week",
      "month": "This month"
    }
  }
}
```

---

## TEMPLATE: ITALIANO (it/$module.json)

```json
{
  "title": "$TITLE_IT",
  "subtitle": "$SUBTITLE_IT",

  "columns": {
    "name": "Nome",
    "description": "Descrizione",
    "status": "Stato",
    "createdAt": "Creato il",
    "updatedAt": "Modificato il",
    "actions": "Azioni"
  },

  "form": {
    "title": {
      "create": "Crea $ENTITY_IT",
      "edit": "Modifica $ENTITY_IT"
    },
    "fields": {
      "name": {
        "label": "Nome",
        "placeholder": "Inserisci il nome",
        "required": "Il nome è obbligatorio"
      },
      "description": {
        "label": "Descrizione",
        "placeholder": "Inserisci una descrizione (opzionale)"
      },
      "isActive": {
        "label": "Attivo",
        "description": "Attiva o disattiva questo elemento"
      }
    },
    "buttons": {
      "submit": "Salva",
      "cancel": "Annulla",
      "delete": "Elimina"
    }
  },

  "detail": {
    "title": "Dettaglio $ENTITY_IT",
    "tabs": {
      "general": "Generale",
      "history": "Cronologia"
    },
    "sections": {
      "info": "Informazioni generali",
      "metadata": "Metadati"
    }
  },

  "list": {
    "empty": "Nessun $ENTITY_IT_PLURAL trovato",
    "loading": "Caricamento...",
    "error": "Errore durante il caricamento dei $ENTITY_IT_PLURAL"
  },

  "messages": {
    "createSuccess": "$ENTITY_IT creato con successo",
    "updateSuccess": "$ENTITY_IT aggiornato con successo",
    "deleteSuccess": "$ENTITY_IT eliminato con successo",
    "deleteConfirm": "Sei sicuro di voler eliminare questo $ENTITY_IT?",
    "error": "Si è verificato un errore"
  },

  "filters": {
    "searchPlaceholder": "Cerca $ENTITY_IT_PLURAL...",
    "status": {
      "all": "Tutti",
      "active": "Attivi",
      "inactive": "Inattivi"
    },
    "dateRange": {
      "label": "Periodo",
      "all": "Tutti",
      "today": "Oggi",
      "week": "Questa settimana",
      "month": "Questo mese"
    }
  }
}
```

---

## TEMPLATE: DEUTSCH (de/$module.json)

```json
{
  "title": "$TITLE_DE",
  "subtitle": "$SUBTITLE_DE",

  "columns": {
    "name": "Name",
    "description": "Beschreibung",
    "status": "Status",
    "createdAt": "Erstellt am",
    "updatedAt": "Geändert am",
    "actions": "Aktionen"
  },

  "form": {
    "title": {
      "create": "$ENTITY_DE erstellen",
      "edit": "$ENTITY_DE bearbeiten"
    },
    "fields": {
      "name": {
        "label": "Name",
        "placeholder": "Name eingeben",
        "required": "Name ist erforderlich"
      },
      "description": {
        "label": "Beschreibung",
        "placeholder": "Beschreibung eingeben (optional)"
      },
      "isActive": {
        "label": "Aktiv",
        "description": "Dieses Element aktivieren oder deaktivieren"
      }
    },
    "buttons": {
      "submit": "Speichern",
      "cancel": "Abbrechen",
      "delete": "Löschen"
    }
  },

  "detail": {
    "title": "$ENTITY_DE-Details",
    "tabs": {
      "general": "Allgemein",
      "history": "Verlauf"
    },
    "sections": {
      "info": "Allgemeine Informationen",
      "metadata": "Metadaten"
    }
  },

  "list": {
    "empty": "Keine $ENTITY_DE_PLURAL gefunden",
    "loading": "Laden...",
    "error": "Fehler beim Laden der $ENTITY_DE_PLURAL"
  },

  "messages": {
    "createSuccess": "$ENTITY_DE erfolgreich erstellt",
    "updateSuccess": "$ENTITY_DE erfolgreich aktualisiert",
    "deleteSuccess": "$ENTITY_DE erfolgreich gelöscht",
    "deleteConfirm": "Sind Sie sicher, dass Sie dieses $ENTITY_DE löschen möchten?",
    "error": "Ein Fehler ist aufgetreten"
  },

  "filters": {
    "searchPlaceholder": "$ENTITY_DE_PLURAL suchen...",
    "status": {
      "all": "Alle",
      "active": "Aktiv",
      "inactive": "Inaktiv"
    },
    "dateRange": {
      "label": "Zeitraum",
      "all": "Alle",
      "today": "Heute",
      "week": "Diese Woche",
      "month": "Dieser Monat"
    }
  }
}
```

---

## MISE À JOUR NAVIGATION.JSON

Pour chaque entité de navigation créée, mettre à jour les fichiers `navigation.json` :

### fr/navigation.json

```json
{
  "modules": {
    "$module": "$LABEL_FR"
  },
  "applications": {
    "$application": "$APP_LABEL_FR"
  }
}
```

### en/navigation.json

```json
{
  "modules": {
    "$module": "$LABEL_EN"
  },
  "applications": {
    "$application": "$APP_LABEL_EN"
  }
}
```

### it/navigation.json

```json
{
  "modules": {
    "$module": "$LABEL_IT"
  },
  "applications": {
    "$application": "$APP_LABEL_IT"
  }
}
```

### de/navigation.json

```json
{
  "modules": {
    "$module": "$LABEL_DE"
  },
  "applications": {
    "$application": "$APP_LABEL_DE"
  }
}
```

---

## ENREGISTREMENT i18n

Ajouter le namespace dans `i18n/index.ts` :

```typescript
// Ajouter l'import
import $module_fr from './locales/fr/$module.json';
import $module_en from './locales/en/$module.json';
import $module_it from './locales/it/$module.json';
import $module_de from './locales/de/$module.json';

// Ajouter dans les resources
resources: {
  fr: {
    // ... existing
    $module: $module_fr,
  },
  en: {
    // ... existing
    $module: $module_en,
  },
  it: {
    // ... existing
    $module: $module_it,
  },
  de: {
    // ... existing
    $module: $module_de,
  },
}
```

---

## EXEMPLE COMPLET: Module "Products"

### Variables

```
$MODULE = products
$ENTITY_FR = Produit / Produits
$ENTITY_EN = Product / Products
$ENTITY_IT = Prodotto / Prodotti
$ENTITY_DE = Produkt / Produkte

$TITLE_FR = Gestion des produits
$TITLE_EN = Product Management
$TITLE_IT = Gestione prodotti
$TITLE_DE = Produktverwaltung

$SUBTITLE_FR = Gérez votre catalogue de produits
$SUBTITLE_EN = Manage your product catalog
$SUBTITLE_IT = Gestisci il tuo catalogo prodotti
$SUBTITLE_DE = Verwalten Sie Ihren Produktkatalog
```

---

## CHECKLIST I18N

| Vérification | Status |
|--------------|--------|
| ☐ fr/$module.json créé | |
| ☐ en/$module.json créé | |
| ☐ it/$module.json créé | |
| ☐ de/$module.json créé | |
| ☐ navigation.json mis à jour (4 langues) | |
| ☐ Namespace enregistré dans i18n/index.ts | |
| ☐ Toutes les clés présentes dans les 4 fichiers | |
| ☐ Pas de clés manquantes | |

---

## OUTILS DE VALIDATION

```bash
# Vérifier que toutes les clés sont présentes dans les 4 langues
# Script à exécuter depuis web/smartstack-web

# Liste les clés du fichier français (référence)
jq -r 'paths(scalars) | join(".")' src/i18n/locales/fr/$module.json > /tmp/fr_keys.txt

# Compare avec les autres langues
for lang in en it de; do
  jq -r 'paths(scalars) | join(".")' src/i18n/locales/$lang/$module.json > /tmp/${lang}_keys.txt
  diff /tmp/fr_keys.txt /tmp/${lang}_keys.txt
done
```
