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;
|
||||
|
||||
protected static $labels = [
|
||||
Days::MONDAY => 'Monday',
|
||||
Days::TUESDAY => 'Tuesday',
|
||||
Days::WEDNESDAY => 'Wednesday',
|
||||
Days::THURSDAY => 'Thursday',
|
||||
Days::FRIDAY => 'Friday',
|
||||
Days::SATURDAY => 'Saturday',
|
||||
Days::SUNDAY => 'Sunday',
|
||||
Days::MONDAY => 'system.days.mon',
|
||||
Days::TUESDAY => 'system.days.tues',
|
||||
Days::WEDNESDAY => 'system.days.wed',
|
||||
Days::THURSDAY => 'system.days.thurs',
|
||||
Days::FRIDAY => 'system.days.fri',
|
||||
Days::SATURDAY => 'system.days.sat',
|
||||
Days::SUNDAY => 'system.days.sun',
|
||||
];
|
||||
}
|
||||
|
@ -17,12 +17,16 @@ namespace App\Models\Enums;
|
||||
class EnumBase
|
||||
{
|
||||
protected static $labels = [];
|
||||
protected static $adverbs = [];
|
||||
|
||||
/**
|
||||
* Return the label, try to return the translated version as well
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
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;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
class PirepState extends EnumBase {
|
||||
|
||||
const REJECTED = -1;
|
||||
const PENDING = 0;
|
||||
const ACCEPTED = 1;
|
||||
|
||||
protected static $labels = [
|
||||
PirepState::REJECTED => 'Rejected',
|
||||
PirepState::PENDING => 'Pending',
|
||||
PirepState::ACCEPTED => 'Accepted',
|
||||
PirepState::REJECTED => 'system.pireps.state.rejected',
|
||||
PirepState::PENDING => 'system.pireps.state.pending',
|
||||
PirepState::ACCEPTED => 'system.pireps.state.accepted',
|
||||
];
|
||||
}
|
||||
|
@ -119,6 +119,7 @@ return [
|
||||
|
||||
|
||||
# ENUMS
|
||||
'PirepSource' => App\Models\Enums\PirepSource::class,
|
||||
'PirepState' => App\Models\Enums\PirepState::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>
|
||||
<td>Status</td>
|
||||
<td>
|
||||
@if($pirep->state == PirepState::PENDING)
|
||||
<div class="badge badge-warning ">Pending</div>
|
||||
@if($pirep->state === PirepState::PENDING)
|
||||
<div class="badge badge-warning ">{!! PirepState::label(PirepState::PENDING) !!}</div>
|
||||
@elseif($pirep->state === PirepState::ACCEPTED)
|
||||
<div class="badge badge-success">Accepted</div>
|
||||
<div class="badge badge-success">{!! PirepState::label(PirepState::ACCEPTED) !!}</div>
|
||||
@else
|
||||
<div class="badge badge-danger">Rejected</div>
|
||||
<div class="badge badge-danger">{!! PirepState::label(PirepState::REJECTED) !!}</div>
|
||||
@endif
|
||||
|
||||
<span class="description" style="padding-left: 20px;">
|
||||
source: {!! PirepSource::label($pirep->source) !!}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
Loading…
Reference in New Issue
Block a user