Skip to content

Commit

Permalink
Qt: Fix loading of base translations for two-code locale
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Sep 17, 2023
1 parent b2789be commit c2a7fba
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pcsx2-qt/Translations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,22 @@ void QtHost::InstallTranslator()
#else
const QString base_dir = QStringLiteral("%1/translations").arg(qApp->applicationDirPath());
#endif
QString base_path = QStringLiteral("%1/qt_%2.qm").arg(base_dir).arg(language);

// Qt base uses underscores instead of hyphens.
const QString qt_language = QString(language).replace(QChar('-'), QChar('_'));
QString base_path = QStringLiteral("%1/qt_%2.qm").arg(base_dir).arg(qt_language);
bool has_base_ts = QFile::exists(base_path);
if (!has_base_ts)
{
// Try without the country suffix.
const int index = language.indexOf('-');
const int index = language.lastIndexOf('-');
if (index > 0)
{
base_path = QStringLiteral("%1/qt_%2.qm").arg(base_dir).arg(language.left(index));
has_base_ts = QFile::exists(base_path);
}
}

if (has_base_ts)
{
QTranslator* base_translator = new QTranslator(qApp);
Expand Down

0 comments on commit c2a7fba

Please sign in to comment.