19 declare(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));
49 $default = key($languages);
51 return $this->
ui->create()->input()->field()->group([
52 'lng' => $this->
radio(
53 $this->
ui->txt(
'language'),
55 $arguments[
'lng'] ?? $default
56 )->withRequired(
true, ($this->required)($languages))
57 ], $this->
ui->txt(
'crit_type_usr_language'), $this->
ui->txt(
'crit_type_usr_language_info'));
67 return $this->
ui->txt(
'crit_type_usr_language');
72 return $this->
ui->txt(
'meta_l_' . $language);
79 private function radio(
string $lang_key, array $options, $value):
Radio 81 $field = $this->
ui->create()->input()->field()->radio($lang_key);
82 foreach ($options as
$key => $label) {
83 $field = $field->withOption((
string)
$key, $label);
86 return $value !== null && isset($options[(
string) $value]) ? $field->withValue((
string) $value) : $field;
radio(string $lang_key, array $options, $value)
__construct(private readonly UI $ui, private readonly array $installed_languages, private readonly Closure $required)
formGroup(array $arguments=[])
withCriterion(CriterionContent $criterion)
translatedLanguage(string $language)