People searching “Laravel locale Vue” call App::setLocale($request->query('locale')) with no list. The i18n guide is the Vue strings. This page is the one line that picks the language for Laravel’s own translator.
TL;DR
- Set the locale from an allow-list.
- A query string is not a locale until you have checked it.
- Do not pass the raw query string into
setLocale. - Do not store the locale only in
localStorage.
The fix#
$locale = $request->string('locale')->toString();
if (in_array($locale, ['en', 'fr', 'ar'], true)) {
$request->user()->update(['locale' => $locale]);
App::setLocale($locale);
}Share the current locale if the layout needs it. Validation messages then use that language on the next response.
What to avoid#
Gotcha
Do not pass the raw query string into setLocale. An unknown locale falls through to odd file lookups. Do not store the locale only in localStorage. The server renders the flash and the mail, and it cannot see that key.
FAQ#
How do I switch the app locale from Vue?
Set the locale from an allow-list. A query string is not a locale until you have checked it.
What goes wrong with Laravel locale Vue?
Many developers call App::setLocale($request->query('locale')) with no list. Do not pass the raw query string into setLocale.



