symfony/translation · error · NotFoundResourceException

File " " not found.

Error message

File "%s" not found.

What it means

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.

Solutions

  1. Create the missing translation file, e.g. translations/messages.en.xliff, matching the requested locale and domain.
  2. Verify the path passed to load() / the translator's resource paths (translations dir location, kernel.translations_dir).
  3. In the translator, fall back to another locale via enabled_locale_fallbacks or add fallback files so missing locales do not throw.
  4. Check filename spelling: locale and domain must match exactly (case-sensitive).

Example fix

// before
$loader->load(__DIR__.'/translations/messages.Fr.xlf', 'fr'); // wrong case
// after
$path = __DIR__.'/translations/messages.fr.xlf';
if (!file_exists($path)) {
    throw new \RuntimeException("Translation file missing: $path");
}
$loader->load($path, 'fr');
Defensive patterns

Strategy: fallback

Validate before calling

if (!file_exists($resource)) {
    throw new \RuntimeException("Translation file does not exist: $resource");
}

Try / catch

try {
    $catalogue = $loader->load($path, $locale);
} catch (Symfony\Component\Translation\Exception\NotFoundResourceException $e) {
    // optional translation file missing: continue with fallback locale
    $catalogue = $fallbackLoader->load($fallbackPath, $fallbackLocale);
}

Prevention

When it happens

Trigger: 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.

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

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/77f9bb001d6b0d1d. Report an issue: GitHub.

Appendix: source

Thrown at Loader/FileLoader.php:31

use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Translation\Exception\InvalidResourceException;
use Symfony\Component\Translation\Exception\NotFoundResourceException;
use Symfony\Component\Translation\MessageCatalogue;

/**
 * @author Abdellatif Ait boudad <a.aitboudad@gmail.com>
 */
abstract class FileLoader extends ArrayLoader
{
    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 (!file_exists($resource)) {
            throw new NotFoundResourceException(\sprintf('File "%s" not found.', $resource));
        }

        $messages = $this->loadResource($resource);

        // empty resource
        $messages ??= [];

        // not an array
        if (!\is_array($messages)) {
            throw new InvalidResourceException(\sprintf('Unable to load file "%s".', $resource));
        }

        $catalogue = parent::load($messages, $locale, $domain);

        if (class_exists(FileResource::class)) {
            $catalogue->addResource(new FileResource($resource));
        }

View on GitHub (pinned to ae9e8a51bc)