{"record":{"id":"2f2e48f2f45a27e0","repo":"symfony/translation","slug":"loading-translations-from-the-qt-format-requires-the-symfony","errorCode":null,"errorMessage":"Loading translations from the QT format requires the Symfony Config component.","messagePattern":"Loading translations from the QT format requires the Symfony Config component\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"Loader/QtFileLoader.php","lineNumber":31,"sourceCode":"\nuse Symfony\\Component\\Config\\Resource\\FileResource;\nuse Symfony\\Component\\Config\\Util\\XmlUtils;\nuse Symfony\\Component\\Translation\\Exception\\InvalidResourceException;\nuse Symfony\\Component\\Translation\\Exception\\NotFoundResourceException;\nuse Symfony\\Component\\Translation\\Exception\\RuntimeException;\nuse Symfony\\Component\\Translation\\MessageCatalogue;\n\n/**\n * QtFileLoader loads translations from QT Translations XML files.\n *\n * @author Benjamin Eberlei <kontakt@beberlei.de>\n */\nclass QtFileLoader implements LoaderInterface\n{\n    public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue\n    {\n        if (!class_exists(XmlUtils::class)) {\n            throw new RuntimeException('Loading translations from the QT format requires the Symfony Config component.');\n        }\n\n        if (!stream_is_local($resource)) {\n            throw new InvalidResourceException(\\sprintf('This is not a local file \"%s\".', $resource));\n        }\n\n        if (!file_exists($resource)) {\n            throw new NotFoundResourceException(\\sprintf('File \"%s\" not found.', $resource));\n        }\n\n        try {\n            $dom = XmlUtils::loadFile($resource);\n        } catch (\\InvalidArgumentException $e) {\n            throw new InvalidResourceException(\\sprintf('Unable to load \"%s\".', $resource), $e->getCode(), $e);\n        }\n\n        $internalErrors = libxml_use_internal_errors(true);\n        libxml_clear_errors();","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/symfony/translation/blob/ae9e8a51bc29780d63c7f9efd6005d7c875e100b/Loader/QtFileLoader.php#L13-L49","documentation":"QtFileLoader parses QT translation TS (XML) files using Symfony's XmlUtils. That class lives in the symfony/config component; when it is not installed the loader cannot work and throws RuntimeException instead of a cryptic class-not-found error.","triggerScenarios":"Calling QtFileLoader::load() in a project where symfony/config is not installed (it is a suggested, not required, dependency of symfony/translation).","commonSituations":"Minimal installs with only symfony/translation, projects that removed symfony/config as transitive dependency, composer installs with --no-suggest that never added the optional package.","solutions":["Run `composer require symfony/config` to install the missing component.","Alternatively convert QT .ts files to XLIFF/PO and use a loader with no extra dependency.","Pin a symfony/config version compatible with your symfony/translation version after installing.","Verify with `php -r 'var_dump(class_exists(\"Symfony\\\\Component\\\\Config\\\\Util\\\\XmlUtils\"));'` before deploying."],"exampleFix":"// before\ncomposer require symfony/translation  // config component missing\n// after\ncomposer require symfony/translation symfony/config","handlingStrategy":"fallback","validationCode":"if (!class_exists(\\Symfony\\Component\\Config\\Util\\XmlUtils::class)) {\n    throw new \\RuntimeException('QT loading needs symfony/config; run composer require symfony/config');\n}","typeGuard":null,"tryCatchPattern":"try {\n    $catalogue = $qtLoader->load($file, $locale);\n} catch (\\RuntimeException $e) {\n    if (str_contains($e->getMessage(), 'Config component')) {\n        $catalogue = $xliffLoader->load(convertedFile, $locale); // pre-converted fallback\n    } else {\n        throw $e;\n    }\n}","preventionTips":["Require symfony/config explicitly in composer.json if QT loading is used","Run class_exists checks in your translation bootstrap","Prefer XLIFF/PO formats to avoid optional dependencies","Add a composer platform/dependency test in CI"],"tags":["qt","translation","dependency","composer"],"backgroundTag":"missing-optional-dependency","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"}