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



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

我想设置 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 

>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',

相关内容

最新更新