Fixes #2 add enum transalation for difficulty_enum
This commit is contained in:
parent
802d7eda8e
commit
c190de01d6
3 changed files with 22 additions and 1 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Traits\Enums;
|
||||
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
|
|
@ -27,7 +28,9 @@ trait BaseEnum
|
|||
*/
|
||||
public function label(): string
|
||||
{
|
||||
return self::toLabels()[$this->name];
|
||||
$class = Str::snake(\class_basename(\get_class($this)));
|
||||
return Lang::has("enums.{$class}.{$this->name}") ?
|
||||
Lang::get("enums.{$class}.{$this->name}") : self::toLabels()[$this->name];
|
||||
}
|
||||
|
||||
// * STATIC FETCH METHODS
|
||||
|
|
|
|||
9
resources/lang/de/enums.php
Normal file
9
resources/lang/de/enums.php
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'difficulty_enum' => [
|
||||
'easy' => 'leicht',
|
||||
'medium' => 'mittlere',
|
||||
'hard' => 'hart',
|
||||
]
|
||||
];
|
||||
9
resources/lang/en/enums.php
Normal file
9
resources/lang/en/enums.php
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'difficulty_enum' => [
|
||||
'easy' => 'easy',
|
||||
'medium' => 'medium',
|
||||
'hard' => 'hard',
|
||||
]
|
||||
];
|
||||
Loading…
Add table
Reference in a new issue