diff --git a/pcsx2-qt/GameList/GameListModel.cpp b/pcsx2-qt/GameList/GameListModel.cpp index 075199a0f6..595f7c7894 100644 --- a/pcsx2-qt/GameList/GameListModel.cpp +++ b/pcsx2-qt/GameList/GameListModel.cpp @@ -438,7 +438,7 @@ bool GameListModel::titlesLessThan(int left_row, int right_row) const const GameList::Entry* left = GameList::GetEntryByIndex(left_row); const GameList::Entry* right = GameList::GetEntryByIndex(right_row); - return (StringUtil::Strcasecmp(left->GetTitleSort().c_str(), right->GetTitleSort().c_str()) < 0); + return QtHost::LocaleSensitiveCompare(QString::fromStdString(left->GetTitleSort()), QString::fromStdString(right->GetTitleSort())) < 0; } bool GameListModel::lessThan(const QModelIndex& left_index, const QModelIndex& right_index, int column) const diff --git a/pcsx2-qt/QtHost.h b/pcsx2-qt/QtHost.h index 959ba3df59..5f88aaafdd 100644 --- a/pcsx2-qt/QtHost.h +++ b/pcsx2-qt/QtHost.h @@ -283,4 +283,7 @@ namespace QtHost /// VM state, safe to access on UI thread. bool IsVMValid(); bool IsVMPaused(); + + /// Compare strings in the locale of the current UI language + int LocaleSensitiveCompare(QStringView lhs, QStringView rhs); } // namespace QtHost diff --git a/pcsx2-qt/Translations.cpp b/pcsx2-qt/Translations.cpp index f2599b42f2..8b949ec6ed 100644 --- a/pcsx2-qt/Translations.cpp +++ b/pcsx2-qt/Translations.cpp @@ -66,6 +66,9 @@ namespace QtHost static const GlyphInfo* GetGlyphInfo(const std::string_view& language); static std::vector s_glyph_ranges; + + static QLocale s_current_locale; + static QCollator s_current_collator; } // namespace QtHost static std::vector s_translators; @@ -112,6 +115,11 @@ void QtHost::InstallTranslator() if (language == QStringLiteral("system")) language = getSystemLanguage(); + QString qlanguage = language; + qlanguage.replace('-', '_'); + s_current_locale = QLocale(qlanguage); + s_current_collator = QCollator(s_current_locale); + // Install the base qt translation first. #ifdef __APPLE__ const QString base_dir = QStringLiteral("%1/../Resources/translations").arg(qApp->applicationDirPath()); @@ -375,3 +383,8 @@ const QtHost::GlyphInfo* QtHost::GetGlyphInfo(const std::string_view& language) return nullptr; } + +int QtHost::LocaleSensitiveCompare(QStringView lhs, QStringView rhs) +{ + return s_current_collator.compare(lhs, rhs); +}