{"record":{"id":"d956fa4c8fd41a57","repo":"flarum/framework","slug":"you-cannot-disable-the-default-language-pack","errorCode":null,"errorMessage":"You cannot disable the default language pack!","messagePattern":"You cannot disable the default language pack!","errorType":"exception","errorClass":"PermissionDeniedException","httpStatus":403,"severity":"error","filePath":"framework/core/src/Extension/DefaultLanguagePackGuard.php","lineNumber":34,"sourceCode":"\nclass DefaultLanguagePackGuard\n{\n    public function __construct(\n        protected SettingsRepositoryInterface $settings\n    ) {\n    }\n\n    public function handle(Disabling $event): void\n    {\n        if (! Arr::has($event->extension->extra, 'flarum-locale')) {\n            return;\n        }\n\n        $defaultLocale = $this->settings->get('default_locale');\n        $locale = Arr::get($event->extension->extra, 'flarum-locale.code');\n\n        if ($locale === $defaultLocale) {\n            throw new PermissionDeniedException('You cannot disable the default language pack!');\n        }\n    }\n}\n","sourceCodeStart":16,"sourceCodeEnd":38,"githubUrl":"https://github.com/flarum/framework/blob/4b939f685389bfe8a380e9e28ddf305a1c66950c/framework/core/src/Extension/DefaultLanguagePackGuard.php#L16-L38","documentation":"Flarum throws PermissionDeniedException from DefaultLanguagePackGuard::handle when an extension being disabled is the language pack that supplies the forum's default locale. The guard listens to the extension disabling event and compares the pack's flarum-locale.code extra field against the default_locale setting. Disabling it would leave the forum without its default language, so the operation is refused.","triggerScenarios":"Attempting to disable (or uninstall) a language-pack extension whose locale code equals the 'default_locale' setting (e.g. clicking Disable on the 'en' language pack while default_locale is 'en'), via admin panel or the flarum extension:disable console command.","commonSituations":"Admins cleaning up 'unused' extensions in the dashboard; scripted extension management that disables all non-core extensions; migrating to a new language pack without first switching default_locale.","solutions":["Change the default locale to another installed language pack first (admin panel Appearance/Language settings, or set 'default_locale' in the settings table / config), then disable the old pack.","Install another language pack for the desired locale, switch default_locale to it, then disable the original pack.","If the extension must be removed by script, check its flarum-locale.code against the current default_locale before calling disable and skip or reorder operations."],"exampleFix":"// before: disabling the en pack while default_locale = en\nphp flarum extension:disable flarum-lang-english\n\n// after: switch default locale first, then disable\nphp flarum config:set default_locale de  // or update settings table\nphp flarum extension:disable flarum-lang-english","handlingStrategy":"try-catch","validationCode":"// before disabling an extension\n$locale = Arr::get($extension->getExtra(), 'flarum-locale.code');\n$defaultLocale = $settings->get('default_locale');\n$canDisable = $locale === null || $locale !== $defaultLocale;","typeGuard":null,"tryCatchPattern":"try {\n    $manager->disable($extensionId);\n} catch (PermissionDeniedException $e) {\n    // switch default_locale first or surface a friendly admin notice\n}","preventionTips":["Always install at least two language packs before disabling any of them.","Check flarum-locale.code against default_locale in automation scripts before disabling.","Switch default_locale as part of the migration runbook, not after cleanup."],"tags":["flarum","permission-denied","language-pack","configuration"],"backgroundTag":"invalid-state-transition","analyzedSha":"4b939f685389bfe8a380e9e28ddf305a1c66950c","analyzedAt":"2026-09-15T18:09:20.879Z","contentChangedAt":"2026-09-15T18:09:20.879Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}