a2lix / TranslationFormBundle

Ease translations with some dedicated Symfony form types
https://a2lix.fr/bundles/translation-form
MIT License
329 stars 140 forks source link

No locales were configured, but expected at least the default locale #394

Open Paradonized opened 1 month ago

Paradonized commented 1 month ago

I get the error: No locales were configured, but expected at least the default locale en. Perhaps you need to add it to your a2lix_translation_form.locales bundle configuration?

I'm using Symfony 7 and just set up the translation bundle. Also I did the required steps: in config/packages/a2lix.yaml

a2lix_translation_form:
    locale_provider: default
    locales: [en, fr, es, de]
    default_locale: en
    required_locales: [fr]
    templating: "@A2lixTranslationForm/bootstrap_4_layout.html.twig"

and in my formType

$builder->add('translations', TranslationsType::class, [
    'locales' => ['en', 'fr', 'es', 'de'], 
    'default_locale' => ['en'], 
    'required_locales' => ['fr'],  
    'fields' => [                             
        'description' => [                       
            'field_type' => 'textarea',          
            'label' => 'descript.',      
            'locale_options' => [              
                'es' => ['label' => 'descripción'],   
                'fr' => ['display' => false]         
            ]
        ]
    ],
    'excluded_fields' => ['details'],         
    'locale_labels' => [                      
        'fr' => 'Français',
        'en' => 'English',
    ],
]);

in config/bundles.php

    A2lix\AutoFormBundle\A2lixAutoFormBundle::class => ['all' => true],
    A2lix\TranslationFormBundle\A2lixTranslationFormBundle::class => ['all' => true],

in config/packages/translation.yaml

framework:
    default_locale: en
    translator:
        default_path: '%kernel.project_dir%/translations'
        fallbacks:
            - en
        providers:

I went trough the documentation and the other issues but still couldn't resolve the problem.

c-vandendyck-kbr commented 1 month ago

@Paradonized I got the exact same error as you.. Also working on Symfony 7.

I fixed it by cleaning the cache with: php bin/console cache:clear