By Sheldon L | Published at 2020-08-09 | Updated at 2020-08-09 |
config/app.php
# https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
'timezone' => 'Asia/Taipei',
config/app.php
'locale' => 'lang=cn',
'fallback_locale' => 'cn',
# 简体: lang=zh_cmn_Hans
# 繁体: lang=zh_cmn_Hand
# 英语页面: lang=en
.env
LOCALE = "cn"
APPNAME = "Land View"
php artisan make:middleware SetLanguage
public function handle($request, Closure $next)
{
if ($request->locale) {
App::setLocale($request->locale);
} else {
App::setLocale(env('LOCALE ', 'cn'));
}
return $next($request);
}
Kernel.php
protected $middleware = [
// ...
\App\Http\Middleware\SetLanguage::class,
];
Route::group(['prefix' => '{locale?}'], function() {
Route::get('/', function () {
return view('welcome');
});
});
lang/en
to lang/cn
, Translate all settings, such as:# `lang/cn/app.php`
return [
"app_name" => "南德视界",
]
# `lang/cn/welcome.php`
return [
"title" => "南德视界",
]
# `views/welcome.blade.php`
<body>
<h1></h1>
</body>
route()
to:route('login', app()->getLocal())
<a href="">简体中文</a>
Translate/Customize Laravel Auth Default Emails
.env
: APP_NAME="Land View"
MAIL_FROM_NAME=ull
env.php
APP_NAME="Land Vision"
config/app.php
'name' => env('APP_NAME', 'Land Vision'),
<title></title>
<link rel="shortcut icon" href="">
/public