diff --git a/src/Discord.Net.Interactions/LocalizationManagers/ResxLocalizationManager.cs b/src/Discord.Net.Interactions/LocalizationManagers/ResxLocalizationManager.cs index 7b0ab6ed3..7f3b9e865 100644 --- a/src/Discord.Net.Interactions/LocalizationManagers/ResxLocalizationManager.cs +++ b/src/Discord.Net.Interactions/LocalizationManagers/ResxLocalizationManager.cs @@ -1,13 +1,7 @@ -using System; -using System.Collections.Concurrent; using System.Collections.Generic; -using System.Collections.Immutable; -using System.Diagnostics; using System.Globalization; -using System.Linq; using System.Reflection; using System.Resources; -using System.Threading.Tasks; namespace Discord.Interactions { @@ -22,9 +16,8 @@ namespace Discord.Interactions private readonly string _baseResource; private readonly Assembly _assembly; - private static readonly ConcurrentDictionary _localizerCache = new(); + private readonly ResourceManager _resourceManager; private readonly IEnumerable _supportedLocales; - private readonly IEnumerable _resourceNames; /// /// Initializes a new instance of the class. @@ -37,7 +30,7 @@ namespace Discord.Interactions _baseResource = baseResource; _assembly = assembly; _supportedLocales = supportedLocales; - _resourceNames = assembly.GetManifestResourceNames(); + _resourceManager = new ResourceManager(_baseResource, assembly); } /// @@ -50,17 +43,13 @@ namespace Discord.Interactions private IDictionary GetValues(IList key, string identifier) { - var resourceName = (_baseResource + "." + string.Join(".", key)).Replace(" ", SpaceToken); - - if (!_resourceNames.Any(x => string.Equals(resourceName + ".resources", x, StringComparison.OrdinalIgnoreCase))) - return ImmutableDictionary.Empty; + var entryKey = (string.Join('.', key) + '.' + identifier).Replace(" ", SpaceToken); var result = new Dictionary(); - var resourceManager = _localizerCache.GetOrAdd(resourceName, new ResourceManager(resourceName, _assembly)); foreach (var locale in _supportedLocales) { - var value = resourceManager.GetString(identifier, locale); + var value = _resourceManager.GetString(entryKey, locale); if (value is not null) result[locale.Name] = value; }