diff --git a/resources/lang/de/cachet.php b/resources/lang/de/cachet.php index 91081fda..1a45935e 100644 --- a/resources/lang/de/cachet.php +++ b/resources/lang/de/cachet.php @@ -18,4 +18,5 @@ 'open_source_status_page' => 'Die Open-Source-Statusseite.', 'all_times_shown_in' => 'Alle Zeiten werden angezeigt in *:timezone*.', 'rss_feed' => ':name RSS-Feed', + 'and' => 'und', ]; diff --git a/resources/lang/de/metric.php b/resources/lang/de/metric.php index 5474e415..1897ac7e 100644 --- a/resources/lang/de/metric.php +++ b/resources/lang/de/metric.php @@ -26,6 +26,7 @@ 'form' => [ 'name_label' => 'Name', 'suffix_label' => 'Suffix', + 'suffix_placeholder' => 'z. B. ms, %, usw.', 'description_label' => 'Beschreibung', 'default_view_label' => 'Standardansicht', 'default_value_label' => 'Standardwert', diff --git a/resources/lang/de/update.php b/resources/lang/de/update.php new file mode 100644 index 00000000..ed2ddace --- /dev/null +++ b/resources/lang/de/update.php @@ -0,0 +1,20 @@ + 'Update|Updates', + 'list' => [ + 'headers' => [ + 'message' => 'Nachricht', + 'status' => 'Status', + 'user' => 'Benutzer', + 'created_at' => 'Erstellt am', + 'updated_at' => 'Aktualisiert am', + ], + ], + 'form' => [ + 'message_label' => 'Nachricht', + 'user_label' => 'Benutzer', + 'user_helper' => 'Benutzer, welcher den Vorfall gemeldet hat.', + 'status_label' => 'Status', + ], +]; diff --git a/resources/lang/de_AT/cachet.php b/resources/lang/de_AT/cachet.php index 91081fda..1a45935e 100644 --- a/resources/lang/de_AT/cachet.php +++ b/resources/lang/de_AT/cachet.php @@ -18,4 +18,5 @@ 'open_source_status_page' => 'Die Open-Source-Statusseite.', 'all_times_shown_in' => 'Alle Zeiten werden angezeigt in *:timezone*.', 'rss_feed' => ':name RSS-Feed', + 'and' => 'und', ]; diff --git a/resources/lang/de_AT/metric.php b/resources/lang/de_AT/metric.php index 5474e415..1897ac7e 100644 --- a/resources/lang/de_AT/metric.php +++ b/resources/lang/de_AT/metric.php @@ -26,6 +26,7 @@ 'form' => [ 'name_label' => 'Name', 'suffix_label' => 'Suffix', + 'suffix_placeholder' => 'z. B. ms, %, usw.', 'description_label' => 'Beschreibung', 'default_view_label' => 'Standardansicht', 'default_value_label' => 'Standardwert', diff --git a/resources/lang/de_AT/update.php b/resources/lang/de_AT/update.php new file mode 100644 index 00000000..ed2ddace --- /dev/null +++ b/resources/lang/de_AT/update.php @@ -0,0 +1,20 @@ + 'Update|Updates', + 'list' => [ + 'headers' => [ + 'message' => 'Nachricht', + 'status' => 'Status', + 'user' => 'Benutzer', + 'created_at' => 'Erstellt am', + 'updated_at' => 'Aktualisiert am', + ], + ], + 'form' => [ + 'message_label' => 'Nachricht', + 'user_label' => 'Benutzer', + 'user_helper' => 'Benutzer, welcher den Vorfall gemeldet hat.', + 'status_label' => 'Status', + ], +]; diff --git a/resources/lang/de_CH/cachet.php b/resources/lang/de_CH/cachet.php index 91081fda..1a45935e 100644 --- a/resources/lang/de_CH/cachet.php +++ b/resources/lang/de_CH/cachet.php @@ -18,4 +18,5 @@ 'open_source_status_page' => 'Die Open-Source-Statusseite.', 'all_times_shown_in' => 'Alle Zeiten werden angezeigt in *:timezone*.', 'rss_feed' => ':name RSS-Feed', + 'and' => 'und', ]; diff --git a/resources/lang/de_CH/metric.php b/resources/lang/de_CH/metric.php index 5474e415..1897ac7e 100644 --- a/resources/lang/de_CH/metric.php +++ b/resources/lang/de_CH/metric.php @@ -26,6 +26,7 @@ 'form' => [ 'name_label' => 'Name', 'suffix_label' => 'Suffix', + 'suffix_placeholder' => 'z. B. ms, %, usw.', 'description_label' => 'Beschreibung', 'default_view_label' => 'Standardansicht', 'default_value_label' => 'Standardwert', diff --git a/resources/lang/de_CH/update.php b/resources/lang/de_CH/update.php new file mode 100644 index 00000000..ed2ddace --- /dev/null +++ b/resources/lang/de_CH/update.php @@ -0,0 +1,20 @@ + 'Update|Updates', + 'list' => [ + 'headers' => [ + 'message' => 'Nachricht', + 'status' => 'Status', + 'user' => 'Benutzer', + 'created_at' => 'Erstellt am', + 'updated_at' => 'Aktualisiert am', + ], + ], + 'form' => [ + 'message_label' => 'Nachricht', + 'user_label' => 'Benutzer', + 'user_helper' => 'Benutzer, welcher den Vorfall gemeldet hat.', + 'status_label' => 'Status', + ], +]; diff --git a/resources/lang/en/cachet.php b/resources/lang/en/cachet.php index 50555621..30f3f8fe 100644 --- a/resources/lang/en/cachet.php +++ b/resources/lang/en/cachet.php @@ -18,4 +18,5 @@ 'open_source_status_page' => 'The open source status page.', 'all_times_shown_in' => 'All times are shown in *:timezone*.', 'rss_feed' => ':name RSS feed', + 'and' => 'and', ]; diff --git a/resources/lang/en/metric.php b/resources/lang/en/metric.php index 14851444..7f2ec89b 100644 --- a/resources/lang/en/metric.php +++ b/resources/lang/en/metric.php @@ -26,6 +26,7 @@ 'form' => [ 'name_label' => 'Name', 'suffix_label' => 'Suffix', + 'suffix_placeholder' => 'e.g. ms, %, etc.', 'description_label' => 'Description', 'default_view_label' => 'Default view', 'default_value_label' => 'Default value', diff --git a/resources/lang/en/update.php b/resources/lang/en/update.php new file mode 100644 index 00000000..3465a24a --- /dev/null +++ b/resources/lang/en/update.php @@ -0,0 +1,20 @@ + 'Update|Updates', + 'list' => [ + 'headers' => [ + 'message' => 'Message', + 'status' => 'Status', + 'user' => 'User', + 'created_at' => 'Created at', + 'updated_at' => 'Updated at', + ], + ], + 'form' => [ + 'message_label' => 'Message', + 'user_label' => 'User', + 'user_helper' => 'The user who reported the incident.', + 'status_label' => 'Status', + ], +]; diff --git a/resources/views/components/incident.blade.php b/resources/views/components/incident.blade.php index ab8183e1..0445e21a 100644 --- a/resources/views/components/incident.blade.php +++ b/resources/views/components/incident.blade.php @@ -52,7 +52,7 @@ class="text-zinc-400 transition hover:text-zinc-700 dark:text-zinc-500 dark:hove @if ($incident->components->isNotEmpty())
- {{ __('Affected Components') }}: {{ $incident->components->pluck('name')->join(', ', ' and ') }} + {{ __('cachet::incident.affected_components_header') }}: {{ $incident->components->pluck('name')->join(', ', ' '.__('cachet::cachet.and').' ') }}
@endif @@ -82,9 +82,9 @@ class="text-zinc-400 transition hover:text-zinc-700 dark:text-zinc-500 dark:hove @php($reportStatus = $incident->updates->isEmpty() ? $incident->status : null) @if ($headingLevel === 1) -

{{ $reportStatus?->getLabel() ?? __('Reported') }}

+

{{ $reportStatus?->getLabel() ?? __('cachet::incident.status.reported') }}

@else -

{{ $reportStatus?->getLabel() ?? __('Reported') }}

+

{{ $reportStatus?->getLabel() ?? __('cachet::incident.status.reported') }}

@endif @@ -122,7 +122,7 @@ class="group relative rounded-lg bg-white shadow-sm ring-1 ring-zinc-900/10 dark @if ($schedule->components->isNotEmpty())
- {{ __('Affected Components') }}: {{ $schedule->components->pluck('name')->join(', ', ' and ') }} + {{ __('cachet::incident.affected_components_header') }}: {{ $schedule->components->pluck('name')->join(', ', ' '.__('cachet::cachet.and').' ') }}
@endif diff --git a/resources/views/components/schedule.blade.php b/resources/views/components/schedule.blade.php index 15a72c36..36adf684 100644 --- a/resources/views/components/schedule.blade.php +++ b/resources/views/components/schedule.blade.php @@ -33,7 +33,7 @@ @if ($schedule->components->isNotEmpty())
- {{ __('Affected Components') }}: {{ $schedule->components->pluck('name')->join(', ', ' and ') }} + {{ __('cachet::incident.affected_components_header') }}: {{ $schedule->components->pluck('name')->join(', ', ' '.__('cachet::cachet.and').' ') }}
@endif diff --git a/src/Filament/Resources/Components/RelationManagers/ComponentsRelationManager.php b/src/Filament/Resources/Components/RelationManagers/ComponentsRelationManager.php index 6288dc57..9631b428 100644 --- a/src/Filament/Resources/Components/RelationManagers/ComponentsRelationManager.php +++ b/src/Filament/Resources/Components/RelationManagers/ComponentsRelationManager.php @@ -29,7 +29,7 @@ class ComponentsRelationManager extends RelationManager public static function getTitle(Model $ownerRecord, string $pageClass): string { - return __('Components'); + return trans_choice('cachet::component.resource_label', 2); } public function form(Schema $schema): Schema diff --git a/src/Filament/Resources/Incidents/IncidentResource.php b/src/Filament/Resources/Incidents/IncidentResource.php index 0f07716a..7c8aa094 100644 --- a/src/Filament/Resources/Incidents/IncidentResource.php +++ b/src/Filament/Resources/Incidents/IncidentResource.php @@ -124,7 +124,7 @@ public static function form(Schema $schema): Schema ->default(ResourceVisibilityEnum::guest) ->required(), Select::make('user_id') - ->label(__('User')) + ->label(__('cachet::incident.form.user_label')) ->helperText(__('cachet::incident.form.user_helper')) ->relationship('user', 'name') ->default(auth()->id()) diff --git a/src/Filament/Resources/Metrics/MetricResource.php b/src/Filament/Resources/Metrics/MetricResource.php index 2aefb69b..b816bd1b 100644 --- a/src/Filament/Resources/Metrics/MetricResource.php +++ b/src/Filament/Resources/Metrics/MetricResource.php @@ -46,7 +46,7 @@ public static function form(Schema $schema): Schema ->label(__('cachet::metric.form.suffix_label')) ->required() ->maxLength(255) - ->placeholder('e.g. ms, %, etc.'), + ->placeholder(__('cachet::metric.form.suffix_placeholder')), MarkdownEditor::make('description') ->label(__('cachet::metric.form.description_label')) ->maxLength(255) diff --git a/src/Filament/Resources/Updates/RelationManagers/UpdatesRelationManager.php b/src/Filament/Resources/Updates/RelationManagers/UpdatesRelationManager.php index 70ea8154..631f13e1 100644 --- a/src/Filament/Resources/Updates/RelationManagers/UpdatesRelationManager.php +++ b/src/Filament/Resources/Updates/RelationManagers/UpdatesRelationManager.php @@ -27,36 +27,36 @@ public function form(Schema $schema): Schema return $schema ->components([ MarkdownEditor::make('message') - ->label(__('Message')) + ->label(__('cachet::update.form.message_label')) ->required() ->minHeight('200px') ->maxHeight('300px') ->columnSpanFull(), Select::make('user_id') - ->label(__('User')) - ->hint(__('The user who reported the incident.')) + ->label(__('cachet::update.form.user_label')) + ->hint(__('cachet::update.form.user_helper')) ->relationship('user', 'name') ->searchable() ->preload() ->createOptionForm([ TextInput::make('name') - ->label(__('Name')) + ->label(__('cachet::user.form.name_label')) ->required() ->maxLength(255), TextInput::make('email') - ->label(__('Email')) + ->label(__('cachet::user.form.email_label')) ->required() ->email() ->maxLength(255), TextInput::make('password') - ->label(__('Password')) + ->label(__('cachet::user.form.password_label')) ->required() ->password() ->confirmed() ->minLength(8), ]), ToggleButtons::make('status') - ->label(__('Status')) + ->label(__('cachet::update.form.status_label')) ->inline() ->columnSpanFull() ->options(IncidentStatusEnum::class) @@ -69,28 +69,28 @@ public function table(Table $table): Table { return $table ->recordTitleAttribute('message') - ->modelLabel(__('Update')) - ->pluralModelLabel(__('Updates')) + ->modelLabel(trans_choice('cachet::update.resource_label', 1)) + ->pluralModelLabel(trans_choice('cachet::update.resource_label', 2)) ->columns([ TextColumn::make('message') - ->label(__('Message')) + ->label(__('cachet::update.list.headers.message')) ->searchable() ->limit(80) ->wrap(), TextColumn::make('status') - ->label(__('Status')) + ->label(__('cachet::update.list.headers.status')) ->badge() ->sortable() ->visible(fn (): bool => $this->getOwnerRecord() instanceof Incident), TextColumn::make('user.name') - ->label(__('User')) + ->label(__('cachet::update.list.headers.user')) ->sortable(), TextColumn::make('created_at') - ->label(__('Created at')) + ->label(__('cachet::update.list.headers.created_at')) ->dateTime() ->sortable(), TextColumn::make('updated_at') - ->label(__('Updated at')) + ->label(__('cachet::update.list.headers.updated_at')) ->dateTime() ->sortable() ->toggleable(isToggledHiddenByDefault: true), @@ -98,7 +98,7 @@ public function table(Table $table): Table ->defaultSort('created_at', 'desc') ->filters([ SelectFilter::make('status') - ->label(__('Status')) + ->label(__('cachet::update.list.headers.status')) ->options(IncidentStatusEnum::class) ->visible(fn (): bool => $this->getOwnerRecord() instanceof Incident), ]) diff --git a/tests/Feature/Filament/Resources/IncidentResourceTest.php b/tests/Feature/Filament/Resources/IncidentResourceTest.php index 5cc2b2f1..f35c2905 100644 --- a/tests/Feature/Filament/Resources/IncidentResourceTest.php +++ b/tests/Feature/Filament/Resources/IncidentResourceTest.php @@ -6,6 +6,7 @@ use Cachet\Enums\IncidentStatusEnum; use Cachet\Enums\ResourceVisibilityEnum; use Cachet\Filament\Components\ComponentOptions; +use Cachet\Filament\Resources\Components\RelationManagers\ComponentsRelationManager; use Cachet\Filament\Resources\Incidents\IncidentResource; use Cachet\Filament\Resources\Incidents\Pages\CreateIncident; use Cachet\Filament\Resources\Incidents\Pages\EditIncident; @@ -18,6 +19,7 @@ use Cachet\Notifications\NewIncidentNotification; use Cachet\Settings\MailSettings; use Filament\Facades\Filament; +use Filament\Tables\Columns\TextColumn; use Illuminate\Support\Facades\Notification; use Workbench\App\User; @@ -185,6 +187,20 @@ ->assertTableColumnStateSet('message', $update->message, $update); }); +it('translates the update and component relation managers', function () { + app()->setLocale('de'); + $incident = Incident::factory()->create(); + + livewire(UpdatesRelationManager::class, [ + 'ownerRecord' => $incident, + 'pageClass' => EditIncident::class, + ]) + ->assertTableColumnExists('message', fn (TextColumn $column): bool => $column->getLabel() === 'Nachricht') + ->assertTableColumnExists('created_at', fn (TextColumn $column): bool => $column->getLabel() === 'Erstellt am'); + + expect(ComponentsRelationManager::getTitle($incident, EditIncident::class))->toBe('Komponenten'); +}); + it('excludes already attached components from the attach action options', function () { $incident = Incident::factory()->create(); $attached = Component::factory()->create(['name' => 'Already Attached']); diff --git a/tests/Feature/StatusPage/SchedulePageTest.php b/tests/Feature/StatusPage/SchedulePageTest.php index cb276a2c..ea7139cf 100644 --- a/tests/Feature/StatusPage/SchedulePageTest.php +++ b/tests/Feature/StatusPage/SchedulePageTest.php @@ -2,9 +2,12 @@ namespace Tests\Feature\StatusPage; +use Cachet\Enums\ComponentStatusEnum; use Cachet\Enums\IncidentStatusEnum; +use Cachet\Models\Component; use Cachet\Models\Schedule; use Cachet\Models\Update; +use Cachet\Settings\AppSettings; use function Pest\Laravel\get; @@ -27,6 +30,24 @@ ->assertSee('Maintenance window confirmed.'); }); +it('translates the affected components label', function () { + $settings = app(AppSettings::class); + $settings->locale = 'de'; + $settings->save(); + + $database = Component::factory()->create(['name' => 'Database']); + $website = Component::factory()->create(['name' => 'Website']); + $schedule = Schedule::factory()->create(['scheduled_at' => now()->addDay()]); + $schedule->components()->attach([$database->id, $website->id], [ + 'component_status' => ComponentStatusEnum::under_maintenance, + ]); + + get(route('cachet.status-page.schedule', ['schedule' => $schedule])) + ->assertOk() + ->assertSee('Betroffene Komponenten: Database und Website') + ->assertDontSee('Affected Components'); +}); + it('links to schedules from the status page', function () { $schedule = Schedule::factory()->create(['scheduled_at' => now()->addDay()]); diff --git a/tests/Feature/StatusPage/StatusPageTest.php b/tests/Feature/StatusPage/StatusPageTest.php index 12df8be7..0e5d03d3 100644 --- a/tests/Feature/StatusPage/StatusPageTest.php +++ b/tests/Feature/StatusPage/StatusPageTest.php @@ -544,6 +544,41 @@ function systemStatusGroupPattern(ComponentGroup $group, bool $open): string expect(app()->getLocale())->toBe('de'); }); +it('translates the affected components label of incidents', function () { + $settings = app(AppSettings::class); + $settings->locale = 'de'; + $settings->save(); + + $api = Component::factory()->create(['name' => 'API']); + $website = Component::factory()->create(['name' => 'Website']); + $incident = Incident::factory()->create(['status' => IncidentStatusEnum::investigating]); + $incident->components()->attach([$api->id, $website->id], [ + 'component_status' => ComponentStatusEnum::major_outage, + ]); + + $this->get(route('cachet.status-page')) + ->assertOk() + ->assertSee('Betroffene Komponenten: API und Website') + ->assertDontSee('Affected Components'); +}); + +it('translates the reported label of incidents with updates', function () { + $settings = app(AppSettings::class); + $settings->locale = 'de'; + $settings->save(); + + $incident = Incident::factory()->create(['status' => IncidentStatusEnum::investigating]); + $incident->updates()->create([ + 'message' => 'We have identified the issue.', + 'status' => IncidentStatusEnum::identified, + ]); + + $this->get(route('cachet.status-page')) + ->assertOk() + ->assertSee('Gemeldet') + ->assertDontSee('Reported'); +}); + it('does not error when the from query parameter is malformed', function () { $this->get(route('cachet.status-page', ['from' => '2024-04-15/'])) ->assertOk();