PHP 8 - Laravel Blog (App Config)

By Sheldon L Published at 2020-08-09 Updated at 2020-08-09


Timezone

# https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
'timezone' => 'Asia/Taipei',

Language

Change Default Language

'locale' => 'lang=cn',

'fallback_locale' => 'cn',

# 简体: lang=zh_cmn_Hans
# 繁体: lang=zh_cmn_Hand
# 英语页面: lang=en
LOCALE = "cn"

APPNAME = "Land View"
public function handle($request, Closure $next)
{
    if ($request->locale) {
        App::setLocale($request->locale);
    } else {
        App::setLocale(env('LOCALE ', 'cn'));
    }
    return $next($request);
}
protected $middleware = [
    // ...
    \App\Http\Middleware\SetLanguage::class,
];
Route::group(['prefix' => '{locale?}'], function() {
    Route::get('/', function () {
        return view('welcome');
    });
});
# `lang/cn/app.php`
return [
    "app_name" => "南德视界",
]

# `lang/cn/welcome.php`
return [
    "title" => "南德视界",
]
# `views/welcome.blade.php`
<body>
    <h1></h1>
</body>
route('login', app()->getLocal())
<a href="">简体中文</a>

Multi-Language Models

App Name

APP_NAME="Land Vision"
'name' => env('APP_NAME', 'Land Vision'),
<title></title>

Favicon

<link rel="shortcut icon" href="">