symfony/translation · error · InvalidArgumentException
You must define "framework.enabled_locales" or…
Error message
You must define "framework.enabled_locales" or "framework.translator.providers.%s.locales" config key in order to work with translation providers.
What it means
Configuration guard in TranslationPushCommand::execute(): to push translations to a provider named %s the application must know which locales to push, but neither framework.enabled_locales nor framework.translator.providers.<name>.locales is defined in the configuration. The command cannot determine the locale set to synchronize, so it aborts.
Solutions
- Add `framework: enabled_locales: [en, fr]` (or the Symfony 4-era `translator.enabled_locales`) to config/packages/framework.yaml.
- Configure per-provider locales under `framework.translator.providers.<provider>.locales` in the translator provider config.
- Re-run with `--locales=en` on the command line, which overrides the missing config for this run.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at Command/TranslationPushCommand.php:114 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of symfony/translation@ae9e8a51bc (2026-09-15).
Data as JSON: /api/errors/e6ee41d4d4cbcc5d.
Report an issue: GitHub.
Appendix: source
Thrown at Command/TranslationPushCommand.php:114
Full example:
<info>php %command.full_name% provider --force --delete-missing --domains=messages --domains=validators --locales=en</>
This command pushes all translations associated with the <info>messages</> and <info>validators</> domains for the <info>en</> locale.
Provider translations for the specified domains and locale are deleted if they're not present locally and overwritten if it's the case.
Provider translations for others domains and locales are ignored.
EOF
)
;
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$provider = $this->providers->get($input->getArgument('provider'));
if (!$this->enabledLocales) {
throw new InvalidArgumentException(\sprintf('You must define "framework.enabled_locales" or "framework.translator.providers.%s.locales" config key in order to work with translation providers.', parse_url($provider, \PHP_URL_SCHEME)));
}
$io = new SymfonyStyle($input, $output);
$domains = $input->getOption('domains');
$locales = $input->getOption('locales');
$force = $input->getOption('force');
$deleteMissing = $input->getOption('delete-missing');
if (!$domains && $provider instanceof FilteringProvider) {
$domains = $provider->getDomains();
}
// Reading local translations must be done after retrieving the domains from the provider
// in order to manage only translations from configured domains
$localTranslations = $this->readLocalTranslations($locales, $domains, $this->transPaths);
if (!$domains) {
$domains = $this->getDomainsFromTranslatorBag($localTranslations);View on GitHub (pinned to ae9e8a51bc)