From 94c8339e17c8ace9e28f0790622a3368c7d16cfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Mon, 8 May 2023 21:45:03 +0200 Subject: [PATCH] Allow for optional localised text notifications. --- OpenRA.Game/Translation.cs | 6 ++++++ OpenRA.Mods.Common/Lint/CheckTranslationReference.cs | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/OpenRA.Game/Translation.cs b/OpenRA.Game/Translation.cs index 9f1f062f62..90b1fc6182 100644 --- a/OpenRA.Game/Translation.cs +++ b/OpenRA.Game/Translation.cs @@ -27,6 +27,7 @@ namespace OpenRA [AttributeUsage(AttributeTargets.Field)] public sealed class TranslationReferenceAttribute : Attribute { + public readonly bool Optional; public readonly string[] RequiredVariableNames; public readonly LintDictionaryReference DictionaryReference; @@ -41,6 +42,11 @@ namespace OpenRA { DictionaryReference = dictionaryReference; } + + public TranslationReferenceAttribute(bool optional) + { + Optional = optional; + } } public class Translation diff --git a/OpenRA.Mods.Common/Lint/CheckTranslationReference.cs b/OpenRA.Mods.Common/Lint/CheckTranslationReference.cs index df2ff65fae..f759bab059 100644 --- a/OpenRA.Mods.Common/Lint/CheckTranslationReference.cs +++ b/OpenRA.Mods.Common/Lint/CheckTranslationReference.cs @@ -46,7 +46,9 @@ namespace OpenRA.Mods.Common.Lint { if (key == null) { - emitError($"Trait `{traitInfo.InstanceName}` on field `{field.Name}` has an empty translation reference."); + if (!translationReference.Optional) + emitError($"Trait `{traitInfo.InstanceName}` on field `{field.Name}` has an empty translation reference."); + continue; }