Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ethar's avatar
Level 5

Mcamara Package Error

hi after install Mcamara Package i got this Error Mcamara\LaravelLocalization\Exceptions\SupportedLocalesNotDefined Supported locales must be defined.

any solution to solve this problem

0 likes
5 replies
MichalOravec's avatar

Run

php artisan vendor:publish --provider="Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider"

and then

php artisan config:clear

// or

php artisan config:cache
1 like
aurawindsurfing's avatar

Hi @ethar

php artisan vendor:publish --provider="Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider"

its in the docs, you probably need to define your locales in config file first:

The configuration options are:

- supportedLocales Languages of your app (Default: English & Spanish).
- useAcceptLanguageHeader If true, then automatically detect language from browser.
- hideDefaultLocaleInURL If true, then do not show default locale in url.
- localesOrder Sort languages in custom order.
- localesMapping Rename url locales.
- utf8suffix Allow changing utf8suffix for CentOS etc.
- urlsIgnored Ignore specific urls.

So I guess you locale is neither english or spanish?

Hope it helps!

ethar's avatar
Level 5

when i perform any of above commands I got

Mcamara\LaravelLocalization\Exceptions\SupportedLocalesNotDefined

Supported locales must be defined.

at C:\xampp\htdocs\site\panorama\vendor\mcamara\laravel-localization\src\Mcamara\LaravelLocalization\LaravelLocalization.php:470 466| 467| $locales = $this->configRepository->get('laravellocalization.supportedLocales'); 468| 469| if (empty($locales) || !\is_array($locales)) {

470| throw new SupportedLocalesNotDefined(); 471| } 472| 473| $this->supportedLocales = $locales; 474|

1 C:\xampp\htdocs\site\panorama\vendor\mcamara\laravel-localization\src\Mcamara\LaravelLocalization\LaravelLocalization.php:141 Mcamara\LaravelLocalization\LaravelLocalization::getSupportedLocales()

2 C:\xampp\htdocs\site\panorama\vendor\mcamara\laravel-localization\src\Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider.php:55 Mcamara\LaravelLocalization\LaravelLocalization::__construct()

ethar's avatar
Level 5

when i perform any of above commands I got

Mcamara\LaravelLocalization\Exceptions\SupportedLocalesNotDefined

Supported locales must be defined.

at C:\xampp\htdocs\site\panorama\vendor\mcamara\laravel-localization\src\Mcamara\LaravelLocalization\LaravelLocalization.php:470 466| 467| $locales = $this->configRepository->get('laravellocalization.supportedLocales'); 468| 469| if (empty($locales) || !\is_array($locales)) {

470| throw new SupportedLocalesNotDefined(); 471| } 472| 473| $this->supportedLocales = $locales; 474|

1 C:\xampp\htdocs\site\panorama\vendor\mcamara\laravel-localization\src\Mcamara\LaravelLocalization\LaravelLocalization.php:141 Mcamara\LaravelLocalization\LaravelLocalization::getSupportedLocales()

2 C:\xampp\htdocs\site\panorama\vendor\mcamara\laravel-localization\src\Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider.php:55 Mcamara\LaravelLocalization\LaravelLocalization::__construct()

semsem's avatar
semsem
Best Answer
Level 1

Hi I have the same problem

look.. if you have this line in Web.php file

Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['localeSessionRedirect', 'localizationRedirect', 'localeViewPath']], function ()

1- make it's as comment and run in terminal -> php artisan config:cache.

2- then delete comment from line.

i hope worked

3 likes

Please or to participate in this conversation.