symfony/translation · error · NotFoundResourceException

File " " not found.

Error message

File "%s" not found.

What it means

Resource guard in IcuDatFileLoader::load(): the compiled ICU resource bundle file '<resource>.dat' does not exist or is not readable (the loader appends the .dat extension to the given path before checking), so it raises NotFoundResourceException before attempting to parse the bundle with ResourceBundle.

Solutions

  1. Generate the .dat resource bundle for the locale (e.g. with genrb and icupkg/derb conversion) and place it at the expected path.
  2. Verify the path passed to load() points at the bundle without the .dat suffix — the loader appends it automatically.
  3. Check filesystem permissions and that the file is local (stream_is_local requirement).

Example fix

// before
$loader->load('/app/resources/messages.en.dat', 'en'); // loader appends .dat again
// after
$loader->load('/app/resources/messages', 'en'); // expects /app/resources/messages.en.dat to exist
Defensive patterns

Strategy: fallback

Validate before calling

$datFile = $basePath.'.'.$locale.'.dat';
if (!file_exists($datFile)) {
    throw new \RuntimeException("Missing ICU bundle: $datFile");
}

Try / catch

try {
    $catalogue = $loader->load($basePath, $locale);
} catch (Symfony\Component\Translation\Exception\NotFoundResourceException $e) {
    $catalogue = $loader->load($basePath, $fallbackLocale);
}

Prevention

When it happens

Trigger: Calling IcuDatFileLoader::load('/path/bundle', 'en') when '/path/bundle.en.dat' (the .dat file referenced by ResourceBundle) does not exist locally.

Common situations: ICU bundles not packaged with the application, bundle built for a different naming scheme, files stripped during deployment, or passing the .dat file itself instead of the bundle base path.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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

Appendix: source

Thrown at Loader/IcuDatFileLoader.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 IcuDatFileLoader extends IcuResFileLoader
{
    public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue
    {
        if (!stream_is_local($resource.'.dat')) {
            throw new InvalidResourceException(\sprintf('This is not a local file "%s".', $resource));
        }

        if (!file_exists($resource.'.dat')) {
            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)