{"record":{"id":"b19e336984fbdeef","repo":"symfony/translation","slug":"no-loader-is-registered-for-the-s-format-when-loading-the-s","errorCode":null,"errorMessage":"No loader is registered for the \"%s\" format when loading the \"%s\" resource.","messagePattern":"No loader is registered for the \"(.+?)\" format when loading the \"(.+?)\" resource\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"Translator.php","lineNumber":371,"sourceCode":"    }\n\n    private function getCatalogueCachePath(string $locale): string\n    {\n        return $this->cacheDir.'/catalogue.'.$locale.'.'.strtr(substr(base64_encode(hash('xxh128', serialize($this->cacheVary), true)), 0, 7), '/', '_').'.php';\n    }\n\n    /**\n     * @internal\n     */\n    protected function doLoadCatalogue(string $locale): void\n    {\n        $this->catalogues[$locale] = new MessageCatalogue($locale);\n\n        if (isset($this->resources[$locale])) {\n            foreach ($this->resources[$locale] as $resource) {\n                if (!isset($this->loaders[$resource[0]])) {\n                    if (\\is_string($resource[1])) {\n                        throw new RuntimeException(\\sprintf('No loader is registered for the \"%s\" format when loading the \"%s\" resource.', $resource[0], $resource[1]));\n                    }\n\n                    throw new RuntimeException(\\sprintf('No loader is registered for the \"%s\" format.', $resource[0]));\n                }\n                $this->catalogues[$locale]->addCatalogue($this->loaders[$resource[0]]->load($resource[1], $locale, $resource[2]));\n            }\n        }\n    }\n\n    private function loadFallbackCatalogues(string $locale): void\n    {\n        $current = $this->catalogues[$locale];\n\n        foreach ($this->computeFallbackLocales($locale) as $fallback) {\n            if (!isset($this->catalogues[$fallback])) {\n                $this->initializeCatalogue($fallback);\n            }\n","sourceCodeStart":353,"sourceCodeEnd":389,"githubUrl":"https://github.com/symfony/translation/blob/ae9e8a51bc29780d63c7f9efd6005d7c875e100b/Translator.php#L353-L389","documentation":"Thrown by Symfony\\Component\\Translation\\Translator when catalogue initialisation encounters a registered translation resource whose format has no loader registered in $this->loaders, and the resource is a string path. RuntimeException includes both the format and the resource path.","triggerScenarios":"addResource('yaml', '/path/messages.fr.yaml', 'fr') (or via translation resource config) called without first adding a loader for that format via addLoader().","commonSituations":"Using a format whose loader package is missing (e.g. symfony/translation not configured with YamlFileLoader or XliffFileLoader), custom resource formats without a matching loader, or framework.translator loaders removed from DI.","solutions":["Register a loader for the format: $translator->addLoader('yaml', new YamlFileLoader())","Install the required package (e.g. symfony/yaml for yaml resources, symfony/twig or xml extension for xliff)","Check config/packages/translation.yaml loaders wiring in full-framework apps","Remove stale addResource() calls for formats you no longer support"],"exampleFix":"// before\n$translator->addResource('yaml', 'messages.fr.yaml', 'fr');\n// after\nuse Symfony\\Component\\Translation\\Loader\\YamlFileLoader;\n$translator->addLoader('yaml', new YamlFileLoader());\n$translator->addResource('yaml', 'messages.fr.yaml', 'fr');","handlingStrategy":"try-catch","validationCode":"foreach ($resources as [$format, $path]) {\n    if (!isset($loaders[$format])) {\n        throw new \\RuntimeException(\"Register a loader for format '{$format}' before adding resources.\");\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    $translator->trans('key', [], 'messages', 'fr');\n} catch (RuntimeException $e) {\n    if (str_contains($e->getMessage(), 'No loader is registered')) {\n        // register the missing loader and retry\n    }\n}","preventionTips":["Always pair addResource() with a matching addLoader()","Keep symfony/yaml (and other format packages) in composer.json","In full-framework apps, do not remove default translation loader DI definitions"],"tags":["php","symfony","translation","loader"],"backgroundTag":"missing-dependency","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"}