19declare(strict_types=1);
40 private readonly
UI $ui,
41 private readonly array $installed_languages,
42 private readonly Closure $required
48 $languages = array_combine($this->installed_languages, array_map($this->
translatedLanguage(...), $this->installed_languages));
50 return $this->
ui->create()->input()->field()->group([
51 'lng' => $this->
radio(
52 $this->
ui->txt(
'language'),
54 $arguments[
'lng'] ??
null
55 )->withRequired(
true, ($this->required)($languages))
56 ], $this->ui->txt(
'crit_type_usr_language'), $this->ui->txt(
'crit_type_usr_language_info'));
66 return $this->
ui->txt(
'crit_type_usr_language');
71 return $this->
ui->txt(
'meta_l_' . $language);
78 private function radio(
string $lang_key, array $options, $value):
Radio
80 $field = $this->
ui->create()->input()->field()->radio($lang_key);
81 foreach ($options as $key => $label) {
82 $field = $field->withOption((
string) $key, $label);
85 return $value !==
null && isset($options[(
string) $value]) ? $field->withValue((
string) $value) : $field;
formGroup(array $arguments=[])
__construct(private readonly UI $ui, private readonly array $installed_languages, private readonly Closure $required)
translatedLanguage(string $language)
withCriterion(CriterionContent $criterion)
radio(string $lang_key, array $options, $value)
A constraint encodes some resrtictions on values.