TryHardz
TryHardz

Reputation: 159

How to set default lang if lang doesn't exist

How to set default lang if lang doesn't exist . It should redirect to default lang I use mcamara/laravel-localization package

I want to set en = default lang and if I type url isn't exist I want to redirect into en

example 

1 www.test.com/en/new

2 www.test.com/cn/new <- this url empty it should redirect into url 1 

Upvotes: 0

Views: 625

Answers (1)

emotality
emotality

Reputation: 13025

Laravel comes with en as default and you can specify the fallback in config/app.php

/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/

'locale' => 'en',

/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/

'fallback_locale' => 'en',

Upvotes: 1

Related Questions