Custom Translations
This commit is contained in:
parent
efb40f1777
commit
58ef5240cd
2 changed files with 23 additions and 0 deletions
|
|
@ -12,7 +12,9 @@
|
|||
namespace App\Http\ViewComposers;
|
||||
|
||||
use App\Models\ClientContact;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\TranslationHelper;
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
use Illuminate\View\View;
|
||||
|
||||
/**
|
||||
|
|
@ -29,6 +31,9 @@ class PortalComposer
|
|||
public function compose(View $view) :void
|
||||
{
|
||||
$view->with($this->portalData());
|
||||
|
||||
if(auth()->user())
|
||||
Lang::replace(Ninja::transformTranslations(auth()->user()->client->getMergedSettings()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -121,4 +121,22 @@ class Ninja
|
|||
'is_system' => app()->runningInConsole(),
|
||||
];
|
||||
}
|
||||
|
||||
public static function transformTranslations($settings) :array
|
||||
{
|
||||
$translations = [];
|
||||
|
||||
$trans = (array)$settings->translations;
|
||||
|
||||
if(count($trans) == 0)
|
||||
return $translations;
|
||||
|
||||
foreach($trans as $key => $value)
|
||||
{
|
||||
$translations['texts.'.$key] = $value;
|
||||
}
|
||||
|
||||
return $translations;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue