Add initial translations for enumerated values
This commit is contained in:
parent
e5278bc0bf
commit
3f8073e552
@ -17,12 +17,12 @@ class Days extends EnumBase {
|
|||||||
const SUNDAY = 64;
|
const SUNDAY = 64;
|
||||||
|
|
||||||
protected static $labels = [
|
protected static $labels = [
|
||||||
Days::MONDAY => 'Monday',
|
Days::MONDAY => 'system.days.mon',
|
||||||
Days::TUESDAY => 'Tuesday',
|
Days::TUESDAY => 'system.days.tues',
|
||||||
Days::WEDNESDAY => 'Wednesday',
|
Days::WEDNESDAY => 'system.days.wed',
|
||||||
Days::THURSDAY => 'Thursday',
|
Days::THURSDAY => 'system.days.thurs',
|
||||||
Days::FRIDAY => 'Friday',
|
Days::FRIDAY => 'system.days.fri',
|
||||||
Days::SATURDAY => 'Saturday',
|
Days::SATURDAY => 'system.days.sat',
|
||||||
Days::SUNDAY => 'Sunday',
|
Days::SUNDAY => 'system.days.sun',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -17,12 +17,16 @@ namespace App\Models\Enums;
|
|||||||
class EnumBase
|
class EnumBase
|
||||||
{
|
{
|
||||||
protected static $labels = [];
|
protected static $labels = [];
|
||||||
|
protected static $adverbs = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Return the label, try to return the translated version as well
|
||||||
* @param $value
|
* @param $value
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public static function label($value) {
|
public static function label($value) {
|
||||||
return self::$labels[$value];
|
if(isset(static::$labels[$value])) {
|
||||||
|
return trans(static::$labels[$value]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,16 +2,16 @@
|
|||||||
|
|
||||||
namespace App\Models\Enums;
|
namespace App\Models\Enums;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Facade;
|
|
||||||
|
|
||||||
class PirepState extends EnumBase {
|
class PirepState extends EnumBase {
|
||||||
|
|
||||||
const REJECTED = -1;
|
const REJECTED = -1;
|
||||||
const PENDING = 0;
|
const PENDING = 0;
|
||||||
const ACCEPTED = 1;
|
const ACCEPTED = 1;
|
||||||
|
|
||||||
protected static $labels = [
|
protected static $labels = [
|
||||||
PirepState::REJECTED => 'Rejected',
|
PirepState::REJECTED => 'system.pireps.state.rejected',
|
||||||
PirepState::PENDING => 'Pending',
|
PirepState::PENDING => 'system.pireps.state.pending',
|
||||||
PirepState::ACCEPTED => 'Accepted',
|
PirepState::ACCEPTED => 'system.pireps.state.accepted',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -119,6 +119,7 @@ return [
|
|||||||
|
|
||||||
|
|
||||||
# ENUMS
|
# ENUMS
|
||||||
|
'PirepSource' => App\Models\Enums\PirepSource::class,
|
||||||
'PirepState' => App\Models\Enums\PirepState::class,
|
'PirepState' => App\Models\Enums\PirepState::class,
|
||||||
'PirepStatus' => App\Models\Enums\PirepStatus::class,
|
'PirepStatus' => App\Models\Enums\PirepStatus::class,
|
||||||
],
|
],
|
||||||
|
21
resources/lang/en/system.php
Normal file
21
resources/lang/en/system.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'days' => [
|
||||||
|
'mon' => 'Monday',
|
||||||
|
'tues' => 'Tuesday',
|
||||||
|
'wed' => 'Wednesday',
|
||||||
|
'thurs' => 'Thursday',
|
||||||
|
'fri' => 'Friday',
|
||||||
|
'sat' => 'Saturday',
|
||||||
|
'sun' => 'Sunday',
|
||||||
|
],
|
||||||
|
|
||||||
|
'pireps' => [
|
||||||
|
'state' => [
|
||||||
|
'accepted' => 'Accepted',
|
||||||
|
'pending' => 'Pending',
|
||||||
|
'rejected' => 'Rejected',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
@ -14,13 +14,17 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>Status</td>
|
<td>Status</td>
|
||||||
<td>
|
<td>
|
||||||
@if($pirep->state == PirepState::PENDING)
|
@if($pirep->state === PirepState::PENDING)
|
||||||
<div class="badge badge-warning ">Pending</div>
|
<div class="badge badge-warning ">{!! PirepState::label(PirepState::PENDING) !!}</div>
|
||||||
@elseif($pirep->state === PirepState::ACCEPTED)
|
@elseif($pirep->state === PirepState::ACCEPTED)
|
||||||
<div class="badge badge-success">Accepted</div>
|
<div class="badge badge-success">{!! PirepState::label(PirepState::ACCEPTED) !!}</div>
|
||||||
@else
|
@else
|
||||||
<div class="badge badge-danger">Rejected</div>
|
<div class="badge badge-danger">{!! PirepState::label(PirepState::REJECTED) !!}</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
<span class="description" style="padding-left: 20px;">
|
||||||
|
source: {!! PirepSource::label($pirep->source) !!}
|
||||||
|
</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
Loading…
Reference in New Issue
Block a user