# Messaging Templates i18n

## What is translated via `lang`

The admin interface for `/admin/messaging/templates` is translated through:

- `lang/ar/messaging.php`
- `lang/fr/messaging.php`

These files contain:

- Page titles, subtitles, filters, labels, buttons, statuses, empty states
- Friendly names and descriptions for each `template_key`
- Variable labels shown in the helper panel
- Channel and locale labels used in the admin UI

Examples:

- `messaging.templates.title`
- `messaging.templates.filters.channel`
- `messaging.templates.actions.save`
- `messaging.template_keys.student_enroll_created.label`
- `messaging.variables.student_name`

## What remains data in the database

The following fields are not translated through `lang` files because they are business content managed by administrators:

- `message_templates.title`
- `message_templates.body`

For each functional template, the database stores one row per:

- `template_key`
- `channel`
- `locale`

Example:

- `student_enroll_created + whatsapp + ar`
- `student_enroll_created + whatsapp + fr`

This keeps message content editable from the admin UI while preserving a localized interface.

## Admin UX rules

- The page groups templates by `template_key + channel`
- Arabic and French are edited together in the same editor
- The UI language changes with the admin locale immediately
- The message preview renders the selected locale using sample variables
- A warning is shown when one locale body is empty

## Seeder expectations

`MessagingTemplatesSeeder` guarantees both `ar` and `fr` rows for every seeded `template_key + channel` pair.

Current seeded keys:

- `student_enroll_created`
- `student_payment_confirmed`
- `admin_new_enrollment_alert`

## Important separation of concerns

- `lang/*/messaging.php` = admin interface localization
- `message_templates` table = editable message content per locale

This separation prevents technical identifiers from leaking into the UI while keeping message text operationally editable.
