# Shark CRM Multi Language System

## What was added

- Database-driven language system.
- Add unlimited languages from Settings > Languages.
- Translation manager from database; no code changes needed to add a new language.
- User language switcher in the top header.
- Account default language support.
- User language support.
- RTL/LTR support through the language direction field.
- AJAX/JSON response messages pass through the translation layer.
- Auto-capture layer for visible PHP page text: browsing pages registers missing text keys automatically under the `auto` group.
- JavaScript loading/request messages use translations.

## Install

1. Upload the new code.
2. Run this migration once in phpMyAdmin:

`migrations/2026_06_19_multilanguage.sql`

3. Open Settings > Languages.
4. Add any language you want.
5. Click Translate and fill missing translations.

## Developer use

For new code, never print text directly. Use:

```php
__('buttons.save', 'Save')
_e('customers.title', 'Customers')
jsonResponse(false, 'Customer not found')
```

For JavaScript:

```js
__t('js.saving', 'Saving...')
```

## Notes

The auto-capture layer makes old hardcoded page text translatable without editing every page manually. For best control, new features should use explicit translation keys.

## 2026-06-19 Full Seed Fix

The first version used auto-capture for many old labels. This updated package now includes a full seed file:

- `migrations/2026_06_19_multilanguage_full_seed.sql`
- The same seed is also appended to `migrations/2026_06_19_multilanguage.sql`

It pre-inserts extracted page labels, buttons, placeholders, headings, JS texts, and AJAX/server messages into `translation_keys` and `translations` for English and Arabic.

Run only:

```sql
migrations/2026_06_19_multilanguage.sql
```

If you already ran the first migration, run:

```sql
migrations/2026_06_19_multilanguage_full_seed.sql
```
