Added the ability to automatically translate simple text.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Dto\Service\ProjectTranslationServiceTextHash;
|
||||
|
||||
final class Codes
|
||||
{
|
||||
private array $codes = [];
|
||||
|
||||
public function add(string $code, string $value): self
|
||||
{
|
||||
$this->codes[$code] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCodes(): array
|
||||
{
|
||||
return $this->codes;
|
||||
}
|
||||
|
||||
public function getCodeNames(): array
|
||||
{
|
||||
return \array_keys($this->codes);
|
||||
}
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Dto\Service\ProjectTranslationServiceTextHash;
|
||||
|
||||
final class HashStatusWaiting
|
||||
{
|
||||
private array $hash = [];
|
||||
|
||||
public function add(string $code, bool $isWaiting): void
|
||||
{
|
||||
$this->hash[$code] = $isWaiting;
|
||||
}
|
||||
|
||||
public function isStatusWaiting(string $code): bool
|
||||
{
|
||||
return $this->hash[$code] ?? false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Dto\Service\ProjectTranslationServiceTextHash;
|
||||
|
||||
final class Hashes
|
||||
{
|
||||
private array $hashes = [];
|
||||
private array $ids = [];
|
||||
|
||||
public function add(int $hashId, string $code, string $hash): void
|
||||
{
|
||||
$this->hashes[$hashId] = [
|
||||
'code' => $code,
|
||||
'hash' => $hash,
|
||||
];
|
||||
$this->ids[] = $hashId;
|
||||
}
|
||||
|
||||
public function getHash(int $hashId): ?array
|
||||
{
|
||||
return $this->hashes[$hashId] ?? null;
|
||||
}
|
||||
|
||||
public function getIds(): array
|
||||
{
|
||||
return $this->ids;
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Dto\Service\ProjectTranslationServiceTextHash;
|
||||
|
||||
final class TranslateCodes
|
||||
{
|
||||
private array $codes = [];
|
||||
private array $hashes = [];
|
||||
|
||||
public function add(int $languageId, string $code, string $hash, int $hashId): self
|
||||
{
|
||||
if (!isset($this->codes[$languageId])) {
|
||||
$this->codes[$languageId] = [];
|
||||
}
|
||||
$this->codes[$languageId][] = $code;
|
||||
|
||||
if (!isset($this->hashes[$languageId])) {
|
||||
$this->hashes[$languageId] = [];
|
||||
}
|
||||
$this->hashes[$languageId][$code] = [
|
||||
'hash' => $hash,
|
||||
'hashId' => $hashId,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCodes(): array
|
||||
{
|
||||
return $this->codes;
|
||||
}
|
||||
|
||||
public function getHashesByLanguage(int $languageId): array
|
||||
{
|
||||
return $this->hashes[$languageId] ?? [];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user