Handle missing or empty translations in MSGComponentBase.

This commit is contained in:
Thorsten Sommer 2025-04-17 12:25:56 +02:00
parent 36df88a415
commit 2caf291db3
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -41,8 +41,16 @@ public abstract class MSGComponentBase : ComponentBase, IDisposable, IMessageBus
var ns = $"{type.Namespace!}::{type.Name}".ToUpperInvariant().Replace(".", "::");
var key = $"root::{ns}::T{fallbackEN.ToFNV32()}";
if(this.Lang is NoPluginLanguage)
return fallbackEN;
if(this.Lang.TryGetText(key, out var text, logWarning: false))
{
if(string.IsNullOrWhiteSpace(text))
return fallbackEN;
return text;
}
this.Logger.LogWarning($"Missing translation key '{key}' for content '{fallbackEN}'.");
return fallbackEN;