mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 08:09:32 +02:00
TranslatableString caption & message in MessageBoxException
This commit is contained in:
parent
54e2bbd8ff
commit
503ccabdd8
@ -32,7 +32,7 @@ AudacityException::~AudacityException()
|
||||
|
||||
wxAtomicInt sOutstandingMessages {};
|
||||
|
||||
MessageBoxException::MessageBoxException( const wxString &caption_ )
|
||||
MessageBoxException::MessageBoxException( const TranslatableString &caption_ )
|
||||
: caption{ caption_ }
|
||||
{
|
||||
if (!caption.empty())
|
||||
@ -80,7 +80,7 @@ SimpleMessageBoxException::~SimpleMessageBoxException()
|
||||
{
|
||||
}
|
||||
|
||||
wxString SimpleMessageBoxException::ErrorMessage() const
|
||||
TranslatableString SimpleMessageBoxException::ErrorMessage() const
|
||||
{
|
||||
return message;
|
||||
}
|
||||
@ -96,8 +96,8 @@ void MessageBoxException::DelayedHandlerAction()
|
||||
// give the user no useful added information.
|
||||
if ( wxAtomicDec( sOutstandingMessages ) == 0 )
|
||||
::AudacityMessageBox(
|
||||
ErrorMessage(),
|
||||
caption.empty() ? AudacityMessageBoxCaptionStr() : caption,
|
||||
ErrorMessage().Translation(),
|
||||
(caption.empty() ? AudacityMessageBoxCaptionStr() : caption).Translation(),
|
||||
wxICON_ERROR
|
||||
);
|
||||
moved = true;
|
||||
|
@ -54,17 +54,17 @@ class MessageBoxException /* not final */ : public AudacityException
|
||||
|
||||
protected:
|
||||
// If default-constructed with empty caption, it makes no message box.
|
||||
explicit MessageBoxException( const wxString &caption = wxString{} );
|
||||
explicit MessageBoxException( const TranslatableString &caption = {} );
|
||||
~MessageBoxException() override;
|
||||
|
||||
MessageBoxException( const MessageBoxException& );
|
||||
MessageBoxException &operator = ( MessageBoxException && );
|
||||
|
||||
// Format a default, internationalized error message for this exception.
|
||||
virtual wxString ErrorMessage() const = 0;
|
||||
// Format a default error message for this exception.
|
||||
virtual TranslatableString ErrorMessage() const = 0;
|
||||
|
||||
private:
|
||||
wxString caption;
|
||||
TranslatableString caption;
|
||||
mutable bool moved { false };
|
||||
};
|
||||
|
||||
@ -72,8 +72,8 @@ private:
|
||||
class SimpleMessageBoxException /* not final */ : public MessageBoxException
|
||||
{
|
||||
public:
|
||||
explicit SimpleMessageBoxException( const wxString &message_,
|
||||
const wxString &caption = _("Message") )
|
||||
explicit SimpleMessageBoxException( const TranslatableString &message_,
|
||||
const TranslatableString &caption = XO("Message") )
|
||||
: MessageBoxException{ caption }
|
||||
, message{ message_ }
|
||||
{}
|
||||
@ -84,10 +84,10 @@ public:
|
||||
SimpleMessageBoxException && ) PROHIBITED;
|
||||
|
||||
// Format a default, internationalized error message for this exception.
|
||||
virtual wxString ErrorMessage() const override;
|
||||
virtual TranslatableString ErrorMessage() const override;
|
||||
|
||||
private:
|
||||
wxString message;
|
||||
TranslatableString message;
|
||||
};
|
||||
|
||||
|
||||
|
@ -15,24 +15,24 @@ FileException::~FileException()
|
||||
{
|
||||
}
|
||||
|
||||
wxString FileException::ErrorMessage() const
|
||||
TranslatableString FileException::ErrorMessage() const
|
||||
{
|
||||
wxString format;
|
||||
TranslatableString format;
|
||||
switch (cause) {
|
||||
case Cause::Open:
|
||||
format = _("Audacity failed to open a file in %s.");
|
||||
format = XO("Audacity failed to open a file in %s.");
|
||||
break;
|
||||
case Cause::Read:
|
||||
format = _("Audacity failed to read from a file in %s.");
|
||||
format = XO("Audacity failed to read from a file in %s.");
|
||||
break;
|
||||
case Cause::Write:
|
||||
format =
|
||||
_("Audacity failed to write to a file.\n"
|
||||
XO("Audacity failed to write to a file.\n"
|
||||
"Perhaps %s is not writable or the disk is full.");
|
||||
break;
|
||||
case Cause::Rename:
|
||||
format =
|
||||
_("Audacity successfully wrote a file in %s but failed to rename it as %s.");
|
||||
XO("Audacity successfully wrote a file in %s but failed to rename it as %s.");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -54,7 +54,6 @@ _("Audacity successfully wrote a file in %s but failed to rename it as %s.");
|
||||
|
||||
#endif
|
||||
|
||||
return wxString::Format(
|
||||
format, target, renameTarget.GetFullName() );
|
||||
return format.Format( target, renameTarget.GetFullName() );
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ public:
|
||||
|
||||
explicit FileException
|
||||
( Cause cause_, const wxFileName &fileName_,
|
||||
const wxString &caption = _("File Error"),
|
||||
const TranslatableString &caption = XO("File Error"),
|
||||
const wxFileName &renameTarget_ = {})
|
||||
: MessageBoxException{ caption }
|
||||
, cause{ cause_ }, fileName{ fileName_ }, renameTarget{ renameTarget_ }
|
||||
@ -38,7 +38,7 @@ public:
|
||||
|
||||
protected:
|
||||
// Format a default, internationalized error message for this exception.
|
||||
wxString ErrorMessage() const override;
|
||||
TranslatableString ErrorMessage() const override;
|
||||
|
||||
public:
|
||||
Cause cause;
|
||||
|
@ -13,7 +13,7 @@ InconsistencyException::~InconsistencyException()
|
||||
{
|
||||
}
|
||||
|
||||
wxString InconsistencyException::ErrorMessage() const
|
||||
TranslatableString InconsistencyException::ErrorMessage() const
|
||||
{
|
||||
// Shorten the path
|
||||
wxString path { file };
|
||||
@ -23,14 +23,12 @@ wxString InconsistencyException::ErrorMessage() const
|
||||
path = path.Mid(index + sub.size());
|
||||
|
||||
#ifdef __func__
|
||||
return wxString::Format(
|
||||
_("Internal error in %s at %s line %d.\nPlease inform the Audacity team at https://forum.audacityteam.org/."),
|
||||
func, path, line
|
||||
);
|
||||
return
|
||||
XO("Internal error in %s at %s line %d.\nPlease inform the Audacity team at https://forum.audacityteam.org/.")
|
||||
.Format( func, path, line );
|
||||
#else
|
||||
return wxString::Format(
|
||||
_("Internal error at %s line %d.\nPlease inform the Audacity team at https://forum.audacityteam.org/."),
|
||||
path, line
|
||||
);
|
||||
return
|
||||
XO("Internal error at %s line %d.\nPlease inform the Audacity team at https://forum.audacityteam.org/.")
|
||||
.Format( path, line );
|
||||
#endif
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ public:
|
||||
|
||||
explicit InconsistencyException
|
||||
( const char *fn, const char *f, unsigned l )
|
||||
: MessageBoxException{ _("Internal Error") }
|
||||
: MessageBoxException{ XO("Internal Error") }
|
||||
, func { fn }, file { f }, line { l }
|
||||
{}
|
||||
|
||||
@ -49,7 +49,7 @@ public:
|
||||
|
||||
private:
|
||||
// Format a default, internationalized error message for this exception.
|
||||
wxString ErrorMessage() const override;
|
||||
TranslatableString ErrorMessage() const override;
|
||||
|
||||
const char *func {};
|
||||
const char *file {};
|
||||
|
@ -1159,7 +1159,7 @@ void ThemeBase::SaveComponents()
|
||||
wxString::Format(
|
||||
_("Some required files in:\n %s\nwere already present. Overwrite?"),
|
||||
FileNames::ThemeComponentsDir()),
|
||||
AudacityMessageBoxCaptionStr(),
|
||||
AudacityMessageBoxCaptionStr().Translation(),
|
||||
wxYES_NO | wxNO_DEFAULT);
|
||||
if(result == wxNO)
|
||||
return;
|
||||
|
@ -1952,7 +1952,7 @@ void WaveClip::Resample(int rate, ProgressDialog *progress)
|
||||
|
||||
if (error)
|
||||
throw SimpleMessageBoxException{
|
||||
_("Resampling failed.")
|
||||
XO("Resampling failed.")
|
||||
};
|
||||
else
|
||||
{
|
||||
|
@ -1228,7 +1228,7 @@ void WaveTrack::Paste(double t0, const Track *src)
|
||||
// STRONG-GUARANTEE in case of this path
|
||||
// not that it matters.
|
||||
throw SimpleMessageBoxException{
|
||||
_("There is not enough room available to paste the selection")
|
||||
XO("There is not enough room available to paste the selection")
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -1248,7 +1248,7 @@ void WaveTrack::Paste(double t0, const Track *src)
|
||||
// STRONG-GUARANTEE in case of this path
|
||||
// not that it matters.
|
||||
throw SimpleMessageBoxException{
|
||||
_("There is not enough room available to paste the selection")
|
||||
XO("There is not enough room available to paste the selection")
|
||||
};
|
||||
|
||||
for (const auto &clip : other->mClips)
|
||||
@ -2381,7 +2381,7 @@ void WaveTrack::ExpandCutLine(double cutLinePosition, double* cutlineStart,
|
||||
clip->GetEndTime() + end - start > clip2->GetStartTime())
|
||||
// STRONG-GUARANTEE in case of this path
|
||||
throw SimpleMessageBoxException{
|
||||
_("There is not enough room available to expand the cut line")
|
||||
XO("There is not enough room available to expand the cut line")
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -13,10 +13,9 @@ NotYetAvailableException::~NotYetAvailableException()
|
||||
{
|
||||
}
|
||||
|
||||
wxString NotYetAvailableException::ErrorMessage() const
|
||||
TranslatableString NotYetAvailableException::ErrorMessage() const
|
||||
{
|
||||
return wxString::Format(
|
||||
_("This operation cannot be done until importation of %s completes."),
|
||||
fileName.GetFullName()
|
||||
);
|
||||
return
|
||||
XO("This operation cannot be done until importation of %s completes.")
|
||||
.Format( fileName.GetFullName() );
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
~NotYetAvailableException();
|
||||
|
||||
protected:
|
||||
wxString ErrorMessage() const override;
|
||||
TranslatableString ErrorMessage() const override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -209,7 +209,7 @@ static void Extract(bool bits16,
|
||||
}
|
||||
|
||||
if( dataSizeIn < 1 )
|
||||
throw SimpleMessageBoxException{_("Bad data size")};
|
||||
throw SimpleMessageBoxException{XO("Bad data size")};
|
||||
|
||||
size_t dataSize = (size_t)dataSizeIn;
|
||||
|
||||
|
@ -468,7 +468,7 @@ void OnPaste(const CommandContext &context)
|
||||
// Throw, so that any previous changes to the project in this loop
|
||||
// are discarded.
|
||||
throw SimpleMessageBoxException{
|
||||
_("Pasting one type of track into another is not allowed.")
|
||||
XO("Pasting one type of track into another is not allowed.")
|
||||
};
|
||||
|
||||
// We should need this check only each time we visit the leading
|
||||
@ -496,7 +496,7 @@ void OnPaste(const CommandContext &context)
|
||||
// Throw, so that any previous changes to the project in this
|
||||
// loop are discarded.
|
||||
throw SimpleMessageBoxException{
|
||||
_("Copying stereo audio into a mono track is not allowed.")
|
||||
XO("Copying stereo audio into a mono track is not allowed.")
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "AudacityMessageBox.h"
|
||||
#include "../Internat.h"
|
||||
|
||||
wxString AudacityMessageBoxCaptionStr()
|
||||
TranslatableString AudacityMessageBoxCaptionStr()
|
||||
{
|
||||
return _("Message");
|
||||
return XO("Message");
|
||||
}
|
||||
|
@ -12,12 +12,13 @@
|
||||
#define __AUDACITY_MESSAGE_BOX__
|
||||
|
||||
#include <wx/msgdlg.h>
|
||||
#include "../Internat.h"
|
||||
|
||||
extern wxString AudacityMessageBoxCaptionStr();
|
||||
extern TranslatableString AudacityMessageBoxCaptionStr();
|
||||
|
||||
// Do not use wxMessageBox!! Its default window title does not translate!
|
||||
inline int AudacityMessageBox(const wxString& message,
|
||||
const wxString& caption = AudacityMessageBoxCaptionStr(),
|
||||
const wxString& caption = AudacityMessageBoxCaptionStr().Translation(),
|
||||
long style = wxOK | wxCENTRE,
|
||||
wxWindow *parent = NULL,
|
||||
int x = wxDefaultCoord, int y = wxDefaultCoord)
|
||||
|
@ -111,7 +111,7 @@ class AUDACITY_DLL_API XMLFileWriter final : private wxFFile, public XMLWriter {
|
||||
private:
|
||||
|
||||
void ThrowException(
|
||||
const wxFileName &fileName, const wxString &caption)
|
||||
const wxFileName &fileName, const TranslatableString &caption)
|
||||
{
|
||||
throw FileException{ FileException::Cause::Write, fileName, caption };
|
||||
}
|
||||
@ -121,7 +121,7 @@ class AUDACITY_DLL_API XMLFileWriter final : private wxFFile, public XMLWriter {
|
||||
void CloseWithoutEndingTags(); // for auto-save files
|
||||
|
||||
const FilePath mOutputPath;
|
||||
const wxString mCaption;
|
||||
const TranslatableString mCaption;
|
||||
FilePath mBackupName;
|
||||
const bool mKeepBackup;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user