Skip to content

Commit

Permalink
Translation loading fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aon4o authored Jul 25, 2024
1 parent b077803 commit 57e03e4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/LanguageLine.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ public static function boot(): void

public static function getTranslationsForGroup(string $locale, string $group): array
{
// When the app uses laravel-sail the package breaks every artisan command ran outside sail context.
// That's beacuse artisan starts an app and registers all service providers, but the database is unavailable
// beacause the hostname (e.g. mysql) is unresolvable.
try {
DB::connection()->getPdo();
} catch (PDOException $exception) {
Log::error('laravel-translation-loader: Could not connect to the database, falling back to file translations');
return [];
}

return Cache::rememberForever(static::getCacheKey($group, $locale), function () use ($group, $locale) {
return static::query()
->where('group', $group)
Expand Down

0 comments on commit 57e03e4

Please sign in to comment.