Skip to content

Commit 9eafce6

Browse files
committed
translations
1 parent 1ad990d commit 9eafce6

File tree

11 files changed

+162
-65
lines changed

11 files changed

+162
-65
lines changed

packages/prompts/resources/lang/de/prompts.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,38 @@
33
return [
44
'prompt' => 'Prompt',
55
'prompts' => 'Prompts',
6+
7+
'ui' => [
8+
'error_heading' => 'Fehler',
9+
'success_heading' => 'Command erfolgreich abgeschlossen!',
10+
'starting_heading' => 'Command wird gestartet...',
11+
'validation_title' => 'Bitte korrigieren:',
12+
'next_button' => 'Weiter',
13+
'output_heading' => 'Command Ausgabe',
14+
'confirm_yes' => 'Ja',
15+
'confirm_no' => 'Nein',
16+
'no_commands_available' => 'Keine Commands verfügbar. Bitte konfiguriere die erlaubten Commands in der',
17+
'command_label' => 'Command',
18+
'select_command_placeholder' => 'Bitte Command auswählen …',
19+
'commands_config_hint' => 'Nur Commands aus der Konfiguration sind hier sichtbar.',
20+
'start_command_button' => 'Command starten',
21+
'back_to_selection' => 'Zurück zur Command-Auswahl',
22+
'unknown_error' => 'Unbekannter Fehler',
23+
'navigation_label' => 'Command Runner',
24+
'navigation_group' => 'System',
25+
],
26+
27+
'errors' => [
28+
'command_not_found' => 'Command nicht gefunden: :command',
29+
'step_not_found' => 'Step :step nicht gefunden auf Command :class',
30+
],
31+
32+
'validation' => [
33+
'text_required' => 'Bitte „:label“ ausfüllen.',
34+
'multiselect_required' => 'Bitte mindestens eine Option wählen.',
35+
'multiselect_min' => 'Bitte mindestens eine Option wählen.',
36+
'select_required' => 'Bitte wählen Sie eine Option aus.',
37+
'select_in' => 'Bitte wählen Sie eine gültige Option aus.',
38+
'callable_invalid' => 'Ungültiger Wert.',
39+
],
640
];

packages/prompts/resources/lang/en/prompts.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,38 @@
33
return [
44
'prompt' => 'Prompt',
55
'prompts' => 'Prompts',
6+
7+
'ui' => [
8+
'error_heading' => 'Error',
9+
'success_heading' => 'Command finished successfully!',
10+
'starting_heading' => 'Starting command...',
11+
'validation_title' => 'Please fix the following:',
12+
'next_button' => 'Next',
13+
'output_heading' => 'Command output',
14+
'confirm_yes' => 'Yes',
15+
'confirm_no' => 'No',
16+
'no_commands_available' => 'No commands available. Please configure allowed commands in',
17+
'command_label' => 'Command',
18+
'select_command_placeholder' => 'Please select a command …',
19+
'commands_config_hint' => 'Only commands from the configuration are visible here.',
20+
'start_command_button' => 'Start command',
21+
'back_to_selection' => 'Back to command selection',
22+
'unknown_error' => 'Unknown error',
23+
'navigation_label' => 'Command Runner',
24+
'navigation_group' => 'System',
25+
],
26+
27+
'errors' => [
28+
'command_not_found' => 'Command not found: :command',
29+
'step_not_found' => 'Step :step not found on command :class',
30+
],
31+
32+
'validation' => [
33+
'text_required' => 'Please fill in “:label”.',
34+
'multiselect_required' => 'Please select at least one option.',
35+
'multiselect_min' => 'Please select at least one option.',
36+
'select_required' => 'Please choose an option.',
37+
'select_in' => 'Please choose a valid option.',
38+
'callable_invalid' => 'Invalid value.',
39+
],
640
];

packages/prompts/resources/views/filament/components/run-command.blade.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
@if($error)
33
<x-filament::section>
44
<x-slot name="heading">
5-
Fehler
5+
{{ __('moox-prompts::prompts.ui.error_heading') }}
66
</x-slot>
77
<p style="color: #b91c1c;">{{ $error }}</p>
88
@if($output)
@@ -16,7 +16,7 @@
1616
@elseif($isComplete)
1717
<x-filament::section>
1818
<x-slot name="heading">
19-
Command erfolgreich abgeschlossen!
19+
{{ __('moox-prompts::prompts.ui.success_heading') }}
2020
</x-slot>
2121
@if($output)
2222
<pre
@@ -36,7 +36,9 @@
3636
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z">
3737
</path>
3838
</svg>
39-
<strong style="color: #92400e; font-size: 0.875rem; font-weight: 600;">Validierungsfehler:</strong>
39+
<strong style="color: #92400e; font-size: 0.875rem; font-weight: 600;">
40+
{{ __('moox-prompts::prompts.ui.validation_title') }}
41+
</strong>
4042
</div>
4143
<ul style="color: #92400e; margin: 0; padding-left: 1.25rem; list-style: disc; font-size: 0.875rem;">
4244
@foreach($validationErrors as $msg)
@@ -48,14 +50,14 @@
4850

4951
<div style="margin-top: 1rem; display: flex; justify-content: flex-end;">
5052
<x-filament::button wire:click="submitPrompt" type="button" color="primary">
51-
Weiter
53+
{{ __('moox-prompts::prompts.ui.next_button') }}
5254
</x-filament::button>
5355
</div>
5456

5557
@if($currentStepOutput)
5658
<x-filament::section style="margin-top: 1rem;">
5759
<x-slot name="heading">
58-
Command Output
60+
{{ __('moox-prompts::prompts.ui.output_heading') }}
5961
</x-slot>
6062
<pre
6163
style="background-color: #111827; color: #4ade80; padding: 1rem; border-radius: 0.25rem; overflow: auto; font-size: 0.875rem; max-height: 400px;">{{ $currentStepOutput }}</pre>
@@ -64,7 +66,7 @@
6466
@else
6567
<x-filament::section>
6668
<x-slot name="heading">
67-
Command wird gestartet...
69+
{{ __('moox-prompts::prompts.ui.starting_heading') }}
6870
</x-slot>
6971
<x-filament::loading-indicator />
7072
</x-filament::section>

packages/prompts/resources/views/filament/pages/run-command.blade.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<x-filament::section>
55
@if (empty($availableCommands))
66
<p style="font-size: 0.875rem; color: #6b7280;">
7-
Keine Commands verfügbar. Bitte konfiguriere die erlaubten Commands in der
7+
{{ __('moox-prompts::prompts.ui.no_commands_available') }}
88
<code style="padding: 0.125rem 0.25rem; background-color: #f3f4f6; border-radius: 0.25rem; font-size: 0.75rem;">
99
config/prompts.php
1010
</code>.
@@ -13,12 +13,12 @@
1313
<form wire:submit="startCommand" style="display: flex; flex-direction: column; gap: 1.25rem; margin-top: 0.5rem;">
1414
<div style="display: flex; flex-direction: column; gap: 0.25rem; max-width: 480px;">
1515
<label style="font-size: 0.875rem;">
16-
Command
16+
{{ __('moox-prompts::prompts.ui.command_label') }}
1717
</label>
1818

1919
<x-filament::input.wrapper>
2020
<x-filament::input.select wire:model="selectedCommand" required>
21-
<option value="">Bitte Command auswählen …</option>
21+
<option value="">{{ __('moox-prompts::prompts.ui.select_command_placeholder') }}</option>
2222
@foreach ($availableCommands as $commandName => $description)
2323
<option value="{{ $commandName }}">
2424
{{ $commandName }}{{ $description }}
@@ -30,11 +30,11 @@
3030

3131
<div style="display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; max-width: 640px;">
3232
<p style="font-size: 0.875rem; color: #6b7280; margin: 0;">
33-
Nur Commands aus der Konfiguration sind hier sichtbar.
33+
{{ __('moox-prompts::prompts.ui.commands_config_hint') }}
3434
</p>
3535

3636
<x-filament::button type="submit" color="primary">
37-
Command starten
37+
{{ __('moox-prompts::prompts.ui.start_command_button') }}
3838
</x-filament::button>
3939
</div>
4040
</form>
@@ -52,7 +52,7 @@
5252

5353
<div style="margin-top: 1rem;">
5454
<x-filament::button wire:click="resetCommand" color="gray">
55-
Zurück zur Command-Auswahl
55+
{{ __('moox-prompts::prompts.ui.back_to_selection') }}
5656
</x-filament::button>
5757
</div>
5858
</div>

packages/prompts/src/Filament/Components/RunCommandComponent.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ protected function runCommand(): void
8989
$this->isComplete = false;
9090

9191
try {
92-
// erzwinge Web-Runtime (nicht CLI) im Web-Kontext
92+
// Force web runtime (not CLI) in web context
9393
app()->instance(PromptRuntime::class, new WebPromptRuntime);
9494
WebCommandRunner::ensurePublishableResourcesRegistered();
9595

@@ -98,7 +98,7 @@ protected function runCommand(): void
9898

9999
$state = $this->flowId ? $stateStore->get($this->flowId) : null;
100100
if (! $state) {
101-
// frischer Flow: ResponseStore und lokale States leeren
101+
// Fresh flow: clear ResponseStore and local states
102102
$this->responseStore->clear();
103103
$this->responseStore->resetCounter();
104104
$this->answers = [];
@@ -112,7 +112,7 @@ protected function runCommand(): void
112112
$this->flowId = $state->flowId;
113113
}
114114

115-
// Antworten in den ResponseStore spiegeln (ohne den Zähler zu manipulieren)
115+
// Mirror answers into ResponseStore (without manipulating the counter)
116116
foreach ($this->answers as $promptId => $answer) {
117117
$this->responseStore->set($promptId, $answer);
118118
}
@@ -135,7 +135,7 @@ protected function runCommand(): void
135135

136136
if (! empty($result['failed'])) {
137137
$this->currentStepOutput = $this->output;
138-
$this->error = $result['error'] ?? 'Unbekannter Fehler';
138+
$this->error = $result['error'] ?? __('moox-prompts::prompts.ui.unknown_error');
139139
$this->currentPrompt = null;
140140

141141
return;
@@ -186,7 +186,7 @@ protected function prefillPromptForm(array $prompt): void
186186
$params = $prompt['params'] ?? [];
187187
$p = PromptParamsHelper::extract($method, $params);
188188

189-
// Wenn bereits eine Antwort vorhanden ist, diese verwenden
189+
// If an answer already exists, use it
190190
if (isset($this->answers[$promptId])) {
191191
$value = $this->answers[$promptId];
192192
if ($method === 'multiselect') {
@@ -204,18 +204,18 @@ protected function prefillPromptForm(array $prompt): void
204204
return;
205205
}
206206

207-
// Ansonsten Default-Wert aus den Prompt-Params verwenden
207+
// Otherwise use default value from prompt params
208208
if ($method === 'confirm') {
209-
$default = $p['default'] ?? false; // default Parameter (bool)
209+
$default = $p['default'] ?? false; // default parameter (bool)
210210
$value = $default ? 'yes' : 'no';
211211
$this->form->fill([$promptId => $value]);
212212

213213
return;
214214
}
215215

216216
if ($method === 'multiselect') {
217-
$defaultValue = $p['default'] ?? []; // default Parameter (array)
218-
// Für multiselect müssen wir die einzelnen Checkboxen füllen
217+
$defaultValue = $p['default'] ?? []; // default parameter (array)
218+
// For multiselect we need to fill the individual checkboxes
219219
$options = $p['options'] ?? [];
220220
$fillData = [];
221221
foreach (array_keys($options) as $key) {
@@ -231,9 +231,9 @@ protected function prefillPromptForm(array $prompt): void
231231

232232
$defaultValue = null;
233233
if ($method === 'select') {
234-
$defaultValue = $p['default'] ?? null; // default Parameter
234+
$defaultValue = $p['default'] ?? null; // default parameter
235235
} elseif (in_array($method, ['text', 'textarea', 'password'])) {
236-
$defaultValue = $p['default'] ?? ''; // default Parameter
236+
$defaultValue = $p['default'] ?? ''; // default parameter
237237
}
238238

239239
if ($defaultValue !== null) {
@@ -577,7 +577,7 @@ protected function createMultiselectFields(string $promptId, array $params): arr
577577

578578
$label = $p['label'] ?? '';
579579
$required = ($p['required'] ?? false) !== false;
580-
// Default-Wert: erst aus answers, dann aus default-Parameter
580+
// Default value: first from answers, then from default parameter
581581
$defaultValue = $this->answers[$promptId] ?? ($p['default'] ?? []);
582582
$options = $p['options'] ?? [];
583583

@@ -616,7 +616,7 @@ protected function createFieldFromPrompt(string $promptId, string $method, array
616616
$options = $p['options'] ?? [];
617617
$defaultSelect = $defaultValue ?? ($p['default'] ?? null);
618618

619-
// Für confirm: Default aus params[1] (default Parameter), falls noch keine Antwort vorhanden
619+
// For confirm: default from params[1] (default parameter), if no answer exists yet
620620
$confirmDefault = null;
621621
if ($method === 'confirm') {
622622
$confirmDefault = $defaultValue !== null ? $defaultValue : ($p['default'] ?? false);
@@ -693,8 +693,8 @@ protected function createFieldFromPrompt(string $promptId, string $method, array
693693
'confirm' => Radio::make($promptId)
694694
->label($label)
695695
->options([
696-
'yes' => 'Ja',
697-
'no' => 'Nein',
696+
'yes' => __('moox-prompts::prompts.ui.confirm_yes'),
697+
'no' => __('moox-prompts::prompts.ui.confirm_no'),
698698
])
699699
->default($confirmDefault !== null ? ($confirmDefault ? 'yes' : 'no') : null)
700700
->rules($rules)

packages/prompts/src/Filament/Pages/RunCommandPage.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,26 @@ class RunCommandPage extends Page
1010

1111
protected string $view = 'moox-prompts::filament.pages.run-command';
1212

13-
protected static ?string $navigationLabel = 'Command Runner';
13+
protected static ?string $navigationLabel = null;
1414

15-
protected static ?string $title = 'Command Runner';
15+
protected static ?string $title = null;
1616

17-
protected static string|\UnitEnum|null $navigationGroup = 'System';
17+
protected static string|\UnitEnum|null $navigationGroup = null;
18+
19+
public static function getNavigationLabel(): string
20+
{
21+
return static::$navigationLabel ?? __('moox-prompts::prompts.ui.navigation_label');
22+
}
23+
24+
public function getTitle(): string
25+
{
26+
return static::$title ?? __('moox-prompts::prompts.ui.navigation_label');
27+
}
28+
29+
public static function getNavigationGroup(): ?string
30+
{
31+
return static::$navigationGroup ?? __('moox-prompts::prompts.ui.navigation_group');
32+
}
1833

1934
protected static ?int $navigationSort = 100;
2035

packages/prompts/src/PromptsServiceProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ public function configureMoox(Package $package): void
1818
$package
1919
->name('moox-prompts')
2020
->hasConfigFile('prompts')
21-
->hasViews();
21+
->hasViews()
22+
->hasTranslations();
2223
}
2324

2425
public function register()

packages/prompts/src/Support/FlowCommand.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77
interface PromptFlowCommand
88
{
99
/**
10-
* Liste der Step-Methoden, die der Flow in Reihenfolge ausführt.
10+
* List of step methods that the flow executes in order.
1111
*/
1212
public function promptFlowSteps(): array;
1313
}
1414

1515
/**
16-
* Basis-Klasse für Flow-basierte Commands.
16+
* Base class for flow-based commands.
1717
*
18-
* - CLI: führt alle in promptFlowSteps() definierten Methoden der Reihe nach aus.
19-
* - Web: der PromptFlowRunner ruft die gleichen Methoden stepweise auf.
18+
* - CLI: executes all methods defined in promptFlowSteps() sequentially.
19+
* - Web: the PromptFlowRunner calls the same methods step by step.
2020
*
21-
* Concrete Commands müssen nur:
22-
* - promptFlowSteps(): array implementieren
23-
* - die entsprechenden step*-Methoden bereitstellen.
21+
* Concrete commands only need to:
22+
* - implement promptFlowSteps(): array
23+
* - provide the corresponding step* methods.
2424
*/
2525
abstract class FlowCommand extends Command implements PromptFlowCommand
2626
{

0 commit comments

Comments
 (0)