diff --git a/Libraries/Core/Services/I18nService.cs b/Libraries/Core/Services/I18nService.cs index 22e3a679..87d87ddf 100644 --- a/Libraries/Core/Services/I18nService.cs +++ b/Libraries/Core/Services/I18nService.cs @@ -13,13 +13,13 @@ public class I18nService private readonly JsonUtil _jsonUtil; private readonly Dictionary>> _loadedLocales = new(); - private List _locales; + private HashSet _locales; private string? _setLocale; public I18nService( FileUtil fileUtil, JsonUtil jsonUtil, - List locales, + HashSet locales, Dictionary fallbacks, string defaultLocale, string directory @@ -60,7 +60,7 @@ public class I18nService } } - public void SetLocale(string locale) + public void SetLocaleByKey(string locale) { if (_loadedLocales.ContainsKey(locale)) { @@ -86,7 +86,7 @@ public class I18nService } } - public string GetLocalised(string key) + public string GetLocalisedValue(string key) { if (!_loadedLocales.TryGetValue(_setLocale, out var locales)) { @@ -105,12 +105,12 @@ public class I18nService public string GetLocalised(string key) { - return GetLocalised(key); + return GetLocalisedValue(key); } public string GetLocalised(string key, object? args) { - var rawLocalizedString = GetLocalised(key); + var rawLocalizedString = GetLocalisedValue(key); if (args == null) { return rawLocalizedString; @@ -133,7 +133,7 @@ public class I18nService public string GetLocalised(string key, T? value) where T : IConvertible { - var rawLocalizedString = GetLocalised(key); + var rawLocalizedString = GetLocalisedValue(key); return rawLocalizedString.Replace("%s", value?.ToString()); } diff --git a/Libraries/Core/Services/LocalisationService.cs b/Libraries/Core/Services/LocalisationService.cs index e47ee3b1..811e8b29 100644 --- a/Libraries/Core/Services/LocalisationService.cs +++ b/Libraries/Core/Services/LocalisationService.cs @@ -32,18 +32,18 @@ public class LocalisationService _i18nService = new I18nService( fileUtil, jsonUtil, - localeService.GetServerSupportedLocales(), + localeService.GetServerSupportedLocales().ToHashSet(), localeService.GetLocaleFallbacks(), "en", "./Assets/database/locales/server" ); - _i18nService.SetLocale(localeService.GetDesiredServerLocale()); + _i18nService.SetLocaleByKey(localeService.GetDesiredServerLocale()); } public string GetText(string key, object? args = null) { return args is null - ? _i18nService.GetLocalised(key) + ? _i18nService.GetLocalisedValue(key) : _i18nService.GetLocalised(key, args); }