From 4256e4f5ca75b949a60e43fe2963a72c165848db Mon Sep 17 00:00:00 2001 From: albertlast Date: Sat, 8 Aug 2026 17:51:17 +0200 Subject: [PATCH] Stops the forum offering to delete the language it falls back to MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The language editor guards its delete button with if (Utils::$context['lang_id'] != 'english') and the comment above it says English cannot be deleted. Language ids have not looked like that since 2.1 — Lang.php maps 'english' to 'en_US' precisely because it is the old name — so the comparison never matches anything and the button is offered for every language, including the one the forum is running on. The check that actually performs the deletion is spelled the same way, so it goes through. Deleting en_US is worse than losing a translation: Lang::load() falls back to it for any string the chosen language is missing, so a forum without it has no backstop. Guards on the forum's own default language and on en_US, decided once where lang_id is settled and read by both the action and the template. Signed-off-by: albertlast --- Sources/Actions/Admin/Languages.php | 7 ++++++- Themes/default/ManageLanguages.template.php | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Sources/Actions/Admin/Languages.php b/Sources/Actions/Admin/Languages.php index f482db58fa1..e0636dba07e 100644 --- a/Sources/Actions/Admin/Languages.php +++ b/Sources/Actions/Admin/Languages.php @@ -671,6 +671,11 @@ public function editEntries() Utils::$context['lang_id'] = &$lang_id; + // Neither the forum's own default nor en_US can go. en_US is what + // Lang::load() falls back to for any string the chosen language is + // missing, so a forum without it has no backstop at all. + Utils::$context['can_delete_language'] = $lang_id !== 'en_US' && $lang_id !== Config::$language; + // Get all the theme data. $themes = [ 1 => [ @@ -792,7 +797,7 @@ function ($val1, $val2) { } // We no longer wish to speak this language. - if (!empty($_POST['delete_main']) && $lang_id != 'english') { + if (!empty($_POST['delete_main']) && Utils::$context['can_delete_language']) { User::$me->checkSession(); SecurityToken::validate('admin-mlang'); diff --git a/Themes/default/ManageLanguages.template.php b/Themes/default/ManageLanguages.template.php index 363b3c35c86..ee980005735 100644 --- a/Themes/default/ManageLanguages.template.php +++ b/Themes/default/ManageLanguages.template.php @@ -182,8 +182,8 @@ function template_modify_language_entries() '; - // Allow deleting entries. English can't be deleted though. - if (Utils::$context['lang_id'] != 'english') { + // Allow deleting entries. The default language and en_US can't go. + if (Utils::$context['can_delete_language']) { echo ' '; }