diff --git a/DNN Platform/Library/Services/Localization/ILocalizationProvider.cs b/DNN Platform/Library/Services/Localization/ILocalizationProvider.cs index df04c52f9ab..cb1a563f032 100644 --- a/DNN Platform/Library/Services/Localization/ILocalizationProvider.cs +++ b/DNN Platform/Library/Services/Localization/ILocalizationProvider.cs @@ -1,13 +1,13 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information - +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information + namespace DotNetNuke.Services.Localization { using System.Collections.Generic; - + using DotNetNuke.Entities.Portals; - + /// /// Do not implement. This interface is only implemented by the DotNetNuke core framework. Outside the framework it should used as a type and for unit test purposes only. /// There is no guarantee that this interface will not change. @@ -22,6 +22,8 @@ public interface ILocalizationProvider string GetString(string key, string resourceFileRoot, string language, PortalSettings portalSettings, bool disableShowMissingKeys); + string GetString(string key, string resourceFileRoot, string language, PortalSettings portalSettings, bool disableShowMissingKeys, out bool keyFound); + /// Saves a string to a resource file. /// The key to save (e.g. "MyWidget.Text"). /// The text value for the key. diff --git a/DNN Platform/Library/Services/Localization/Localization.cs b/DNN Platform/Library/Services/Localization/Localization.cs index 48b92417541..24823d9d69a 100644 --- a/DNN Platform/Library/Services/Localization/Localization.cs +++ b/DNN Platform/Library/Services/Localization/Localization.cs @@ -780,6 +780,20 @@ public static string GetString(string key, string resourceFileRoot, PortalSettin return LocalizationProvider.Instance.GetString(key, resourceFileRoot, language, portalSettings, disableShowMissingKeys); } + /// One of six overloads. + /// GetString gets the localized string corresponding to the . + /// The resource key to find. + /// The Local Resource root. + /// The current portals Portal Settings. + /// A specific language to lookup the string. + /// Disables the show missing keys flag. + /// Returns whether a ResourceKey exists in the ResourceFile. + /// The localized Text. + public static string GetString(string key, string resourceFileRoot, PortalSettings portalSettings, string language, bool disableShowMissingKeys, out bool keyFound) + { + return LocalizationProvider.Instance.GetString(key, resourceFileRoot, language, portalSettings, disableShowMissingKeys, out keyFound); + } + /// GetStringUrl gets the localized string corresponding to the . /// The resource key to find. /// The Local Resource root. diff --git a/DNN Platform/Library/Services/Localization/LocalizationProvider.cs b/DNN Platform/Library/Services/Localization/LocalizationProvider.cs index 174b40bd9c0..a03e7ada73d 100644 --- a/DNN Platform/Library/Services/Localization/LocalizationProvider.cs +++ b/DNN Platform/Library/Services/Localization/LocalizationProvider.cs @@ -52,6 +52,12 @@ public string GetString(string key, string resourceFileRoot, string language, Po /// public string GetString(string key, string resourceFileRoot, string language, PortalSettings portalSettings, bool disableShowMissingKeys) + { + return this.GetString(key, resourceFileRoot, language, portalSettings, disableShowMissingKeys, out _); + } + + /// + public string GetString(string key, string resourceFileRoot, string language, PortalSettings portalSettings, bool disableShowMissingKeys, out bool keyFound) { // make the default translation property ".Text" if (key.IndexOf(".", StringComparison.Ordinal) < 1) @@ -60,7 +66,7 @@ public string GetString(string key, string resourceFileRoot, string language, Po } string resourceValue = Null.NullString; - bool keyFound = TryGetStringInternal(key, language, resourceFileRoot, portalSettings, ref resourceValue); + keyFound = TryGetStringInternal(key, language, resourceFileRoot, portalSettings, ref resourceValue); // If the key can't be found then it doesn't exist in the Localization Resources if (Localization.ShowMissingKeys && !disableShowMissingKeys)