my-projects-website/app/application/app/Services/WebsiteTranslations.php

24 lines
475 B
PHP

<?php declare(strict_types=1);
namespace App\Services;
use App\Models\ProjectLanguage;
final readonly class WebsiteTranslations
{
public function __construct(
private ProjectLanguage $language,
private array $transactions,
) { }
public function translate(string $text): string
{
return $this->transactions[$text] ?? __($text);
}
public function getLanguage(): ProjectLanguage
{
return $this->language;
}
}