-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #224 Implementation of the translatable interface. (laurentmu…
…ller) This PR was squashed before being merged into the 2.x-dev branch. Discussion ---------- Implementation of the translatable interface. This is the PR for the feature #221. Commits ------- 53ef960 Implementation of the translatable interface.
- Loading branch information
Showing
4 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/Bridge/Symfony/Translation/TranslatableEnumInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the "elao/enum" package. | ||
* | ||
* Copyright (C) Elao | ||
* | ||
* @author Elao <contact@elao.com> | ||
*/ | ||
|
||
namespace Elao\Enum\Bridge\Symfony\Translation; | ||
|
||
use Elao\Enum\ReadableEnumInterface; | ||
use Symfony\Contracts\Translation\TranslatableInterface; | ||
|
||
interface TranslatableEnumInterface extends ReadableEnumInterface, TranslatableInterface | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the "elao/enum" package. | ||
* | ||
* Copyright (C) Elao | ||
* | ||
* @author Elao <contact@elao.com> | ||
*/ | ||
|
||
namespace Elao\Enum\Bridge\Symfony\Translation; | ||
|
||
use Elao\Enum\ReadableEnumTrait; | ||
use Symfony\Contracts\Translation\TranslatorInterface; | ||
|
||
trait TranslatableEnumTrait | ||
{ | ||
use ReadableEnumTrait; | ||
|
||
public function trans(TranslatorInterface $translator, string $locale = null): string | ||
{ | ||
return $translator->trans($this->getReadable(), [], $locale); | ||
} | ||
} |