[Scummvm-git-logs] scummvm master -> f63ed4b9c333629d2d8a5e3a573ddbd0c5726213
bluegr
noreply at scummvm.org
Mon Jan 1 23:00:57 UTC 2024
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
f63ed4b9c3 COMMON: Fix translation of error messages
Commit: f63ed4b9c333629d2d8a5e3a573ddbd0c5726213
https://github.com/scummvm/scummvm/commit/f63ed4b9c333629d2d8a5e3a573ddbd0c5726213
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-01-02T01:00:54+02:00
Commit Message:
COMMON: Fix translation of error messages
Changed paths:
common/error.cpp
common/error.h
gui/error.cpp
diff --git a/common/error.cpp b/common/error.cpp
index 0cebd9a5521..6f7476a1f77 100644
--- a/common/error.cpp
+++ b/common/error.cpp
@@ -78,11 +78,27 @@ static String errorToString(ErrorCode errorCode) {
}
Error::Error(ErrorCode code)
- : _code(code), _desc(errorToString(code)) {
+ : _code(code), _desc() {
}
Error::Error(ErrorCode code, const String &desc)
- : _code(code), _desc(errorToString(code) + " (" + desc + ")") {
+ : _code(code), _desc(desc) {
+}
+
+String Error::getDesc() const {
+ if (!_desc.empty()) {
+ return Common::String::format("%s (%s)", errorToString(_code).c_str(), _desc.c_str());
+ } else {
+ return errorToString(_code);
+ }
+}
+
+U32String Error::getTranslatedDesc() const {
+ if (!_desc.empty()) {
+ return Common::U32String::format("%S (%S)", _(errorToString(_code)).c_str(), _(_desc).c_str());
+ } else {
+ return _(errorToString(_code));
+ }
}
diff --git a/common/error.h b/common/error.h
index b35233ea558..476c0c8839f 100644
--- a/common/error.h
+++ b/common/error.h
@@ -100,9 +100,14 @@ public:
Error(ErrorCode code, const String &extra);
/**
- * Get the description of this error.
+ * Get the untranslated description of this error.
*/
- const String &getDesc() const { return _desc; }
+ String getDesc() const;
+
+ /**
+ * Get the translated description of this error.
+ */
+ U32String getTranslatedDesc() const;
/**
* Get the error code of this error.
diff --git a/gui/error.cpp b/gui/error.cpp
index 8f1689a10f0..8f3aa27a51a 100644
--- a/gui/error.cpp
+++ b/gui/error.cpp
@@ -23,8 +23,6 @@
#include "gui/message.h"
#include "gui/error.h"
-#include "common/translation.h"
-
namespace GUI {
void displayErrorDialog(const Common::U32String &text) {
@@ -35,7 +33,7 @@ void displayErrorDialog(const Common::U32String &text) {
void displayErrorDialog(const Common::Error &error, const Common::U32String &extraText) {
Common::U32String errorText(extraText);
errorText += Common::U32String(" ");
- errorText += _(error.getDesc());
+ errorText += error.getTranslatedDesc();
GUI::MessageDialog alert(errorText);
alert.runModal();
}
More information about the Scummvm-git-logs
mailing list