mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-12-15 07:29:30 +00:00
Ermögliche Rückgabe aller möglichen Sprachoptionen in Verbindung mit den vom Nutzer freigeschalteten.
This commit is contained in:
parent
a8b3dce899
commit
8c139fbe04
1 changed files with 12 additions and 2 deletions
|
|
@ -60,7 +60,7 @@ class DataSourceSynonymRowType extends AbstractType
|
|||
'required' => true,
|
||||
// Restrict to languages configured in the language menu: disable ChoiceLoader and provide explicit choices
|
||||
'choice_loader' => null,
|
||||
'choices' => $this->buildLocaleChoices(),
|
||||
'choices' => $this->buildLocaleChoices(true),
|
||||
'preferred_choices' => $this->getPreferredLocales(),
|
||||
'constraints' => [
|
||||
new Assert\NotBlank(message: 'settings.system.data_source_synonyms.row_type.value_not_blank'),
|
||||
|
|
@ -97,9 +97,14 @@ class DataSourceSynonymRowType extends AbstractType
|
|||
* Returns only locales configured in the language menu (settings) or falls back to the parameter.
|
||||
* Format: ['German (DE)' => 'de', ...]
|
||||
*/
|
||||
private function buildLocaleChoices(): array
|
||||
private function buildLocaleChoices(bool $returnPossible = false): array
|
||||
{
|
||||
$locales = $this->getPreferredLocales();
|
||||
|
||||
if ($returnPossible) {
|
||||
$locales = $this->getPossibleLocales();
|
||||
}
|
||||
|
||||
$choices = [];
|
||||
foreach ($locales as $code) {
|
||||
$label = Locales::getName($code);
|
||||
|
|
@ -119,6 +124,11 @@ class DataSourceSynonymRowType extends AbstractType
|
|||
return !empty($fromSettings) ? array_values($fromSettings) : array_values($this->preferredLanguagesParam);
|
||||
}
|
||||
|
||||
private function getPossibleLocales(): array
|
||||
{
|
||||
return array_values($this->preferredLanguagesParam);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setRequired('data_sources');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue