Internationalization
What it is
Ignite ships with two locales, English (en) and French (fr), covering both the backend (validation messages, mail, flash toasts) and the frontend (Vue component strings). The supported set is a single source of truth in config/locales.php:
'supported' => [
'en' => 'English',
'fr' => 'Français',
],Prerequisites
None. Both shipped locales work out of the box with no configuration.
The env vars: APP_LOCALE / APP_FALLBACK_LOCALE
APP_LOCALE=en
APP_FALLBACK_LOCALE=enBoth default to en in .env.example. APP_FALLBACK_LOCALE is the locale App\Http\Middleware\SetLocale falls back to when nothing else resolves a supported locale for the request.
How the locale is resolved
SetLocale runs on every request and picks the active locale in this order:
- The authenticated user's persisted
localecolumn, if logged in. - A guest
localecookie (App\Support\GuestLocale), used before registration. - The browser's
Accept-Languageheader, negotiated againstconfig('locales.supported'). APP_FALLBACK_LOCALE.
Any resolved value outside the supported list is rejected back to the fallback, so an unsupported Accept-Language or a tampered cookie can't select a locale with no translation files.
On the frontend, resources/js/lib/i18n.ts boots laravel-vue-i18n from the locale the server already resolved (read off the <html lang> attribute), so the client and server never disagree on first paint.
Translation file layout
lang/<locale>/*.php: PHP-array translation files, one per domain (auth.php,goals.php,validation.php,toasts.php, and so on). These exist for bothlang/en/andlang/fr/.lang/<locale>.json: flat string-key translations used bylaravel-vue-i18n's$t()on the frontend. Onlylang/en.jsonexists today; French frontend strings are served from the PHP files only (compiled tophp_fr.jsonat build time by thelaravel-vue-i18nVite plugin).resources/js/lib/i18n.tsmerges the build-time-generatedphp_<locale>.jsonwith the hand-written<locale>.jsonat runtime, JSON winning on key collisions.
Adding a new locale
- Add the locale code and display name to
config/locales.php'ssupportedarray. - Create
lang/<locale>/with the same PHP files aslang/en/, translated. - Optionally add
lang/<locale>.jsonfor any frontend-only strings not covered by the PHP files. - Rebuild frontend assets (
npm run buildor restartnpm run dev) so the Vite plugin picks up the newphp_<locale>.json.
How to verify
- Switch locale via the in-app language switcher (
LanguageSwitcher.vue/LocaleSelect.vue) and confirm both page chrome and validation error text change. - Send a request with
Accept-Language: frand no session/cookie locale; the response should render in French. - Check a logged-in user's
localecolumn takes priority over both the cookie and the header.
See Configuration for the full environment variable reference.