{"record":{"id":"6041640dcaab27f0","repo":"phalcon/cphalcon","slug":"parameter-directory-is-required","errorCode":null,"errorMessage":"Parameter 'directory' is required","messagePattern":"Parameter 'directory' is required","errorType":"exception","errorClass":"Phalcon\\Translate\\Exceptions\\MissingRequiredParameter","httpStatus":null,"severity":"error","filePath":"phalcon/Translate/Adapter/Gettext.zep","lineNumber":296,"sourceCode":"        return [\n            \"category\":      LC_ALL,\n            \"defaultDomain\": \"messages\"\n        ];\n    }\n\n    /**\n     * Validator for constructor\n     *\n     * @phpstan-param translate_gettext_options $options\n     */\n    protected function prepareOptions( array options) -> void\n    {\n        if unlikely !isset options[\"locale\"] {\n            throw new MissingRequiredParameter(\"locale\");\n        }\n\n        if unlikely !isset options[\"directory\"] {\n            throw new MissingRequiredParameter(\"directory\");\n        }\n\n        let options = array_merge(\n            this->getOptionsDefault(),\n            options\n        );\n\n        this->setLocale(options[\"category\"], options[\"locale\"]);\n        this->setDefaultDomain(options[\"defaultDomain\"]);\n        this->setDirectory(options[\"directory\"]);\n        this->setDomain(options[\"defaultDomain\"]);\n    }\n}\n","sourceCodeStart":278,"sourceCodeEnd":310,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Translate/Adapter/Gettext.zep#L278-L310","documentation":"The second mandatory Gettext option: prepareOptions() throws Phalcon\\Translate\\Exceptions\\MissingRequiredParameter('directory') when options lacks 'directory' (phalcon/Translate/Adapter/Gettext.zep:296). The directory is where gettext looks for <locale>/<LC_CATEGORY>/<domain>.mo files — a string path or an array of paths.","triggerScenarios":"new Gettext($factory, ['locale' => 'de_DE.UTF-8']) without 'directory'; passing the key as 'dir', 'path', or 'directories'.","commonSituations":"Config moved to a new structure and the directory entry dropped; single-locale dev setups where the directory was hardcoded then removed; the check order means locale errors surface first — fix locale, then this one appears.","solutions":["Add 'directory' => '/app/locales' (string) or an array of directories when catalogs live in several places.","Ensure the directory layout matches gettext expectations: <directory>/<locale>/LC_MESSAGES/<domain>.mo.","Validate both 'locale' and 'directory' keys before constructing when options are dynamic."],"exampleFix":"// before\n$t = new Gettext($factory, ['locale' => 'de_DE.UTF-8']);\n\n// after\n$t = new Gettext($factory, [\n    'locale'        => 'de_DE.UTF-8',\n    'directory'     => '/app/locales',\n    'defaultDomain' => 'messages',\n]);","handlingStrategy":"validation","validationCode":"$required = ['locale', 'directory'];\n$missing = array_diff($required, array_keys($options));\nif ($missing !== []) {\n    throw new InvalidArgumentException('Gettext adapter missing options: ' . implode(', ', $missing));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check both required keys together — validation order surfaces 'locale' first, then 'directory'.","Lay out catalogs as <directory>/<locale>/LC_MESSAGES/<domain>.mo so gettext resolves them.","Use an array of directories when catalogs are split across modules."],"tags":["phalcon","translate","gettext","directory","missing-option","i18n"],"backgroundTag":"missing-required-option","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}