Skip to content

Translations

Labels, descriptions, outcomes, confirmations and the reason of a deadline may be language keys. They stay keys in the stored definition, so it is the same in every language, and are translated when shown:

public function label(): string
{
return 'Purchase.workflow';
}
State::make('draft')->label('Purchase.states.draft')->initial(),
Transition::make('submit')->label('Purchase.transitions.submit')->confirm('Purchase.confirmSubmit'),
Task::make('budget')->label('Purchase.tasks.budget')
->outcomes(['approved' => 'Purchase.outcomes.approved', 'rejected' => 'Purchase.outcomes.rejected'])
->form(static fn (): array => [TextInput::make('cost_center')->label(lang('Purchase.fields.costCenter'))]),

with app/Language/en/Purchase.php and app/Language/de/Purchase.php.

  • A text is translated when it is a whole key (File.key.sub) that exists; other texts are shown as they are.
  • Fields of forms are built when the form is shown: give them a closure and call lang() in it.
  • Use $workflow->title(), stateLabel() and transitionLabel() for the translated labels in own views.
  • Task titles are stored when the task is created, in the language of the user who started the step.