FIX: use LaravelLocalizationServiceProvider in CLI, but do not throw exceptions when table languages is missing
This commit is contained in:
@@ -11,17 +11,16 @@ class LaravelLocalizationServiceProvider extends ServiceProvider
|
|||||||
{
|
{
|
||||||
public function register()
|
public function register()
|
||||||
{
|
{
|
||||||
// localization is not important in running in CLI
|
try {
|
||||||
if (App::runningInConsole()) {
|
$languages = DB::table('languages')
|
||||||
return;
|
->get();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$languages = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$languages = DB::table('languages')
|
|
||||||
->get();
|
|
||||||
|
|
||||||
$supportedLocales = [];
|
$supportedLocales = [];
|
||||||
if (empty($languages)) {
|
if (empty($languages)) {
|
||||||
$supportedLocales[config('app.locale')] = (object)[
|
$supportedLocales[config('app.locale')] = [
|
||||||
'native' => env('LOCALE_NATIVE_NAME'),
|
'native' => env('LOCALE_NATIVE_NAME'),
|
||||||
'script' => env('LOCALE_SCRIPT'),
|
'script' => env('LOCALE_SCRIPT'),
|
||||||
'name' => env('LOCALE_TRANSLATED_NAME'),
|
'name' => env('LOCALE_TRANSLATED_NAME'),
|
||||||
@@ -29,7 +28,11 @@ class LaravelLocalizationServiceProvider extends ServiceProvider
|
|||||||
];
|
];
|
||||||
|
|
||||||
// create default language
|
// create default language
|
||||||
Language::create((array)$supportedLocales[config('app.locale')]);
|
try {
|
||||||
|
Language::create($supportedLocales[config('app.locale')]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// ignore, table languages probably does not exist.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($languages as $language) {
|
foreach ($languages as $language) {
|
||||||
|
|||||||
Reference in New Issue
Block a user