diff --git a/Libraries/Core/Services/LocaleService.cs b/Libraries/Core/Services/LocaleService.cs index 7293df72..bb54c4a7 100644 --- a/Libraries/Core/Services/LocaleService.cs +++ b/Libraries/Core/Services/LocaleService.cs @@ -1,4 +1,4 @@ -using System.Globalization; +using System.Globalization; using SptCommon.Annotations; using Core.Models.Spt.Config; using Core.Models.Utils; @@ -154,4 +154,9 @@ public class LocaleService( { return CultureInfo.InstalledUICulture; } + + public List GetLocaleKeysThatStartsWithValue(string partialKey) + { + return GetLocaleDb().Keys.Where(x => x.StartsWith(partialKey)).ToList(); + } } diff --git a/Libraries/Core/Services/LocalisationService.cs b/Libraries/Core/Services/LocalisationService.cs index ec5e22f7..d55eee2c 100644 --- a/Libraries/Core/Services/LocalisationService.cs +++ b/Libraries/Core/Services/LocalisationService.cs @@ -57,6 +57,9 @@ public class LocalisationService public string GetRandomTextThatMatchesPartialKey(string partialKey) { - throw new NotImplementedException(); + var values = _localeService.GetLocaleKeysThatStartsWithValue(partialKey); + var chosenKey = _randomUtil.GetArrayValue(values); + + return GetText(chosenKey); } }