Skip to content

[3.0] Stop the forum offering to delete the language it falls back to - #9394

Merged
jdarwood007 merged 1 commit into
SimpleMachines:release-3.0from
albertlast:3.0/language-delete-guard
Aug 8, 2026
Merged

[3.0] Stop the forum offering to delete the language it falls back to#9394
jdarwood007 merged 1 commit into
SimpleMachines:release-3.0from
albertlast:3.0/language-delete-guard

Conversation

@albertlast

Copy link
Copy Markdown
Collaborator

Description

The language editor offers to delete the language the forum is running on, and
goes through with it.

template_modify_language_entries() guards the button with:

// Allow deleting entries. English can't be deleted though.
if (Utils::$context['lang_id'] != 'english') {

Language ids have not looked like that since 2.1 — Sources/Lang.php carries
'english' => 'en_US' in its map of old names to new ones, which is exactly why.
$lang_id comes from $_GET['lid'], so on any 3.0 install it is en_US,
de_DE and so on, and the comparison never matches. Languages::modifyLanguage()
spells the check the same way when it acts on the post:

if (!empty($_POST['delete_main']) && $lang_id != 'english') {

so the button is not merely cosmetic.

Deleting en_US is worse than losing a translation. Lang::load() falls back to
it for any string the chosen language is missing:

&& 'en_US' !== Config::$language
&& 'en_US' !== $lang
) {
	$attempts[] = [$dir, $name, 'en_US'];

A forum without it has no backstop.

The guard now covers the forum's own default language and en_US, decided once
where $lang_id is settled and read by both the action and the template rather
than written out twice.

Testing

On a clean install of release-3.0 (a7ac468b1), one language installed,
?action=admin;area=languages;sa=editlang;lid=en_US:

delete button other buttons
before offered, with its confirmation Save, Reset
after absent Save, Reset

I have not exercised the positive case — a second language still being
deletable — because installing one needs to reach simplemachines.org and this box
has no outbound access. It follows from the same expression, and en_US is the
only value the negative case can take on a single-language install.

Found while converting this template's inline confirm() to the shared
you_sure handler in #9393.

Issues References (Fixes|Related|Closes)

Related to #7933

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 <mathiaspapealbert@hotmail.com>
@jdarwood007 jdarwood007 added the Localization Language & internationalization label Aug 8, 2026
@jdarwood007 jdarwood007 added this to the 3.0 Alpha 5 milestone Aug 8, 2026
@jdarwood007
jdarwood007 merged commit d2fc36e into SimpleMachines:release-3.0 Aug 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Localization Language & internationalization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants