From 6760fa4945cc9589606c704f6507d8c311404e65 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Tue, 6 Feb 2024 13:46:05 +0400 Subject: [PATCH] Localize screenshot messages --- apps/openmw/engine.cpp | 23 ++++++++++++++++++----- components/sceneutil/screencapture.cpp | 4 ++-- files/data/l10n/OMWEngine/de.yaml | 4 +++- files/data/l10n/OMWEngine/en.yaml | 4 +++- files/data/l10n/OMWEngine/fr.yaml | 4 +++- files/data/l10n/OMWEngine/ru.yaml | 4 +++- files/data/l10n/OMWEngine/sv.yaml | 4 +++- 7 files changed, 35 insertions(+), 12 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index fe950a0920..75687ff281 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -109,10 +110,23 @@ namespace profiler.removeUserStatsLine(" -Async"); } - struct ScheduleNonDialogMessageBox + struct ScreenCaptureMessageBox { - void operator()(std::string message) const + void operator()(std::string filePath) const { + if (filePath.empty()) + { + MWBase::Environment::get().getWindowManager()->scheduleMessageBox( + "#{OMWEngine:ScreenshotFailed}", MWGui::ShowInDialogueMode_Never); + + return; + } + + std::string messageFormat + = MWBase::Environment::get().getL10nManager()->getMessage("OMWEngine", "ScreenshotMade"); + + std::string message = Misc::StringUtils::format(messageFormat, filePath); + MWBase::Environment::get().getWindowManager()->scheduleMessageBox( std::move(message), MWGui::ShowInDialogueMode_Never); } @@ -717,9 +731,8 @@ void OMW::Engine::prepareEngine() mScreenCaptureOperation = new SceneUtil::AsyncScreenCaptureOperation(mWorkQueue, new SceneUtil::WriteScreenshotToFileOperation(mCfgMgr.getScreenshotPath(), Settings::general().mScreenshotFormat, - Settings::general().mNotifyOnSavedScreenshot - ? std::function(ScheduleNonDialogMessageBox{}) - : std::function(IgnoreString{}))); + Settings::general().mNotifyOnSavedScreenshot ? std::function(ScreenCaptureMessageBox{}) + : std::function(IgnoreString{}))); mScreenCaptureHandler = new osgViewer::ScreenCaptureHandler(mScreenCaptureOperation); diff --git a/components/sceneutil/screencapture.cpp b/components/sceneutil/screencapture.cpp index 8382e75e54..ed90668cfb 100644 --- a/components/sceneutil/screencapture.cpp +++ b/components/sceneutil/screencapture.cpp @@ -122,10 +122,10 @@ namespace SceneUtil << mScreenshotFormat << "\": " << e.what(); } if (fileName.empty()) - mCallback("Failed to save screenshot"); + mCallback(std::string()); else { - mCallback(Files::pathToUnicodeString(fileName) + " has been saved"); + mCallback(Files::pathToUnicodeString(fileName)); Log(Debug::Info) << mScreenshotPath / fileName << " has been saved"; } } diff --git a/files/data/l10n/OMWEngine/de.yaml b/files/data/l10n/OMWEngine/de.yaml index 2874001309..aab58fb30c 100644 --- a/files/data/l10n/OMWEngine/de.yaml +++ b/files/data/l10n/OMWEngine/de.yaml @@ -29,9 +29,11 @@ BuildingNavigationMesh: "Baue Navigationsgitter" # This save file was created using an older version of OpenMW in a format that is no longer supported. # Load and save this file using {version} to upgrade it. #NewGameConfirmation: "Do you want to start a new game and lose the current one?" +#QuitGameConfirmation: "Quit the game?" #SaveGameDenied: "The game cannot be saved right now." #SavingInProgress: "Saving..." -#QuitGameConfirmation: "Quit the game?" +#ScreenshotFailed: "Failed to save screenshot" +#ScreenshotMade: "%s has been saved" # Save game menu diff --git a/files/data/l10n/OMWEngine/en.yaml b/files/data/l10n/OMWEngine/en.yaml index 0455d11e07..f6ad237394 100644 --- a/files/data/l10n/OMWEngine/en.yaml +++ b/files/data/l10n/OMWEngine/en.yaml @@ -26,9 +26,11 @@ LoadingRequiresOldVersionError: |- This save file was created using an older version of OpenMW in a format that is no longer supported. Load and save this file using {version} to upgrade it. NewGameConfirmation: "Do you want to start a new game and lose the current one?" +QuitGameConfirmation: "Quit the game?" SaveGameDenied: "The game cannot be saved right now." SavingInProgress: "Saving..." -QuitGameConfirmation: "Quit the game?" +ScreenshotFailed: "Failed to save screenshot" +ScreenshotMade: "%s has been saved" # Save game menu diff --git a/files/data/l10n/OMWEngine/fr.yaml b/files/data/l10n/OMWEngine/fr.yaml index 85bac08612..990ecfce9d 100644 --- a/files/data/l10n/OMWEngine/fr.yaml +++ b/files/data/l10n/OMWEngine/fr.yaml @@ -26,9 +26,11 @@ LoadingRequiresNewVersionError: |- # This save file was created using an older version of OpenMW in a format that is no longer supported. # Load and save this file using {version} to upgrade it. NewGameConfirmation: "Voulez-vous démarrer une nouvelle partie ? Toute progression non sauvegardée sera perdue." +QuitGameConfirmation: "Quitter la partie ?" SaveGameDenied: "Sauvegarde impossible" SavingInProgress: "Sauvegarde en cours..." -QuitGameConfirmation: "Quitter la partie ?" +#ScreenshotFailed: "Failed to save screenshot" +#ScreenshotMade: "%s has been saved" # Save game menu diff --git a/files/data/l10n/OMWEngine/ru.yaml b/files/data/l10n/OMWEngine/ru.yaml index 8d221fe33c..a9f396f73c 100644 --- a/files/data/l10n/OMWEngine/ru.yaml +++ b/files/data/l10n/OMWEngine/ru.yaml @@ -26,9 +26,11 @@ LoadingRequiresOldVersionError: |- Это сохранение создано старой версией OpenMW и использует формат, который больше не поддерживается. Загрузите и сохраните этот файл в {version}, чтобы обновить его. NewGameConfirmation: "Вы хотите начать новую игру? Текущая игра будет потеряна." +QuitGameConfirmation: "Выйти из игры?" SaveGameDenied: "В данный момент игру нельзя сохранить." SavingInProgress: "Сохранение..." -QuitGameConfirmation: "Выйти из игры?" +ScreenshotFailed: "Не удалось создать снимок экрана" +ScreenshotMade: "Создан снимок экрана %s" # Save game menu diff --git a/files/data/l10n/OMWEngine/sv.yaml b/files/data/l10n/OMWEngine/sv.yaml index 134fab0e95..bbc6132f55 100644 --- a/files/data/l10n/OMWEngine/sv.yaml +++ b/files/data/l10n/OMWEngine/sv.yaml @@ -26,9 +26,11 @@ LoadingRequiresNewVersionError: |- # This save file was created using an older version of OpenMW in a format that is no longer supported. # Load and save this file using {version} to upgrade it. NewGameConfirmation: "Vill du starta ett nytt spel och förlora det pågående spelet?" +QuitGameConfirmation: "Avsluta spelet?" SaveGameDenied: "Spelet kan inte sparas just nu." SavingInProgress: "Sparar..." -QuitGameConfirmation: "Avsluta spelet?" +#ScreenshotFailed: "Failed to save screenshot" +#ScreenshotMade: "%s has been saved" # Save game menu