for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Services\Locale;
use App\Models\Fragment;
use Cache;
use Illuminate\Translation\FileLoader;
use Schema;
class TranslationLoader extends FileLoader
{
/**
* Load the messages for the given locale.
*
* @param string $locale
* @param string $group
* @param string $namespace
* @return array
*/
public function load($locale, $group, $namespace = null) : array
if (!is_null($namespace) && $namespace !== '*') {
return $this->loadNamespaced($locale, $group, $namespace);
}
if (!$this->fragmentsAreAvailable()) {
return [];
return Cache::rememberForever(
"locale.fragments.{$locale}.{$group}",
function () use ($group, $locale) {
return Fragment::getGroup($group, $locale);
);
protected function fragmentsAreAvailable() : bool
try {
return Schema::hasTable('fragments');
} catch (\Exception $e) {
return false;