symfony/translation · error · NotFoundResourceException

File " " not found.

Error message

File "%s" not found.

What it means

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.

Solutions

  1. Compile the ICU translations to a .res bundle at the given path before loading (genrb from .txt sources).
  2. Verify the exact path passed to load() and that the file is readable by the PHP process.
  3. Ensure the resource is a local filesystem path — remote streams are rejected with InvalidResourceException.

Example fix

// before
$loader->load('/app/resources/messages.res', 'en'); // a file, not a dir
// after
$dir = '/app/resources';
if (!is_dir($dir)) {
    throw new \RuntimeException("ICU bundle directory missing: $dir");
}
$loader->load($dir, 'en');
Defensive patterns

Strategy: fallback

Validate before calling

if (!is_dir($dir)) {
    throw new \RuntimeException("ICU .res bundle directory missing: $dir");
}

Type guard

function isDirectory(mixed $r): bool { return is_string($r) && is_dir($r); }

Try / catch

try {
    $catalogue = $loader->load($dir, $locale);
} catch (Symfony\Component\Translation\Exception\NotFoundResourceException $e) {
    error_log('ICU bundle dir missing: '.$e->getMessage());
    $catalogue = new MessageCatalogue($locale);
}

Prevention

When it happens

Trigger: Calling IcuResFileLoader::load('/path/to/bundles', 'en') where the path does not exist or is a file rather than a directory.

Common situations: 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.

Related errors


AI-assisted analysis of symfony/translation@ae9e8a51bc (2026-09-15). Data as JSON: /api/errors/3368dfee03ceb5b5. Report an issue: GitHub.

Appendix: source

Thrown at Loader/IcuResFileLoader.php:33

use Symfony\Component\Translation\Exception\InvalidResourceException;
use Symfony\Component\Translation\Exception\NotFoundResourceException;
use Symfony\Component\Translation\MessageCatalogue;

/**
 * IcuResFileLoader loads translations from a resource bundle.
 *
 * @author stealth35
 */
class IcuResFileLoader implements LoaderInterface
{
    public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue
    {
        if (!stream_is_local($resource)) {
            throw new InvalidResourceException(\sprintf('This is not a local file "%s".', $resource));
        }

        if (!is_dir($resource)) {
            throw new NotFoundResourceException(\sprintf('File "%s" not found.', $resource));
        }

        try {
            $rb = new \ResourceBundle($locale, $resource);
        } catch (\Exception) {
            $rb = null;
        }

        if (!$rb) {
            throw new InvalidResourceException(\sprintf('Cannot load resource "%s".', $resource));
        } elseif (intl_is_failure($rb->getErrorCode())) {
            throw new InvalidResourceException($rb->getErrorMessage(), $rb->getErrorCode());
        }

        $messages = $this->flatten($rb);
        $catalogue = new MessageCatalogue($locale);
        $catalogue->add($messages, $domain);

View on GitHub (pinned to ae9e8a51bc)