i18n: fix typo in sorting entries

This commit is contained in:
EvilLary 2025-11-30 02:54:18 +03:00
parent a64517c236
commit 287e3105a2
No known key found for this signature in database
GPG key ID: A4C53FA13FA3E63B
2 changed files with 4 additions and 2 deletions

View file

@ -131,7 +131,7 @@ std::string CI18nEngine::localizeEntry(const std::string& locale, uint64_t key,
return std::string{rawStr};
// build the new string. First, sort our entries
std::ranges::sort(rangesFound, [](const auto& a, const auto& b) { return a.begin - b.begin; });
std::ranges::sort(rangesFound, [](const auto& a, const auto& b) { return a.begin < b.begin; });
// calc the size
size_t stringLen = 0;

View file

@ -75,4 +75,6 @@ TEST(I18n, Engine) {
EXPECT_EQ(engine.localizeEntry("ts", 42069 /* invalid key */, {{"count", "1"}}), "");
EXPECT_EQ(engine.localizeEntry("ts_TST", TXT_KEY_FALLBACK, {{"var1", "hi"}, {"var2", "!"}}), "Hello hi world !");
}
// Order shouldn't matter
EXPECT_EQ(engine.localizeEntry("ts_TST", TXT_KEY_FALLBACK, {{"var2", "!"}, {"var1", "hi"}}), "Hello hi world !");
}