symfony/translation · error · NotFoundResourceException

File " " not found.

Error message

File "%s" not found.

What it means

After confirming the resource is a local stream, the loader checks file_exists(); a path that does not exist raises NotFoundResourceException. It is the standard 'translation file missing' error of the XLIFF loader.

Solutions

  1. Verify the file exists at the exact path with file_exists($resource) before calling load().
  2. Fix the path/typo or the configured translation directory (%kernel.project_dir%/translations in Symfony).
  3. Check file name case matches exactly on case-sensitive filesystems.
  4. Ensure your deployment/build copies the translation files to the target environment.

Example fix

// before
$loader->load('translations/messages.en.xlf', 'en'); // file actually at app/translations/
// after
$loader->load('app/translations/messages.en.xlf', 'en');
Defensive patterns

Strategy: validation

Validate before calling

if (!file_exists($resource)) {
    throw new \RuntimeException(sprintf('Translation file missing: %s', $resource));
}

Try / catch

try {
    $catalogue = $loader->load($resource, $locale);
} catch (NotFoundResourceException $e) {
    $this->logger->warning('Missing translation file', ['file' => $resource]);
    return new MessageCatalogue($locale);
}

Prevention

When it happens

Trigger: Passing a local path to XliffFileLoader::load() where no file exists, e.g. a wrong directory, a locale/domain naming mistake, or a file deleted before load.

Common situations: Typo in translations directory configuration; deploy step that skips translation files; case-sensitive filesystems where Messages.EN.xlf != messages.en.xlf.

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

Appendix: source

Thrown at Loader/XliffFileLoader.php:44

 * XliffFileLoader loads translations from XLIFF files.
 *
 * @author Fabien Potencier <fabien@symfony.com>
 */
class XliffFileLoader implements LoaderInterface
{
    public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue
    {
        if (!class_exists(XmlUtils::class)) {
            throw new RuntimeException('Loading translations from the Xliff format requires the Symfony Config component.');
        }

        if (!$this->isXmlString($resource)) {
            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));
            }

            if (!is_file($resource)) {
                throw new InvalidResourceException(\sprintf('This is neither a file nor an XLIFF string "%s".', $resource));
            }
        }

        try {
            if ($this->isXmlString($resource)) {
                $dom = XmlUtils::parse($resource);
            } else {
                $dom = XmlUtils::loadFile($resource);
            }
        } catch (\InvalidArgumentException|XmlParsingException|InvalidXmlException $e) {
            throw new InvalidResourceException(\sprintf('Unable to load "%s": ', $resource).$e->getMessage(), $e->getCode(), $e);
        }

        if ($errors = XliffUtils::validateSchema($dom)) {

View on GitHub (pinned to ae9e8a51bc)