如果lang不存在,如何设置默认lang

时间:2018-09-11 15:57:37

标签: laravel laravel-5.6

如果lang不存在,如何设置默认lang。它应该重定向到我使用mcamara/laravel-localization package

的默认lang

我想设置en =默认lang,如果我输入的url不存在,我想重定向到en

example 

1 www.test.com/en/new

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

1 个答案:

答案 0 :(得分:0)

Laravel默认带有en,您可以在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',