{"record":{"id":"822f60553717d9c3","repo":"symfony/routing","slug":"route-s-is-missing-routes-for-locale-s-s","errorCode":null,"errorMessage":"Route \"%s\" is missing routes for locale(s) \"%s\".","messagePattern":"Route \"(.+?)\" is missing routes for locale\\(s\\) \"(.+?)\"\\.","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"Loader/Configurator/Traits/LocalizedRouteTrait.php","lineNumber":40,"sourceCode":" */\ntrait LocalizedRouteTrait\n{\n    /**\n     * Creates one or many routes.\n     *\n     * @param string|array $path the path, or the localized paths of the route\n     */\n    final protected function createLocalizedRoute(RouteCollection $collection, string $name, string|array $path, string $namePrefix = '', ?array $prefixes = null): RouteCollection\n    {\n        $paths = [];\n\n        $routes = new RouteCollection();\n\n        if (\\is_array($path)) {\n            if (null === $prefixes) {\n                $paths = $path;\n            } elseif ($missing = array_diff_key($prefixes, $path)) {\n                throw new \\LogicException(\\sprintf('Route \"%s\" is missing routes for locale(s) \"%s\".', $name, implode('\", \"', array_keys($missing))));\n            } else {\n                foreach ($path as $locale => $localePath) {\n                    if (!isset($prefixes[$locale])) {\n                        throw new \\LogicException(\\sprintf('Route \"%s\" with locale \"%s\" is missing a corresponding prefix in its parent collection.', $name, $locale));\n                    }\n\n                    $paths[$locale] = $prefixes[$locale].$localePath;\n                }\n            }\n        } elseif (null !== $prefixes) {\n            foreach ($prefixes as $locale => $prefix) {\n                $paths[$locale] = $prefix.$path;\n            }\n        } else {\n            $routes->add($namePrefix.$name, $route = $this->createRoute($path));\n            $collection->add($namePrefix.$name, $route);\n\n            return $routes;","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/symfony/routing/blob/83fa223250b50f4f018c011e101c330e65ac63cc/Loader/Configurator/Traits/LocalizedRouteTrait.php#L22-L58","documentation":"createLocalizedRoute() checks that when a parent collection defines localized prefixes, the route's array of paths covers exactly those locales. If any prefix locale has no corresponding path in the route's array, a LogicException is thrown listing the missing locales.","triggerScenarios":"Parent configured with ->prefix(['en' => '/en', 'fr' => '/fr']) but child route called with a partial path array, e.g. ->route('home', ['en' => '/']) missing 'fr'.","commonSituations":"Adding a new locale to the parent prefix map without updating every localized route; copying route definitions between projects with different locale sets; localized imports where one child omits a language.","solutions":["Provide a path entry for every locale defined in the parent prefix map.","Remove locales from the parent prefix that the route intentionally does not support.","Use a scalar path (non-localized) if per-locale paths are not required."],"exampleFix":"// before\n->prefix(['en' => '/en', 'fr' => '/fr'])\n    ->route('home', ['en' => '/']);\n// after\n->prefix(['en' => '/en', 'fr' => '/fr'])\n    ->route('home', ['en' => '/', 'fr' => '/']);","handlingStrategy":"validation","validationCode":"$missing = array_diff_key($prefixes, $paths);\nif ($missing) { throw new \\LogicException('Route is missing paths for: ' . implode(',', array_keys($missing))); }","typeGuard":null,"tryCatchPattern":"try { $cfg->add($name, $paths); } catch (\\LogicException $e) { /* supply paths for listed locales */ }","preventionTips":["Generate localized path arrays from the parent's prefix keys so they can never diverge.","When adding a locale, update all localized routes at once.","Use a shared LOCALES constant in config."],"tags":["routing","i18n","localized-routes","symfony"],"backgroundTag":"missing-required-config-field","analyzedSha":"83fa223250b50f4f018c011e101c330e65ac63cc","analyzedAt":"2026-09-14T03:19:46.280Z","contentChangedAt":"2026-09-14T03:19:46.280Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}