From 7b7f09f0a06a20f040a3edb04995626cfb4d6881 Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Wed, 4 Dec 2024 01:01:48 +0200 Subject: [PATCH 1/5] Translation PoC --- CMakeLists.txt | 20 +- docs/translations/el.ts | 728 ++++++++++++++++++++++++++++++++++ docs/translations/en.ts | 730 +++++++++++++++++++++++++++++++++++ src/panda_qt/main_window.cpp | 25 ++ 4 files changed, 1502 insertions(+), 1 deletion(-) create mode 100644 docs/translations/el.ts create mode 100644 docs/translations/en.ts diff --git a/CMakeLists.txt b/CMakeLists.txt index 224fea7c0..42a5d4029 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -637,7 +637,7 @@ if(NOT BUILD_HYDRA_CORE AND NOT BUILD_LIBRETRO_CORE) add_executable(Alber) if(ENABLE_QT_GUI) - find_package(Qt6 REQUIRED COMPONENTS Widgets) + find_package(Qt6 REQUIRED COMPONENTS Widgets LinguistTools) if(NOT ENABLE_OPENGL) message(FATAL_ERROR "Qt frontend requires OpenGL") endif() @@ -700,6 +700,24 @@ if(NOT BUILD_HYDRA_CORE AND NOT BUILD_LIBRETRO_CORE) docs/img/sparkling_icon.png docs/img/battery_icon.png docs/img/sdcard_icon.png docs/img/rnap_icon.png docs/img/rcow_icon.png docs/img/skyemu_icon.png ) + + set(QT_TRANSLATIONS "${PROJECT_SOURCE_DIR}/docs/translations") + file(GLOB_RECURSE TRANSLATIONS_TS ${QT_TRANSLATIONS}/*.ts) + + set_source_files_properties(${TRANSLATIONS_TS} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/translations") + qt_add_translation(TRANSLATIONS_QM ${TRANSLATIONS_TS}) + + set(TRANSLATIONS_QRC ${CMAKE_CURRENT_BINARY_DIR}/translations/translations.qrc) + file(WRITE ${TRANSLATIONS_QRC} "\n") + foreach (QM ${TRANSLATIONS_QM}) + message("${QM}") + get_filename_component(QM_FILE ${QM} NAME) + file(APPEND ${TRANSLATIONS_QRC} "${QM_FILE}\n") + endforeach (QM) + file(APPEND ${TRANSLATIONS_QRC} "") + + qt_add_resources(TRANSLATIONS ${TRANSLATIONS_QRC}) + set(APP_RESOURCES ${APP_RESOURCES} ${TRANSLATIONS}) else() set(FRONTEND_SOURCE_FILES src/panda_sdl/main.cpp src/panda_sdl/frontend_sdl.cpp src/panda_sdl/mappings.cpp) set(FRONTEND_HEADER_FILES "include/panda_sdl/frontend_sdl.hpp") diff --git a/docs/translations/el.ts b/docs/translations/el.ts new file mode 100644 index 000000000..241f2bff8 --- /dev/null +++ b/docs/translations/el.ts @@ -0,0 +1,728 @@ + + + AboutWindow + + + About Panda3DS + + + + + Panda3DS is a free and open source Nintendo 3DS emulator, for Windows, MacOS and Linux + + + + + Visit panda3ds.com for help with Panda3DS and links to our official support sites. + + + + + Panda3DS is developed by volunteers in their spare time. Below is a list of some of these volunteers who've agreed to be listed here, in no particular order.<br>If you think you should be listed here too, please inform us<br><br>- Peach (wheremyfoodat)<br>- noumidev<br>- liuk707<br>- Wunk<br>- marysaka<br>- Sky<br>- merryhime<br>- TGP17<br>- Shadow<br> + + + + + CheatEditDialog + + + Edit Cheat + + + + + Cheat name + + + + + CheatEntryWidget + + + Edit + + + + + CheatsWindow + + + Cheats + + + + + Add + + + + + Remove + + + + + ConfigWindow + + + Configuration + + + + + Interface Settings + + + + + System + + + + + Light + + + + + Dark + + + + + Greetings Cat + + + + + Cream + + + + + Color theme + + + + + Happy panda + + + + + Happy panda (colourful) + + + + + Sleepy panda + + + + + Cow panda + + + + + The penguin from SkyEmu + + + + + Window icon + + + + + Show version on window title + + + + + Remember window position + + + + + General Settings + + + + + Browse... + + + + + Select Directory + + + + + Default ROMs path + + + + + Enable Discord RPC + + + + + Use portable build + + + + + Print version in console output + + + + + Graphics Settings + + + + + + Null + + + + + OpenGL + + + + + Vulkan + + + + + GPU renderer + + + + + Enable Renderdoc + + + + + Enable shader JIT + + + + + Enable VSync + + + + + Use ubershaders (No stutter, maybe slower) + + + + + Accurate shader multiplication + + + + + Accelerate shaders + + + + + Force shadergen when rendering lights + + + + + Light threshold for forcing shadergen + + + + + Audio Settings + + + + + LLE + + + + + HLE + + + + + DSP emulation + + + + + Enable audio + + + + + Enable AAC audio + + + + + Print DSP firmware + + + + + Mute audio device + + + + + Cubic + + + + + Linear + + + + + Volume curve + + + + + Audio device volume + + + + + Battery Settings + + + + + Battery percentage + + + + + Charger plugged + + + + + SD Card Settings + + + + + Enable virtual SD card + + + + + Write protect virtual SD card + + + + + Interface + + + + + User Interface settings + + + + + General + + + + + General emulator settings + + + + + Graphics + Γραφικά + + + + Graphics emulation and output settings + + + + + Audio + Ήχος + + + + Audio emulation and output settings + + + + + Battery + + + + + Battery emulation settings + + + + + SD Card + + + + + SD Card emulation settings + + + + + MainWindow + + + Alber + Αλβέρτος + + + + File + + + + + Emulation + + + + + Tools + + + + + About + + + + + Load game + + + + + Load Lua script + + + + + Open Panda3DS folder + + + + + Pause + + + + + Resume + + + + + Reset + + + + + Configure + + + + + Dump RomFS + + + + + Open Lua Editor + + + + + Open Cheats Editor + + + + + Open Patch Window + + + + + Open Shader Editor + + + + + Dump loaded DSP firmware + + + + + About Panda3DS + + + + + Select 3DS ROM to load + + + + + Nintendo 3DS ROMs (*.3ds *.cci *.cxi *.app *.ncch *.3dsx *.elf *.axf) + + + + + Select Lua script to load + + + + + Lua scripts (*.lua *.txt) + + + + + Select folder to dump RomFS files to + + + + + Invalid format for RomFS dumping + + + + + The currently loaded app is not in a format that supports RomFS + + + + + + + OK + + + + + No RomFS found + + + + + No RomFS partition was found in the loaded app + + + + + Select file + + + + + DSP firmware file (*.cdc) + + + + + No DSP firmware loaded + + + + + The currently loaded app has not uploaded a firmware to the DSP + + + + + Failed to open output file + + + + + The currently loaded DSP firmware could not be written to the selected file. Please make sure you have permission to access this file + + + + + PatchWindow + + + ROM patcher + + + + + Select input file + + + + + + Select + + + + + + Select patch file + + + + + Apply patch + + + + + Select file to patch + + + + + + All files (*.*) + + + + + Patch files (*.ips *.ups *.bps) + + + + + Paths not provided correctly + + + + + Please provide paths for both the input file and the patch file + + + + + Select file + + + + + No output path + + + + + No path was provided for the output file, no patching was done + + + + + Unknown patch format + + + + + Unknown format for patch file. Currently IPS, UPS and BPS are supported + + + + + Failed to open input files + + + + + Make sure they're in a directory Panda3DS has access to + + + + + Patching Success + + + + + Your file was patched successfully. + + + + + Checksum mismatch + + + + + Patch was applied successfully but a checksum mismatch was detected. The input or output files might not be correct + + + + + Patching error + + + + + An error occured while patching + + + + + PatchWindow::PatchWindow + + + OK + + + + + ShaderEditorWindow + + + Reload shader + + + + + TextEditorWindow + + + Lua Editor + + + + + Load script + + + + \ No newline at end of file diff --git a/docs/translations/en.ts b/docs/translations/en.ts new file mode 100644 index 000000000..e28dcd7b1 --- /dev/null +++ b/docs/translations/en.ts @@ -0,0 +1,730 @@ + + + + + AboutWindow + + + About Panda3DS + + + + + Panda3DS is a free and open source Nintendo 3DS emulator, for Windows, MacOS and Linux + + + + + Visit panda3ds.com for help with Panda3DS and links to our official support sites. + + + + + Panda3DS is developed by volunteers in their spare time. Below is a list of some of these volunteers who've agreed to be listed here, in no particular order.<br>If you think you should be listed here too, please inform us<br><br>- Peach (wheremyfoodat)<br>- noumidev<br>- liuk707<br>- Wunk<br>- marysaka<br>- Sky<br>- merryhime<br>- TGP17<br>- Shadow<br> + + + + + CheatEditDialog + + + Edit Cheat + + + + + Cheat name + + + + + CheatEntryWidget + + + Edit + + + + + CheatsWindow + + + Cheats + + + + + Add + + + + + Remove + + + + + ConfigWindow + + + Configuration + + + + + Interface Settings + + + + + System + + + + + Light + + + + + Dark + + + + + Greetings Cat + + + + + Cream + + + + + Color theme + + + + + Happy panda + + + + + Happy panda (colourful) + + + + + Sleepy panda + + + + + Cow panda + + + + + The penguin from SkyEmu + + + + + Window icon + + + + + Show version on window title + + + + + Remember window position + + + + + General Settings + + + + + Browse... + + + + + Select Directory + + + + + Default ROMs path + + + + + Enable Discord RPC + + + + + Use portable build + + + + + Print version in console output + + + + + Graphics Settings + + + + + + Null + + + + + OpenGL + + + + + Vulkan + + + + + GPU renderer + + + + + Enable Renderdoc + + + + + Enable shader JIT + + + + + Enable VSync + + + + + Use ubershaders (No stutter, maybe slower) + + + + + Accurate shader multiplication + + + + + Accelerate shaders + + + + + Force shadergen when rendering lights + + + + + Light threshold for forcing shadergen + + + + + Audio Settings + + + + + LLE + + + + + HLE + + + + + DSP emulation + + + + + Enable audio + + + + + Enable AAC audio + + + + + Print DSP firmware + + + + + Mute audio device + + + + + Cubic + + + + + Linear + + + + + Volume curve + + + + + Audio device volume + + + + + Battery Settings + + + + + Battery percentage + + + + + Charger plugged + + + + + SD Card Settings + + + + + Enable virtual SD card + + + + + Write protect virtual SD card + + + + + Interface + + + + + User Interface settings + + + + + General + + + + + General emulator settings + + + + + Graphics + + + + + Graphics emulation and output settings + + + + + Audio + + + + + Audio emulation and output settings + + + + + Battery + + + + + Battery emulation settings + + + + + SD Card + + + + + SD Card emulation settings + + + + + MainWindow + + + Alber + + + + + File + + + + + Emulation + + + + + Tools + + + + + About + + + + + Load game + + + + + Load Lua script + + + + + Open Panda3DS folder + + + + + Pause + + + + + Resume + + + + + Reset + + + + + Configure + + + + + Dump RomFS + + + + + Open Lua Editor + + + + + Open Cheats Editor + + + + + Open Patch Window + + + + + Open Shader Editor + + + + + Dump loaded DSP firmware + + + + + About Panda3DS + + + + + Select 3DS ROM to load + + + + + Nintendo 3DS ROMs (*.3ds *.cci *.cxi *.app *.ncch *.3dsx *.elf *.axf) + + + + + Select Lua script to load + + + + + Lua scripts (*.lua *.txt) + + + + + Select folder to dump RomFS files to + + + + + Invalid format for RomFS dumping + + + + + The currently loaded app is not in a format that supports RomFS + + + + + + + OK + + + + + No RomFS found + + + + + No RomFS partition was found in the loaded app + + + + + Select file + + + + + DSP firmware file (*.cdc) + + + + + No DSP firmware loaded + + + + + The currently loaded app has not uploaded a firmware to the DSP + + + + + Failed to open output file + + + + + The currently loaded DSP firmware could not be written to the selected file. Please make sure you have permission to access this file + + + + + PatchWindow + + + ROM patcher + + + + + Select input file + + + + + + Select + + + + + + Select patch file + + + + + Apply patch + + + + + Select file to patch + + + + + + All files (*.*) + + + + + Patch files (*.ips *.ups *.bps) + + + + + Paths not provided correctly + + + + + Please provide paths for both the input file and the patch file + + + + + Select file + + + + + No output path + + + + + No path was provided for the output file, no patching was done + + + + + Unknown patch format + + + + + Unknown format for patch file. Currently IPS, UPS and BPS are supported + + + + + Failed to open input files + + + + + Make sure they're in a directory Panda3DS has access to + + + + + Patching Success + + + + + Your file was patched successfully. + + + + + Checksum mismatch + + + + + Patch was applied successfully but a checksum mismatch was detected. The input or output files might not be correct + + + + + Patching error + + + + + An error occured while patching + + + + + PatchWindow::PatchWindow + + + OK + + + + + ShaderEditorWindow + + + Reload shader + + + + + TextEditorWindow + + + Lua Editor + + + + + Load script + + + + diff --git a/src/panda_qt/main_window.cpp b/src/panda_qt/main_window.cpp index 5af31d737..14ea19b05 100644 --- a/src/panda_qt/main_window.cpp +++ b/src/panda_qt/main_window.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -78,6 +79,30 @@ MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent) emu = new Emulator(); emu->setOutputSize(screen->surfaceWidth, screen->surfaceHeight); + QTranslator* translator = nullptr; + auto language = QString::fromStdString("el"); + const QString baseDir = QStringLiteral(":/translations"); + QString basePath = QStringLiteral("%1/%2.qm").arg(baseDir).arg(language); + + if (QFile::exists(basePath)) { + if (translator != nullptr) { + qApp->removeTranslator(translator); + } + + translator = new QTranslator(qApp); + if (!translator->load(basePath)) { + QMessageBox::warning( + nullptr, QStringLiteral("Translation Error"), + QStringLiteral("Failed to find load translation file for '%1':\n%2").arg(language).arg(basePath) + ); + delete translator; + } else { + qApp->installTranslator(translator); + } + } else { + printf("%s does not exist\n", basePath.toStdString().c_str()); + } + // Set up misc objects aboutWindow = new AboutWindow(nullptr); cheatsEditor = new CheatsWindow(emu, {}, this); From 8217316dbf7858970f8eab54eb80d6cf550e588b Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Wed, 4 Dec 2024 02:13:05 +0200 Subject: [PATCH 2/5] i18n but better --- include/panda_qt/main_window.hpp | 1 + src/panda_qt/config_window.cpp | 2 +- src/panda_qt/main_window.cpp | 53 +++++++++++++++++--------------- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/include/panda_qt/main_window.hpp b/include/panda_qt/main_window.hpp index eb1cfb16f..ed54ad84d 100644 --- a/include/panda_qt/main_window.hpp +++ b/include/panda_qt/main_window.hpp @@ -126,6 +126,7 @@ class MainWindow : public QMainWindow { void setupControllerSensors(SDL_GameController* controller); void sendMessage(const EmulatorMessage& message); void dispatchMessage(const EmulatorMessage& message); + void loadTranslation(); // Tracks whether we are using an OpenGL-backed renderer or a Vulkan-backed renderer bool usingGL = false; diff --git a/src/panda_qt/config_window.cpp b/src/panda_qt/config_window.cpp index 7f42acab9..549f89902 100644 --- a/src/panda_qt/config_window.cpp +++ b/src/panda_qt/config_window.cpp @@ -103,7 +103,7 @@ ConfigWindow::ConfigWindow(ConfigCallback configCallback, MainWindowCallback win updateConfig(); // Update main window title - getMainWindow()->setWindowTitle(checked ? "Alber v" PANDA3DS_VERSION : "Alber"); + getMainWindow()->setWindowTitle(checked ? tr("Alber v%1").arg(PANDA3DS_VERSION) : tr("Alber")); }); connectCheckbox(showAppVersion, config.windowSettings.showAppVersion); guiLayout->addRow(showAppVersion); diff --git a/src/panda_qt/main_window.cpp b/src/panda_qt/main_window.cpp index 14ea19b05..c3a04f884 100644 --- a/src/panda_qt/main_window.cpp +++ b/src/panda_qt/main_window.cpp @@ -15,6 +15,7 @@ #include "version.hpp" MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent), keyboardMappings(InputMappings::defaultKeyboardMappings()) { + loadTranslation(); setWindowTitle(tr("Alber")); // Enable drop events for loading ROMs @@ -79,30 +80,6 @@ MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent) emu = new Emulator(); emu->setOutputSize(screen->surfaceWidth, screen->surfaceHeight); - QTranslator* translator = nullptr; - auto language = QString::fromStdString("el"); - const QString baseDir = QStringLiteral(":/translations"); - QString basePath = QStringLiteral("%1/%2.qm").arg(baseDir).arg(language); - - if (QFile::exists(basePath)) { - if (translator != nullptr) { - qApp->removeTranslator(translator); - } - - translator = new QTranslator(qApp); - if (!translator->load(basePath)) { - QMessageBox::warning( - nullptr, QStringLiteral("Translation Error"), - QStringLiteral("Failed to find load translation file for '%1':\n%2").arg(language).arg(basePath) - ); - delete translator; - } else { - qApp->installTranslator(translator); - } - } else { - printf("%s does not exist\n", basePath.toStdString().c_str()); - } - // Set up misc objects aboutWindow = new AboutWindow(nullptr); cheatsEditor = new CheatsWindow(emu, {}, this); @@ -704,3 +681,31 @@ void MainWindow::setupControllerSensors(SDL_GameController* controller) { SDL_GameControllerSetSensorEnabled(controller, SDL_SENSOR_ACCEL, SDL_TRUE); } } + +void MainWindow::loadTranslation() { + // TODO: This should become a member variable when we allow changing language at runtime. + QTranslator* translator = nullptr; + + auto language = QString::fromStdString("el"); + const QString baseDir = QStringLiteral(":/translations"); + QString basePath = QStringLiteral("%1/%2.qm").arg(baseDir).arg(language); + + if (QFile::exists(basePath)) { + if (translator != nullptr) { + qApp->removeTranslator(translator); + } + + translator = new QTranslator(qApp); + if (!translator->load(basePath)) { + QMessageBox::warning( + nullptr, QStringLiteral("Translation Error"), + QStringLiteral("Failed to find load translation file for '%1':\n%2").arg(language).arg(basePath) + ); + delete translator; + } else { + qApp->installTranslator(translator); + } + } else { + printf("Language file %s does not exist\n", basePath.toStdString().c_str()); + } +} \ No newline at end of file From b4d212c51036828fd950b389e58478c9646807fd Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Wed, 4 Dec 2024 02:41:44 +0200 Subject: [PATCH 3/5] More Greek translation --- docs/translations/el.ts | 284 +++++++++++++++++++++------------------- docs/translations/en.ts | 84 ++++++------ 2 files changed, 194 insertions(+), 174 deletions(-) diff --git a/docs/translations/el.ts b/docs/translations/el.ts index 241f2bff8..6473258b7 100644 --- a/docs/translations/el.ts +++ b/docs/translations/el.ts @@ -4,17 +4,17 @@ About Panda3DS - + Σχετικά με το Panda3DS Panda3DS is a free and open source Nintendo 3DS emulator, for Windows, MacOS and Linux - + Τo Panda3DS είναι ένας δωρεάν και open source εξομοιωτής του Nintendo 3DS, για Windows, MacOS και Linux Visit panda3ds.com for help with Panda3DS and links to our official support sites. - + Επισκεφτείται το panda3ds.com για βοήθεια με το Panda3DS και συνδέσμους στις επίσημες σελίδες υποστήριξης μας. @@ -27,12 +27,12 @@ Edit Cheat - + Επεξεργασία Κωδικού Cheat name - + Όνομα κωδικού @@ -40,7 +40,7 @@ Edit - + Επεξεργασία @@ -48,17 +48,17 @@ Cheats - + Κωδικοί Add - + Προσθήκη Remove - + Αφαίρεση @@ -66,128 +66,138 @@ Configuration - + Ρυθμίσεις Interface Settings - + Ρυθμίσεις Διεπαφής System - + Σύστημα Light - + Φωτεινό Dark - + Σκοτεινό Greetings Cat - + Γεια Σου Γάτα Cream - + Κρέμα Color theme - + Χρώματα Happy panda - + Χαρούμενο Πάντα Happy panda (colourful) - + Χαρούμενο Πάντα (χρωματιστό) Sleepy panda - + Πάντα που νυστάζει Cow panda - + Αγελάδα πάντα The penguin from SkyEmu - + Ο πιγκουίνος από το SkyEmu Window icon - + Εικονίδιο Παραθύρου Show version on window title - + Εμφάνιση έκδοσης στον τίτλο του παραθύρου + + + + Alber v%1 + Αλβέρτος v%1 + + + + Alber + Αλβέρτος Remember window position - + Αποθήκευση θέσης παραθύρου General Settings - + Γενικές Ρυθμίσεις Browse... - + Περιήγηση Select Directory - + Επιλογή φακέλου Default ROMs path - + Προεπιλεγμένος φάκελος ROM Enable Discord RPC - + Ενεργοποίηση Discord RPC Use portable build - + Ενεργοποίηση φορητής εγκατάστασης Print version in console output - + Εκτύπωση έκδοσης στην κονσόλα Graphics Settings - + Ρυθμίσεις Γραφικών Null - + Κανένα @@ -202,52 +212,52 @@ GPU renderer - + Πυρήνας GPU Enable Renderdoc - + Ενεργοποίηση Renderdoc Enable shader JIT - + Ενεργοποίηση μεταγλωττιστή shaders Enable VSync - + Ενεργοποίηση VSync Use ubershaders (No stutter, maybe slower) - + Χρήση ubershaders (Χωρίς stutter, ίσως πιο αργό) Accurate shader multiplication - + Ακριβής πολλαπλασιασμός στα shaders Accelerate shaders - + Επιτάχυνση shaders Force shadergen when rendering lights - + Εξαναγκασμός shadergen όταν υπάρχουν φώτα Light threshold for forcing shadergen - + Αριθμός φωτών για εξαναγκασμό shadergen Audio Settings - + Ρυθμίσεις Ήχου @@ -262,97 +272,97 @@ DSP emulation - + Εξομοίωση DSP Enable audio - + Ενεργοποίηση ήχου Enable AAC audio - + Ενεργοποίηση ήχου AAC Print DSP firmware - + Εκτύπωση λογισμικού DSP Mute audio device - + Σίγαση συσκευής ήχου Cubic - + Κυβική Linear - + Γραμμική Volume curve - + Κλίμακα ήχου Audio device volume - + Ένταση ήχου Battery Settings - + Ρυθμίσεις μπαταρίας Battery percentage - + Ποσοστό μπαταρίας Charger plugged - + Φορτιστής SD Card Settings - + Ρυθμίσης κάρτας SD Enable virtual SD card - + Ενεργοποίηση εικονικής SD Write protect virtual SD card - + Προστασία της SD από εγγραφή Interface - + Διεπαφή User Interface settings - + Ρυθμίσεις διεπαφής General - + Γενικά General emulator settings - + Γενικές ρυθμίσεις εξομοιωτή @@ -362,7 +372,7 @@ Graphics emulation and output settings - + Ρυθμίσεις εξομοίωσης γραφικών @@ -372,205 +382,205 @@ Audio emulation and output settings - + Ρυθμίσεις εξομοίωσης ήχου Battery - + Μπαταρία Battery emulation settings - + Ρυθμίσεις εξομοίωσης μπαταρίας SD Card - + Κάρτα SD SD Card emulation settings - + Ρυθμίσεις εξομοίωσης κάρτας SD MainWindow - + Alber Αλβέρτος - + File - + Αρχείο - + Emulation - + Εξομοίωση - + Tools - + Εργαλεία - + About - + Σχετικά - + Load game - + Φόρτωση παιχνιδιού - + Load Lua script - + Φόρτωση αρχείου Lua - + Open Panda3DS folder - + Άνοιγμα φακέλου Panda3DS - + Pause - + Παύση - + Resume - + Συνέχεια - + Reset - + Επανέναρξη - + Configure - + Ρύθμιση - + Dump RomFS - + Open Lua Editor - + Άνοιγμα Lua Editor - + Open Cheats Editor - + Άνοιγμα Editor κωδικών - + Open Patch Window - + Άνοιγμα παραθύρου για patching - + Open Shader Editor - + Dump loaded DSP firmware - + About Panda3DS - + Σχετικά με το Panda3DS - + Select 3DS ROM to load - + Επιλέξτε 3DS ROM για να φορτώσετε - + Nintendo 3DS ROMs (*.3ds *.cci *.cxi *.app *.ncch *.3dsx *.elf *.axf) - + Select Lua script to load - + Επιλέξτε αρχείο Lua για να φορτώσετε - + Lua scripts (*.lua *.txt) - + Select folder to dump RomFS files to - + Invalid format for RomFS dumping - + The currently loaded app is not in a format that supports RomFS - - - + + + OK - + ΟΚ - + No RomFS found - + Δεν βρέθηκε RomFS - + No RomFS partition was found in the loaded app - + Select file - + Επιλέξτε αρχείο - + DSP firmware file (*.cdc) - + No DSP firmware loaded - + The currently loaded app has not uploaded a firmware to the DSP - + Failed to open output file - + The currently loaded DSP firmware could not be written to the selected file. Please make sure you have permission to access this file @@ -585,35 +595,35 @@ Select input file - + Επιλογή αρχείου εισόδου Select - + Επιλέξτε Select patch file - + Επιλογή αρχείου patch Apply patch - + Εφαρμογή patch Select file to patch - + Επιλέξτε αρχείο να κάνετε patch All files (*.*) - + Όλα τα αρχεία (*.*) @@ -633,7 +643,7 @@ Select file - + Επιλογή αρχείου @@ -668,12 +678,12 @@ Patching Success - + Επιτυχής Εφαρμογή Patch Your file was patched successfully. - + To αρχείο σας έγινε patch με επιτυχία @@ -701,7 +711,7 @@ OK - + ΟΚ @@ -722,7 +732,7 @@ Load script - + Φόρτωση αρχείου \ No newline at end of file diff --git a/docs/translations/en.ts b/docs/translations/en.ts index e28dcd7b1..258089abd 100644 --- a/docs/translations/en.ts +++ b/docs/translations/en.ts @@ -140,6 +140,16 @@ Show version on window title + + + Alber v%1 + + + + + Alber + + Remember window position @@ -400,179 +410,179 @@ MainWindow - + Alber - + File - + Emulation - + Tools - + About - + Load game - + Load Lua script - + Open Panda3DS folder - + Pause - + Resume - + Reset - + Configure - + Dump RomFS - + Open Lua Editor - + Open Cheats Editor - + Open Patch Window - + Open Shader Editor - + Dump loaded DSP firmware - + About Panda3DS - + Select 3DS ROM to load - + Nintendo 3DS ROMs (*.3ds *.cci *.cxi *.app *.ncch *.3dsx *.elf *.axf) - + Select Lua script to load - + Lua scripts (*.lua *.txt) - + Select folder to dump RomFS files to - + Invalid format for RomFS dumping - + The currently loaded app is not in a format that supports RomFS - - - + + + OK - + No RomFS found - + No RomFS partition was found in the loaded app - + Select file - + DSP firmware file (*.cdc) - + No DSP firmware loaded - + The currently loaded app has not uploaded a firmware to the DSP - + Failed to open output file - + The currently loaded DSP firmware could not be written to the selected file. Please make sure you have permission to access this file From 59016c2ffd05f675bd58b65add3beae5f22cff49 Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Wed, 4 Dec 2024 20:20:52 +0200 Subject: [PATCH 4/5] Add proper translation UI --- CMakeLists.txt | 6 +- docs/translations/el.ts | 203 ++++++++++++++++------------- docs/translations/en.ts | 174 ++++++++++++++----------- include/frontend_settings.hpp | 1 + include/panda_qt/config_window.hpp | 2 + src/config.cpp | 2 + src/panda_qt/config_window.cpp | 5 +- src/panda_qt/main_window.cpp | 32 +---- src/panda_qt/translations.cpp | 91 +++++++++++++ 9 files changed, 319 insertions(+), 197 deletions(-) create mode 100644 src/panda_qt/translations.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 42a5d4029..4f3883c1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -647,7 +647,7 @@ if(NOT BUILD_HYDRA_CORE AND NOT BUILD_LIBRETRO_CORE) set(FRONTEND_SOURCE_FILES src/panda_qt/main.cpp src/panda_qt/screen.cpp src/panda_qt/main_window.cpp src/panda_qt/about_window.cpp src/panda_qt/config_window.cpp src/panda_qt/zep.cpp src/panda_qt/text_editor.cpp src/panda_qt/cheats_window.cpp src/panda_qt/mappings.cpp - src/panda_qt/patch_window.cpp src/panda_qt/elided_label.cpp src/panda_qt/shader_editor.cpp + src/panda_qt/patch_window.cpp src/panda_qt/elided_label.cpp src/panda_qt/shader_editor.cpp src/panda_qt/translations.cpp ) set(FRONTEND_HEADER_FILES include/panda_qt/screen.hpp include/panda_qt/main_window.hpp include/panda_qt/about_window.hpp include/panda_qt/config_window.hpp include/panda_qt/text_editor.hpp include/panda_qt/cheats_window.hpp @@ -701,8 +701,8 @@ if(NOT BUILD_HYDRA_CORE AND NOT BUILD_LIBRETRO_CORE) docs/img/rnap_icon.png docs/img/rcow_icon.png docs/img/skyemu_icon.png ) - set(QT_TRANSLATIONS "${PROJECT_SOURCE_DIR}/docs/translations") - file(GLOB_RECURSE TRANSLATIONS_TS ${QT_TRANSLATIONS}/*.ts) + # Translation files in Qt's .ts format. Will be converted into binary files and embedded into the executable + set(TRANSLATIONS_TS docs/translations/en.ts docs/translations/el.ts) set_source_files_properties(${TRANSLATIONS_TS} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/translations") qt_add_translation(TRANSLATIONS_QM ${TRANSLATIONS_TS}) diff --git a/docs/translations/el.ts b/docs/translations/el.ts index 6473258b7..0368d8bda 100644 --- a/docs/translations/el.ts +++ b/docs/translations/el.ts @@ -134,371 +134,396 @@ Εικονίδιο Παραθύρου - + + Language + Γλώσσα + + + Show version on window title Εμφάνιση έκδοσης στον τίτλο του παραθύρου - + Alber v%1 Αλβέρτος v%1 - + Alber Αλβέρτος - + Remember window position Αποθήκευση θέσης παραθύρου - + General Settings Γενικές Ρυθμίσεις - + Browse... Περιήγηση - + Select Directory Επιλογή φακέλου - + Default ROMs path Προεπιλεγμένος φάκελος ROM - + Enable Discord RPC Ενεργοποίηση Discord RPC - + Use portable build Ενεργοποίηση φορητής εγκατάστασης - + Print version in console output Εκτύπωση έκδοσης στην κονσόλα - + Graphics Settings Ρυθμίσεις Γραφικών - - + + Null Κανένα - + OpenGL - + Vulkan - + GPU renderer Πυρήνας GPU - + Enable Renderdoc Ενεργοποίηση Renderdoc - + Enable shader JIT Ενεργοποίηση μεταγλωττιστή shaders - + Enable VSync Ενεργοποίηση VSync - + Use ubershaders (No stutter, maybe slower) Χρήση ubershaders (Χωρίς stutter, ίσως πιο αργό) - + Accurate shader multiplication Ακριβής πολλαπλασιασμός στα shaders - + Accelerate shaders Επιτάχυνση shaders - + Force shadergen when rendering lights Εξαναγκασμός shadergen όταν υπάρχουν φώτα - + Light threshold for forcing shadergen Αριθμός φωτών για εξαναγκασμό shadergen - + Audio Settings Ρυθμίσεις Ήχου - + LLE - + HLE - + DSP emulation Εξομοίωση DSP - + Enable audio Ενεργοποίηση ήχου - + Enable AAC audio Ενεργοποίηση ήχου AAC - + Print DSP firmware Εκτύπωση λογισμικού DSP - + Mute audio device Σίγαση συσκευής ήχου - + Cubic Κυβική - + Linear Γραμμική - + Volume curve Κλίμακα ήχου - + Audio device volume Ένταση ήχου - + Battery Settings Ρυθμίσεις μπαταρίας - + Battery percentage Ποσοστό μπαταρίας - + Charger plugged Φορτιστής - + SD Card Settings Ρυθμίσης κάρτας SD - + Enable virtual SD card Ενεργοποίηση εικονικής SD - + Write protect virtual SD card Προστασία της SD από εγγραφή - + Interface Διεπαφή - + User Interface settings Ρυθμίσεις διεπαφής - + General Γενικά - + General emulator settings Γενικές ρυθμίσεις εξομοιωτή - + Graphics Γραφικά - + Graphics emulation and output settings Ρυθμίσεις εξομοίωσης γραφικών - + Audio Ήχος - + Audio emulation and output settings Ρυθμίσεις εξομοίωσης ήχου - + Battery Μπαταρία - + Battery emulation settings Ρυθμίσεις εξομοίωσης μπαταρίας - + SD Card Κάρτα SD - + SD Card emulation settings Ρυθμίσεις εξομοίωσης κάρτας SD + + + Language change successful + Επιτυχία αλλαγής γλώσσας + + + + Restart Panda3DS for the new language to be used. + Επανεκκινήστε το Panda3DS για να εφαρμοστεί η νέα γλώσσα. + + + + Language change failed + Αποτυχία αλλαγής γλώσσας + + + + The language you selected is not included in Panda3DS. If you're seeing this, someone messed up the language UI code... + Το Panda3DS δεν υποστηρίζει τον γλώσσα που επιλέξατε. Αν το βλέπετε αυτό, κάποιος έκανε λάθος στον κώδικα, κατηγορήστε τον Πάρη... + MainWindow - + Alber Αλβέρτος - + File - Αρχείο + Αρχεία - + Emulation Εξομοίωση - + Tools Εργαλεία - + About Σχετικά - + Load game Φόρτωση παιχνιδιού - + Load Lua script Φόρτωση αρχείου Lua - + Open Panda3DS folder Άνοιγμα φακέλου Panda3DS - + Pause Παύση - + Resume Συνέχεια - + Reset Επανέναρξη - + Configure Ρύθμιση - + Dump RomFS - + Open Lua Editor Άνοιγμα Lua Editor - + Open Cheats Editor Άνοιγμα Editor κωδικών - + Open Patch Window Άνοιγμα παραθύρου για patching - + Open Shader Editor - + Dump loaded DSP firmware - + About Panda3DS Σχετικά με το Panda3DS @@ -552,7 +577,7 @@ No RomFS partition was found in the loaded app - + Δεν βρέθηκε RomFS στην εφαρμογή που έχει φορτωθεί @@ -567,7 +592,7 @@ No DSP firmware loaded - + Δεν έχει φορτωθεί DSP firmware @@ -577,7 +602,7 @@ Failed to open output file - + Αποτυχία ανοίγματος του αρχείου εξόδου @@ -638,7 +663,7 @@ Please provide paths for both the input file and the patch file - + Παρακαλούμε διαλέξτε και αρχείο εισόδου και αρχείο patch @@ -648,32 +673,32 @@ No output path - + Δεν επιλέχθηκε φάκελος εξόδου No path was provided for the output file, no patching was done - + Δεν επιλέχθηκε αρχείο εξόδου. Δεν έγινε patching Unknown patch format - + Άγνωστο είδος patch Unknown format for patch file. Currently IPS, UPS and BPS are supported - + Άγνωστο είδος αρχείου patch. Υποστηρίζονται αρχεία IPS, UPS και BPS Failed to open input files - + Αποτυχία ανοίγματος των αρχείων εισόδου Make sure they're in a directory Panda3DS has access to - + Βεβαιωθείτε ότι είναι σε φάκελο που έχει πρόσβαση το Panda3DS @@ -693,17 +718,17 @@ Patch was applied successfully but a checksum mismatch was detected. The input or output files might not be correct - + Το patch εφαρμόστηκε με επιτυχία αλλά ανιχνεύτηκε σφάλμα στο checksum. Ενδέχεται τα αρχεία εισόδου η εξόδου να είναι λανθασμένα Patching error - + Σφάλμα στο patching An error occured while patching - + Προέκυψε σφάλμα στο patching @@ -719,7 +744,7 @@ Reload shader - + Επαναφόρτωση shader diff --git a/docs/translations/en.ts b/docs/translations/en.ts index 258089abd..4a70fabb3 100644 --- a/docs/translations/en.ts +++ b/docs/translations/en.ts @@ -136,371 +136,397 @@ - + + Language + + + + Show version on window title - + + Alber v%1 - + Alber - + Remember window position - + General Settings - + Browse... - + Select Directory - + Default ROMs path - + Enable Discord RPC - + Use portable build - + Print version in console output - + Graphics Settings - - + + Null - + OpenGL - + Vulkan - + GPU renderer - + Enable Renderdoc - + Enable shader JIT - + Enable VSync - + Use ubershaders (No stutter, maybe slower) - + Accurate shader multiplication - + Accelerate shaders - + Force shadergen when rendering lights - + Light threshold for forcing shadergen - + Audio Settings - + LLE - + HLE - + DSP emulation - + Enable audio - + Enable AAC audio - + Print DSP firmware - + Mute audio device - + Cubic - + Linear - + Volume curve - + Audio device volume - + Battery Settings - + Battery percentage - + Charger plugged - + SD Card Settings - + Enable virtual SD card - + Write protect virtual SD card - + Interface - + User Interface settings - + General - + General emulator settings - + Graphics - + Graphics emulation and output settings - + Audio - + Audio emulation and output settings - + Battery - + Battery emulation settings - + SD Card - + SD Card emulation settings + + + Language change successful + + + + + Restart Panda3DS for the new language to be used. + + + + + Language change failed + + + + + The language you selected is not included in Panda3DS. If you're seeing this, someone messed up the language UI code... + + MainWindow - + Alber - + File - + Emulation - + Tools - + About - + Load game - + Load Lua script - + Open Panda3DS folder - + Pause - + Resume - + Reset - + Configure - + Dump RomFS - + Open Lua Editor - + Open Cheats Editor - + Open Patch Window - + Open Shader Editor - + Dump loaded DSP firmware - + About Panda3DS diff --git a/include/frontend_settings.hpp b/include/frontend_settings.hpp index 1a78ab66f..ae9678792 100644 --- a/include/frontend_settings.hpp +++ b/include/frontend_settings.hpp @@ -24,6 +24,7 @@ struct FrontendSettings { Theme theme = Theme::Dark; WindowIcon icon = WindowIcon::Rpog; + std::string language = "en"; static Theme themeFromString(std::string inString); static const char* themeToString(Theme theme); diff --git a/include/panda_qt/config_window.hpp b/include/panda_qt/config_window.hpp index 9c0037534..1d37a8caa 100644 --- a/include/panda_qt/config_window.hpp +++ b/include/panda_qt/config_window.hpp @@ -45,6 +45,8 @@ class ConfigWindow : public QDialog { void setTheme(FrontendSettings::Theme theme); void setIcon(FrontendSettings::WindowIcon icon); + QComboBox* createLanguageSelect(); + public: ConfigWindow(ConfigCallback configCallback, MainWindowCallback windowCallback, const EmulatorConfig& config, QWidget* parent = nullptr); ~ConfigWindow(); diff --git a/src/config.cpp b/src/config.cpp index fd4d969d4..73b5d6644 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -141,6 +141,7 @@ void EmulatorConfig::load() { frontendSettings.theme = FrontendSettings::themeFromString(toml::find_or(ui, "Theme", "dark")); frontendSettings.icon = FrontendSettings::iconFromString(toml::find_or(ui, "WindowIcon", "rpog")); + frontendSettings.language = toml::find_or(ui, "Language", "en"); } } } @@ -202,6 +203,7 @@ void EmulatorConfig::save() { data["UI"]["Theme"] = std::string(FrontendSettings::themeToString(frontendSettings.theme)); data["UI"]["WindowIcon"] = std::string(FrontendSettings::iconToString(frontendSettings.icon)); + data["UI"]["Language"] = frontendSettings.language; std::ofstream file(path, std::ios::out); file << data; diff --git a/src/panda_qt/config_window.cpp b/src/panda_qt/config_window.cpp index 549f89902..519a4a227 100644 --- a/src/panda_qt/config_window.cpp +++ b/src/panda_qt/config_window.cpp @@ -12,7 +12,7 @@ ConfigWindow::ConfigWindow(ConfigCallback configCallback, MainWindowCallback win // Set the window title of the main window appropriately if we enable showing the app version on the window if (config.windowSettings.showAppVersion) { - getMainWindow()->setWindowTitle("Alber v" PANDA3DS_VERSION); + getMainWindow()->setWindowTitle(tr("Alber v%1").arg(PANDA3DS_VERSION)); } // Initialize the widget list and the widget container widgets @@ -96,6 +96,9 @@ ConfigWindow::ConfigWindow(ConfigCallback configCallback, MainWindowCallback win }); guiLayout->addRow(tr("Window icon"), iconSelect); + QComboBox* languageSelect = createLanguageSelect(); + guiLayout->addRow(tr("Language"), languageSelect); + QCheckBox* showAppVersion = new QCheckBox(tr("Show version on window title")); showAppVersion->setChecked(config.windowSettings.showAppVersion); connect(showAppVersion, &QCheckBox::toggled, this, [&](bool checked) { diff --git a/src/panda_qt/main_window.cpp b/src/panda_qt/main_window.cpp index c3a04f884..c4d536975 100644 --- a/src/panda_qt/main_window.cpp +++ b/src/panda_qt/main_window.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include @@ -15,6 +14,8 @@ #include "version.hpp" MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent), keyboardMappings(InputMappings::defaultKeyboardMappings()) { + emu = new Emulator(); + loadTranslation(); setWindowTitle(tr("Alber")); @@ -77,7 +78,6 @@ MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent) auto aboutAction = aboutMenu->addAction(tr("About Panda3DS")); connect(aboutAction, &QAction::triggered, this, &MainWindow::showAboutMenu); - emu = new Emulator(); emu->setOutputSize(screen->surfaceWidth, screen->surfaceHeight); // Set up misc objects @@ -680,32 +680,4 @@ void MainWindow::setupControllerSensors(SDL_GameController* controller) { if (haveAccelerometer) { SDL_GameControllerSetSensorEnabled(controller, SDL_SENSOR_ACCEL, SDL_TRUE); } -} - -void MainWindow::loadTranslation() { - // TODO: This should become a member variable when we allow changing language at runtime. - QTranslator* translator = nullptr; - - auto language = QString::fromStdString("el"); - const QString baseDir = QStringLiteral(":/translations"); - QString basePath = QStringLiteral("%1/%2.qm").arg(baseDir).arg(language); - - if (QFile::exists(basePath)) { - if (translator != nullptr) { - qApp->removeTranslator(translator); - } - - translator = new QTranslator(qApp); - if (!translator->load(basePath)) { - QMessageBox::warning( - nullptr, QStringLiteral("Translation Error"), - QStringLiteral("Failed to find load translation file for '%1':\n%2").arg(language).arg(basePath) - ); - delete translator; - } else { - qApp->installTranslator(translator); - } - } else { - printf("Language file %s does not exist\n", basePath.toStdString().c_str()); - } } \ No newline at end of file diff --git a/src/panda_qt/translations.cpp b/src/panda_qt/translations.cpp new file mode 100644 index 000000000..5054a0d4c --- /dev/null +++ b/src/panda_qt/translations.cpp @@ -0,0 +1,91 @@ +#include +#include +#include +#include + +#include "panda_qt/config_window.hpp" +#include "panda_qt/main_window.hpp" + +void MainWindow::loadTranslation() { + // TODO: This should become a member variable when we allow changing language at runtime. + QTranslator* translator = nullptr; + + // Fetch the .qm file for our language and load it + auto language = QString::fromStdString(emu->getConfig().frontendSettings.language); + const QString baseDir = QStringLiteral(":/translations"); + const QString basePath = QStringLiteral("%1/%2.qm").arg(baseDir).arg(language); + + if (QFile::exists(basePath)) { + if (translator != nullptr) { + qApp->removeTranslator(translator); + } + + translator = new QTranslator(qApp); + if (!translator->load(basePath)) { + QMessageBox::warning( + nullptr, QStringLiteral("Translation Error"), + QStringLiteral("Failed to find load translation file for '%1':\n%2").arg(language).arg(basePath) + ); + delete translator; + } else { + qApp->installTranslator(translator); + } + } else { + printf("Language file %s does not exist. Defaulting to English\n", basePath.toStdString().c_str()); + } +} + +struct LanguageInfo { + QString name; // Full name of the language (for example "English (US)") + const char* code; // ISO 639 language code (for example "en_us") + + explicit LanguageInfo(const QString& name, const char* code) : name(name), code(code) {} +}; + +// List of languages in the order they should appear in the menu +// Please keep this list mostly in alphabetical order. +// Also, for Unicode characters in language names, use Unicode keycodes instead of writing out the name, +// as some compilers/toolchains may not enjoy Unicode in source files. +static std::array languages = { + LanguageInfo(QStringLiteral(u"English"), "en"), // English + LanguageInfo(QStringLiteral(u"\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC"), "el"), // Greek +}; + +QComboBox* ConfigWindow::createLanguageSelect() { + QComboBox* select = new QComboBox(); + + for (usize i = 0; i < languages.size(); i++) { + const auto& lang = languages[i]; + select->addItem(lang.name); + + if (config.frontendSettings.language == lang.code) { + select->setCurrentIndex(i); + } + } + + connect(select, &QComboBox::currentIndexChanged, this, [&](int index) { + const QString baseDir = QStringLiteral(":/translations"); + const QString basePath = QStringLiteral("%1/%2.qm").arg(baseDir).arg(languages[index].code); + + if (QFile::exists(basePath)) { + config.frontendSettings.language = languages[index].code; + updateConfig(); + + QMessageBox messageBox( + QMessageBox::Icon::Information, tr("Language change successful"), + tr("Restart Panda3DS for the new language to be used.") + ); + + messageBox.exec(); + } else { + QMessageBox messageBox( + QMessageBox::Icon::Warning, tr("Language change failed"), + tr("The language you selected is not included in Panda3DS. If you're seeing this, someone messed up the language UI code...") + ); + + messageBox.exec(); + } + }); + + return select; +} \ No newline at end of file From 13441c7a0a55d0d4ab69a66b5741541d19f88165 Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Wed, 4 Dec 2024 20:27:28 +0200 Subject: [PATCH 5/5] Linux CI: Install qt6-tools-dev --- .github/workflows/Qt_Build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Qt_Build.yml b/.github/workflows/Qt_Build.yml index 3b846a275..cc8055e51 100644 --- a/.github/workflows/Qt_Build.yml +++ b/.github/workflows/Qt_Build.yml @@ -107,7 +107,7 @@ jobs: run: | sudo apt-get update && sudo apt install libx11-dev libgl1 libglx-mesa0 mesa-common-dev libfuse2 libwayland-dev libgl1-mesa-dev sudo apt update - sudo apt install qt6-base-dev qt6-base-private-dev + sudo apt install qt6-base-dev qt6-base-private-dev qt6-tools-dev - name: Install newer Clang run: |