{"record":{"id":"1122fb6e5c34b175","repo":"octobercms/october","slug":"missing-key-for-english-key-in-englis","errorCode":null,"errorMessage":"[!!] Missing key for english [{$key}] in [{$englishPath}]","messagePattern":"\\[!!\\] Missing key for english \\[(.+?)\\] in \\[(.+?)\\]","errorType":"console","errorClass":"Exception","httpStatus":null,"severity":"warning","filePath":"modules/system/console/OctoberUtilRefitLang.php","lineNumber":188,"sourceCode":"            $fileName = 'lang.php';\n        }\n\n        $englishPath = \"{$basePath}/lang/en/{$fileName}\";\n        $englishArr = include($englishPath);\n\n        $legacyPath = \"{$basePath}/lang/{$lang}/{$fileName}\";\n        $legacyArr = include($legacyPath);\n\n        $newPath = \"{$basePath}/lang/{$lang}.json\";\n        $newArr = [];\n\n        if (file_exists($newPath)) {\n            $newArr = json_decode(file_get_contents($newPath), true);\n        }\n\n        $english = array_get($englishArr, $key);\n        if (!$english) {\n            throw new Exception(\"[!!] Missing key for english [{$key}] in [{$englishPath}]\");\n        }\n\n        $translated = array_get($legacyArr, $key);\n        if (!$translated) {\n            $this->comment(\"[{$lang}] Missing key [{$key}] in [{$legacyPath}]\");\n            return;\n        }\n\n        $newArr[$english] = $translated;\n\n        File::put($newPath, $this->refitLangJsonEncode($newArr));\n\n        $this->comment(\"[{$lang}] → {$english}:{$translated}\");\n\n        if ($lang === 'en') {\n            $this->comment(PHP_EOL);\n            $this->refitFinalMessage = \"<?= __(\\\"{$english}\\\") ?>\";\n        }","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/system/console/OctoberUtilRefitLang.php#L170-L206","documentation":"The october:util refit lang utility (OctoberUtilRefitLang::utilRefitLang) converts legacy nested PHP language files (lang/<locale>/<file>.php) into per-locale JSON files (lang/<locale>.json) keyed by the English source string. For each key found in a non-English locale it does array_get($englishArr, $key); when the English source file has no such key, the JSON key cannot be derived and an Exception '[!!] Missing key for english ...' aborts the run.","triggerScenarios":"Running php artisan october:util refit lang when lang/<locale>/<file>.php contains keys that do not exist in lang/en/<file>.php (translator added keys only to their locale, or English keys were renamed), or the English file is missing entirely.","commonSituations":"Contributed translations drifting ahead of the English base; plugins merged from forks with divergent lang trees; refactoring that renamed English keys but not the translations.","solutions":["Add the missing key(s) to the English file named in the message (lang/en/<file>.php) — the message includes the key and path","Or delete the orphaned key(s) from the offending locale file if the string is obsolete","Re-run php artisan october:util refit lang; each fixed file proceeds until the next missing key, so repeat until it completes"],"exampleFix":"// before: lang/fr/validation.php contains 'custom.name' but lang/en/validation.php does not\n\n// after: add the English source so the JSON key can be derived\n// lang/en/validation.php\nreturn [\n    // ...\n    'custom' => ['name' => 'Name'],\n];","handlingStrategy":"validation","validationCode":"$en = include \"$basePath/lang/en/{$fileName}.php\";\n$loc = include \"$basePath/lang/{$lang}/{$fileName}.php\";\n$missing = array_diff(array_keys(array_dot($loc)), array_keys(array_dot($en)));\nif ($missing) {\n    // fix lang/en first: ' . print_r($missing, true)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep English files the canonical key set; add new keys there first","Run a key-diff check in CI before executing refit lang on translation trees","Rename keys in all locales together, never English alone"],"tags":["i18n","lang-files","cli","migration"],"backgroundTag":"missing-translation-key","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}