{"record":{"id":"3368dfee03ceb5b5","repo":"symfony/translation","slug":"file-s-not-found-icuresfileloader","errorCode":null,"errorMessage":"File \"%s\" not found.","messagePattern":"File \"(.+?)\" not found\\.","errorType":"exception","errorClass":"NotFoundResourceException","httpStatus":null,"severity":"error","filePath":"Loader/IcuResFileLoader.php","lineNumber":33,"sourceCode":"use Symfony\\Component\\Translation\\Exception\\InvalidResourceException;\nuse Symfony\\Component\\Translation\\Exception\\NotFoundResourceException;\nuse Symfony\\Component\\Translation\\MessageCatalogue;\n\n/**\n * IcuResFileLoader loads translations from a resource bundle.\n *\n * @author stealth35\n */\nclass IcuResFileLoader implements LoaderInterface\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 (!is_dir($resource)) {\n            throw new NotFoundResourceException(\\sprintf('File \"%s\" not found.', $resource));\n        }\n\n        try {\n            $rb = new \\ResourceBundle($locale, $resource);\n        } catch (\\Exception) {\n            $rb = null;\n        }\n\n        if (!$rb) {\n            throw new InvalidResourceException(\\sprintf('Cannot load resource \"%s\".', $resource));\n        } elseif (intl_is_failure($rb->getErrorCode())) {\n            throw new InvalidResourceException($rb->getErrorMessage(), $rb->getErrorCode());\n        }\n\n        $messages = $this->flatten($rb);\n        $catalogue = new MessageCatalogue($locale);\n        $catalogue->add($messages, $domain);\n","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/symfony/translation/blob/ae9e8a51bc29780d63c7f9efd6005d7c875e100b/Loader/IcuResFileLoader.php#L15-L51","documentation":"Resource guard in IcuResFileLoader::load(): the ICU resource bundle path given as $resource does not exist or is not readable, so the loader aborts with NotFoundResourceException before loading the bundle. It fires for any missing or mistyped .res bundle path when loading ICU translations.","triggerScenarios":"Calling IcuResFileLoader::load('/path/to/bundles', 'en') where the path does not exist or is a file rather than a directory.","commonSituations":"Typo in the bundle directory path, directory not deployed/synced, passing a single .res file instead of its directory, or the directory was removed by a cleanup job.","solutions":["Compile the ICU translations to a .res bundle at the given path before loading (genrb from .txt sources).","Verify the exact path passed to load() and that the file is readable by the PHP process.","Ensure the resource is a local filesystem path — remote streams are rejected with InvalidResourceException."],"exampleFix":"// before\n$loader->load('/app/resources/messages.res', 'en'); // a file, not a dir\n// after\n$dir = '/app/resources';\nif (!is_dir($dir)) {\n    throw new \\RuntimeException(\"ICU bundle directory missing: $dir\");\n}\n$loader->load($dir, 'en');","handlingStrategy":"fallback","validationCode":"if (!is_dir($dir)) {\n    throw new \\RuntimeException(\"ICU .res bundle directory missing: $dir\");\n}","typeGuard":"function isDirectory(mixed $r): bool { return is_string($r) && is_dir($r); }","tryCatchPattern":"try {\n    $catalogue = $loader->load($dir, $locale);\n} catch (Symfony\\Component\\Translation\\Exception\\NotFoundResourceException $e) {\n    error_log('ICU bundle dir missing: '.$e->getMessage());\n    $catalogue = new MessageCatalogue($locale);\n}","preventionTips":["Pass the directory containing .res files, never a single .res file.","Check is_dir() on boot and fail fast with a clear message.","Include bundle directories in deploy artifacts and cleanup exclusions."],"tags":["icu","resource-bundle","directory-not-found","translation"],"backgroundTag":"directory-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"}