Added the ability to dynamically translate on the project website.

This commit is contained in:
2024-04-22 23:52:04 +05:00
parent a648ba3db9
commit 491249c8d8
55 changed files with 867 additions and 119 deletions

View File

@@ -0,0 +1,23 @@
<?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;
}
}