Implemented GetRandomTextThatMatchesPartialKey

This commit is contained in:
Chomp
2025-01-23 17:22:12 +00:00
parent 72cdae8641
commit e666485c82
2 changed files with 10 additions and 2 deletions
+6 -1
View File
@@ -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<string> GetLocaleKeysThatStartsWithValue(string partialKey)
{
return GetLocaleDb().Keys.Where(x => x.StartsWith(partialKey)).ToList();
}
}
@@ -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);
}
}