首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如果语言不存在,如何设置默认语言

如果语言不存在,如何设置默认语言
EN

Stack Overflow用户
提问于 2018-09-11 23:57:37
回答 1查看 250关注 0票数 0

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

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

代码语言:javascript
复制
example 

1 www.test.com/en/new

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

回答 1

Stack Overflow用户

发布于 2018-09-12 00:53:34

config/app.php默认附带en,您可以在Laravel中指定回退

代码语言:javascript
复制
/*
|--------------------------------------------------------------------------
| 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',
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52279918

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档