[qt] fix translations (#2773)

Linguist strongly dislikes lookup tables of this sort due to the fact
that it looks for tr(), qsTr(), etc. when determining what strings need
translations. However, it does provide QT_TR_NOOP which marks the
string for translation *without* running the translation, which is designed
to allow for static or constexpr lookup tables. So let's use that.

Signed-off-by: crueter <crueter@eden-emu.dev>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2773
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
This commit is contained in:
crueter 2025-10-18 22:19:06 +02:00
parent b330117a14
commit a53823646c
No known key found for this signature in database
GPG key ID: 425ACD2D4830EBC6
11 changed files with 234 additions and 193 deletions

View file

@ -10,7 +10,7 @@
using namespace Common::FS;
typedef struct Emulator {
const char *name;
const char *m_name;
LegacyPath e_user_dir;
LegacyPath e_config_dir;
@ -28,23 +28,19 @@ typedef struct Emulator {
return Common::FS::GetLegacyPath(e_cache_dir).string();
}
const std::string lower_name() const {
std::string lower_name{name};
std::transform(lower_name.begin(), lower_name.end(), lower_name.begin(),
[](unsigned char c){ return std::tolower(c); });
const QString name() const { return QObject::tr(m_name);
}
return lower_name;
const QString lower_name() const { return name().toLower();
}
} Emulator;
#define EMU(name) Emulator{#name, name##Dir, name##ConfigDir, name##CacheDir}
static constexpr std::array<Emulator, 4> legacy_emus = {
EMU(Citron),
EMU(Sudachi),
EMU(Suyu),
EMU(Yuzu),
Emulator{QT_TR_NOOP("Citron"), CitronDir, CitronConfigDir, CitronCacheDir},
Emulator{QT_TR_NOOP("Sudachi"), SudachiDir, SudachiConfigDir, SudachiCacheDir},
Emulator{QT_TR_NOOP("Suyu"), SuyuDir, SuyuConfigDir, SuyuCacheDir},
Emulator{QT_TR_NOOP("Yuzu"), YuzuDir, YuzuConfigDir, YuzuCacheDir},
};
#undef EMU
class MigrationWorker : public QObject
{