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: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 224fea7c0..4f3883c1e 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() @@ -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 @@ -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 ) + + # 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}) + + 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..0368d8bda --- /dev/null +++ b/docs/translations/el.ts @@ -0,0 +1,763 @@ + + + AboutWindow + + + 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 και συνδέσμους στις επίσημες σελίδες υποστήριξης μας. + + + + 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 + Ο πιγκουίνος από το SkyEmu + + + + Window icon + Εικονίδιο Παραθύρου + + + + 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 + + + + 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 + Δεν βρέθηκε RomFS στην εφαρμογή που έχει φορτωθεί + + + + Select file + Επιλέξτε αρχείο + + + + DSP firmware file (*.cdc) + + + + + No DSP firmware loaded + Δεν έχει φορτωθεί DSP firmware + + + + 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 + Επιλογή αρχείου patch + + + + Apply patch + Εφαρμογή patch + + + + Select file to patch + Επιλέξτε αρχείο να κάνετε patch + + + + + All files (*.*) + Όλα τα αρχεία (*.*) + + + + Patch files (*.ips *.ups *.bps) + + + + + Paths not provided correctly + + + + + Please provide paths for both the input file and the patch file + Παρακαλούμε διαλέξτε και αρχείο εισόδου και αρχείο patch + + + + Select file + Επιλογή αρχείου + + + + 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 + + + + Patching Success + Επιτυχής Εφαρμογή Patch + + + + Your file was patched successfully. + To αρχείο σας έγινε patch με επιτυχία + + + + Checksum mismatch + + + + + 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 + + + + PatchWindow::PatchWindow + + + OK + ΟΚ + + + + ShaderEditorWindow + + + Reload shader + Επαναφόρτωση 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..4a70fabb3 --- /dev/null +++ b/docs/translations/en.ts @@ -0,0 +1,766 @@ + + + + + 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 + + + + + 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 + + + + + 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/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/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/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 7f42acab9..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) { @@ -103,7 +106,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 5af31d737..c4d536975 100644 --- a/src/panda_qt/main_window.cpp +++ b/src/panda_qt/main_window.cpp @@ -14,6 +14,9 @@ #include "version.hpp" MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent), keyboardMappings(InputMappings::defaultKeyboardMappings()) { + emu = new Emulator(); + + loadTranslation(); setWindowTitle(tr("Alber")); // Enable drop events for loading ROMs @@ -75,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 @@ -678,4 +680,4 @@ void MainWindow::setupControllerSensors(SDL_GameController* controller) { if (haveAccelerometer) { SDL_GameControllerSetSensorEnabled(controller, SDL_SENSOR_ACCEL, SDL_TRUE); } -} +} \ 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