1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

Fix build

This commit is contained in:
Ivan Savenko
2025-03-18 11:56:22 +00:00
parent eb3b51a6cf
commit ca8dcf30ed
2 changed files with 10 additions and 8 deletions

View File

@@ -306,6 +306,15 @@ DLL_LINKAGE std::string TextOperations::getLocaleName()
return Languages::getLanguageOptions(LIBRARY->generaltexth->getPreferredLanguage()).localeName;
}
DLL_LINKAGE bool TextOperations::compareLocalizedStrings(std::string_view str1, std::string_view str2)
{
static const std::locale loc(getLocaleName());
static const std::collate<char> & col = std::use_facet<std::collate<char>>(loc);
return col.compare(str1.data(), str1.data() + str1.size(),
str2.data(), str2.data() + str2.size()) < 0;
}
std::optional<int> TextOperations::textSearchSimilarityScore(const std::string & s, const std::string & t)
{
static const std::locale loc = boost::locale::generator().generate(getLocaleName());

View File

@@ -80,14 +80,7 @@ namespace TextOperations
DLL_LINKAGE std::string getLocaleName();
/// Compares two strings using locale-aware collation based on the selected game language.
DLL_LINKAGE inline bool compareLocalizedStrings(std::string_view str1, std::string_view str2)
{
static const std::locale loc(getLocaleName());
static const std::collate<char> & col = std::use_facet<std::collate<char>>(loc);
return col.compare(str1.data(), str1.data() + str1.size(),
str2.data(), str2.data() + str2.size()) < 0;
}
DLL_LINKAGE bool compareLocalizedStrings(std::string_view str1, std::string_view str2);
/// Check if texts have similarity when typing into search boxes
/// 0 -> Exact match or starts with typed-in text, 1 -> Close match or substring match,