{"record":{"id":"8b0781e204a60047","repo":"symfony/translation","slug":"the-translator-does-not-support-the-following-options-s","errorCode":null,"errorMessage":"The Translator does not support the following options: '%s'.","messagePattern":"The Translator does not support the following options: '(.+?)'\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"DependencyInjection/Translator.php","lineNumber":82,"sourceCode":"     *   * debug:          Whether to enable debugging or not (false by default)\n     *   * resource_files: List of translation resources available grouped by locale.\n     *   * cache_vary:     An array of data that is serialized to generate the cached catalogue name.\n     *\n     * @param string[] $enabledLocales\n     *\n     * @throws InvalidArgumentException\n     */\n    public function __construct(\n        protected ContainerInterface $container,\n        MessageFormatterInterface $formatter,\n        string $defaultLocale,\n        protected array $loaderIds = [],\n        array $options = [],\n        private array $enabledLocales = [],\n    ) {\n        // check option names\n        if ($diff = array_diff(array_keys($options), array_keys($this->options))) {\n            throw new InvalidArgumentException(\\sprintf('The Translator does not support the following options: \\'%s\\'.', implode('\\', \\'', $diff)));\n        }\n\n        $this->options = array_merge($this->options, $options);\n        $this->resourceLocales = array_keys($this->options['resource_files']);\n        $this->resourceFiles = $this->options['resource_files'];\n        $this->scannedDirectories = $this->options['scanned_directories'];\n\n        parent::__construct($defaultLocale, $formatter, $this->options['cache_dir'], $this->options['debug'], $this->options['cache_vary']);\n    }\n\n    public function warmUp(string $cacheDir, ?string $buildDir = null): array\n    {\n        // skip warmUp when translator doesn't use cache\n        if (null === $this->options['cache_dir']) {\n            return [];\n        }\n\n        $localesToWarmUp = $this->enabledLocales ?: array_merge($this->getFallbackLocales(), [$this->getLocale()], $this->resourceLocales);","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/symfony/translation/blob/ae9e8a51bc29780d63c7f9efd6005d7c875e100b/DependencyInjection/Translator.php#L64-L100","documentation":"Thrown by Symfony Translation's Translator constructor when an option key in $options is not one of the supported option names ('cache_dir', 'debug', 'resource_files', 'scanned_directories', 'cache_vary', etc.). The constructor diffs the provided keys against known defaults and fails fast on unknown keys, usually to catch typos.","triggerScenarios":"Instantiating Translator::construct(..., $options) with any key not present in the class's default $options property, e.g. passing 'cacheDir' or 'resouce_files' instead of the exact snake_case names.","commonSituations":"Typo in option name when constructing the Translator manually or in TranslatorPass configuration; upgrading Symfony and an option was renamed; copying options from a different component that uses camelCase.","solutions":["Check the option key spelling against Translator::options defaults (cache_dir, debug, resource_files, scanned_directories, cache_vary)","Remove the unsupported option if it is not needed","If configuring via framework.yaml, validate translation config keys against your Symfony version's reference","Dump the constructor defaults (`new Translator(...)->getOptions()` pattern or read source) and align your keys"],"exampleFix":"// before\nnew Translator('en', null, $loaderIds, ['cacheDir' => '/tmp/cache']);\n// after\nnew Translator('en', null, $loaderIds, ['cache_dir' => '/tmp/cache']);","handlingStrategy":"validation","validationCode":"$supported = ['cache_dir','debug','resource_files','scanned_directories','cache_vary']; $bad = array_diff(array_keys($options), $supported); if ($bad) { throw new \\InvalidArgumentException('Unsupported options: '.implode(',', $bad)); }","typeGuard":"function hasOnlySupportedOptions(array $options, array $supported): bool { return [] === array_diff(array_keys($options), $supported); }","tryCatchPattern":"try { $translator = new Translator(..., $options); } catch (InvalidArgumentException $e) { // log unsupported option names and fix config }","preventionTips":["Copy option keys directly from the Translator class defaults, never retype them","Use named constants or a config factory that validates keys against a whitelist","Grep config for snake_case/camelCase mixing when upgrading Symfony"],"tags":["symfony","translation","invalid-option"],"backgroundTag":"unsupported-config-value","analyzedSha":"ae9e8a51bc29780d63c7f9efd6005d7c875e100b","analyzedAt":"2026-09-15T22:29:15.305Z","contentChangedAt":"2026-09-15T22:29:15.305Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}