{"record":{"id":"77f9bb001d6b0d1d","repo":"symfony/translation","slug":"file-s-not-found","errorCode":null,"errorMessage":"File \"%s\" not found.","messagePattern":"File \"(.+?)\" not found\\.","errorType":"exception","errorClass":"NotFoundResourceException","httpStatus":null,"severity":"error","filePath":"Loader/FileLoader.php","lineNumber":31,"sourceCode":"\nuse Symfony\\Component\\Config\\Resource\\FileResource;\nuse Symfony\\Component\\Translation\\Exception\\InvalidResourceException;\nuse Symfony\\Component\\Translation\\Exception\\NotFoundResourceException;\nuse Symfony\\Component\\Translation\\MessageCatalogue;\n\n/**\n * @author Abdellatif Ait boudad <a.aitboudad@gmail.com>\n */\nabstract class FileLoader extends ArrayLoader\n{\n    public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue\n    {\n        if (!stream_is_local($resource)) {\n            throw new InvalidResourceException(\\sprintf('This is not a local file \"%s\".', $resource));\n        }\n\n        if (!file_exists($resource)) {\n            throw new NotFoundResourceException(\\sprintf('File \"%s\" not found.', $resource));\n        }\n\n        $messages = $this->loadResource($resource);\n\n        // empty resource\n        $messages ??= [];\n\n        // not an array\n        if (!\\is_array($messages)) {\n            throw new InvalidResourceException(\\sprintf('Unable to load file \"%s\".', $resource));\n        }\n\n        $catalogue = parent::load($messages, $locale, $domain);\n\n        if (class_exists(FileResource::class)) {\n            $catalogue->addResource(new FileResource($resource));\n        }\n","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/symfony/translation/blob/ae9e8a51bc29780d63c7f9efd6005d7c875e100b/Loader/FileLoader.php#L13-L49","documentation":"Generic resource guard in the abstract FileLoader::load(): the $resource path given to the loader does not exist or is not readable, so no translation file can be opened. This NotFoundResourceException is thrown before parsing by every file-based translation loader (Xliff, Yaml, Qt, Po, etc.) whenever the requested file for that locale/domain is absent.","triggerScenarios":"Calling any subclass of FileLoader with a local path that does not exist, e.g. load('/app/translations/messages.en.xlf', 'en') where the file was never created or the path is wrong.","commonSituations":"Missing translation files after deployment, wrong kernel project directory resolution, locale-file naming mismatch (messages.fr_ca vs messages.fr_CA), or deleted files excluded by .gitignore/.dockerignore.","solutions":["Create the missing translation file, e.g. translations/messages.en.xliff, matching the requested locale and domain.","Verify the path passed to load() / the translator's resource paths (translations dir location, kernel.translations_dir).","In the translator, fall back to another locale via enabled_locale_fallbacks or add fallback files so missing locales do not throw.","Check filename spelling: locale and domain must match exactly (case-sensitive)."],"exampleFix":"// before\n$loader->load(__DIR__.'/translations/messages.Fr.xlf', 'fr'); // wrong case\n// after\n$path = __DIR__.'/translations/messages.fr.xlf';\nif (!file_exists($path)) {\n    throw new \\RuntimeException(\"Translation file missing: $path\");\n}\n$loader->load($path, 'fr');","handlingStrategy":"fallback","validationCode":"if (!file_exists($resource)) {\n    throw new \\RuntimeException(\"Translation file does not exist: $resource\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    $catalogue = $loader->load($path, $locale);\n} catch (Symfony\\Component\\Translation\\Exception\\NotFoundResourceException $e) {\n    // optional translation file missing: continue with fallback locale\n    $catalogue = $fallbackLoader->load($fallbackPath, $fallbackLocale);\n}","preventionTips":["Generate/commit all locale files with consistent naming (messages.<locale>.<ext>).","Check file existence for every configured locale in a smoke test.","Beware locale casing (fr_CA vs fr_ca) in file names.","Use the Translation component's catalogues/paths config instead of ad-hoc paths."],"tags":["file-loader","translation","file-not-found"],"backgroundTag":"file-not-found","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"}