Skip to content

[3.0] Fall back when a language string is missing - #9398

Merged
Sesquipedalian merged 1 commit into
SimpleMachines:release-3.0from
albertlast:3.0/lang-missing-fallback
Aug 14, 2026
Merged

[3.0] Fall back when a language string is missing#9398
Sesquipedalian merged 1 commit into
SimpleMachines:release-3.0from
albertlast:3.0/lang-missing-fallback

Conversation

@albertlast

Copy link
Copy Markdown
Collaborator

Description

Lang::getTxt() returns '' for a key it cannot find — never null:

// Don't waste time when getting a simple string.
if ($args === [] && \count($txt_key) === 1) {
	return self::${$var}[$txt_key[0]] ?? '';
}

So ?? never fires after it. Six calls pair getTxt() with a fallback that cannot be reached, and take the empty string instead. ?: is what was meant.

The smiley tooltips are the visible one

Sources/Editor.php looks a tooltip up as icon_ plus the lowercased description, and falls back to the description. Eight of the twenty two smileys SMF ships have no matching key, so eight buttons in the editor's emoticon drop-down carry an empty tooltip:

Description Key looked up In General.php
Huh? icon_huh? icon_huh
Roll Eyes icon_roll eyes icon_rolleyes
Lips Sealed icon_lips sealed icon_lips
Evil, Azn, Afro, Police, Angel icon_evil, … (none)

Straight off the reply page on a stock install, before and after:

 "tooltip": "Cool"           "tooltip": "Cool"
 "tooltip": ""          →    "tooltip": "Huh?"
 "tooltip": ""          →    "tooltip": "Roll Eyes"
 "tooltip": "Tongue"         "tooltip": "Tongue"
 "tooltip": "Embarrassed"    "tooltip": "Embarrassed"
 "tooltip": ""          →    "tooltip": "Lips Sealed"

Any smiley an admin adds through Admin → Smileys has the same problem, since nothing writes an icon_ string for it — that is the case the fallback exists for.

The rest
  • Actions/Admin/Themes.php and Actions/Profile/ThemeOptions.php, ×2 each: a theme variant or colour mode with no translated name loses its name entirely instead of falling back to its identifier. Not reachable on a stock install, since the default theme sets neither theme_variants nor has_dark_mode.
  • Themes/default/MaintenanceTemplate.php: the installer and upgrader emit <meta charset="">, because lang_character_set is not a 3.0 string at all. index.template.php writes UTF-8 literally; I kept the fallback rather than hard-coding it, since Actions/Admin/Languages.php still treats lang_character_set as an editable setting for older language packs.

I left the two getTxt(…) ?? '' in Parser.php and Unicode/Utf8String.php alone — they are the same mistake, but the fallback and the actual result are both '', so changing them would be noise.

Found while splitting #7933; not part of the theme, so it goes straight to release-3.0. Related to #9397, which fixes the calls that name the wrong language file — same sweep, different defect.

Issues References (Fixes|Related|Closes)

Related to #7933

Lang::getTxt() returns an empty string for a key it cannot find, never null,
so ?? never fires after it. Six calls pair it with a fallback that therefore
cannot be reached, and take the empty string instead.

Eight of the twenty two smileys SMF ships are affected: the tooltip is looked
up as icon_ plus the lowercased description, and the descriptions "Huh?",
"Roll Eyes" and "Lips Sealed" do not match the keys icon_huh, icon_rolleyes
and icon_lips, while Evil, Azn, Afro, Police and Angel have no icon_ string
at all. Their buttons in the editor's emoticon drop-down carry an empty
tooltip rather than the smiley's own description. Any smiley an admin adds
has the same problem, since nothing writes an icon_ string for it.

The others are a theme variant or colour mode with no translated name, which
loses its name rather than falling back to the identifier, and the installer
and upgrader emitting <meta charset=""> because lang_character_set is not a
3.0 string at all.

Signed-off-by: Mathias Papenbrock <mathiaspapealbert@hotmail.com>
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 6 milestone Aug 8, 2026
@Sesquipedalian
Sesquipedalian merged commit 492a07e into SimpleMachines:release-3.0 Aug 14, 2026
4 checks passed
@jdarwood007 jdarwood007 modified the milestones: 3.0 Alpha 6, 3.0 Alpha 5 Aug 14, 2026
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.

3 participants