From 1af317da1b3976528b1d2d3f479d7e58a999063b Mon Sep 17 00:00:00 2001 From: Gabriele Date: Sat, 25 Nov 2023 00:44:50 +0100 Subject: [PATCH] Implement support for unstranslated strings to GetLocalizedStr --- ClassevivaPCTO/Helpers/ResourceExtensions.cs | 21 +++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/ClassevivaPCTO/Helpers/ResourceExtensions.cs b/ClassevivaPCTO/Helpers/ResourceExtensions.cs index d51c503d..cf8a959a 100644 --- a/ClassevivaPCTO/Helpers/ResourceExtensions.cs +++ b/ClassevivaPCTO/Helpers/ResourceExtensions.cs @@ -4,17 +4,28 @@ namespace ClassevivaPCTO.Helpers { internal static class ResourceExtensions { - private static ResourceLoader _resLoader = new(); + private static ResourceLoader _defaultResLoader = new(); - public static string GetLocalizedStr(this string resourceKey) + public static string GetLocalizedStr(this string resourceKey, bool isNotTranslatable = false, string resourceFileName = null) { - return _resLoader.GetString(resourceKey); + ResourceLoader resLoader = _defaultResLoader; + + if (isNotTranslatable) + { + resLoader = new ResourceLoader("untranslatable"); + } + + if (!string.IsNullOrEmpty(resourceFileName)) { + resLoader = new ResourceLoader(resourceFileName); + } + + return resLoader.GetString(resourceKey); } - public static string GetLocalizedStr(this string resourceKey, string tag) + public static string GetLocalizedStr(this string resourceKey, string tag, bool isNotTranslatable = false, string resourceFileName = null) { resourceKey += "_" + tag; - return GetLocalizedStr(resourceKey); + return GetLocalizedStr(resourceKey, isNotTranslatable, resourceFileName); } } } \ No newline at end of file