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

问题描述 投票:0回答:1

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

我想设置en = default 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 laravel-5.6
1个回答
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',
© www.soinside.com 2019 - 2024. All rights reserved.