1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-25 16:48:44 +02:00

Rewrite many formattings of long user-readable texts with XO not _

This commit is contained in:
Paul Licameli 2019-12-26 22:12:19 -05:00
commit 3117128e08
7 changed files with 422 additions and 301 deletions

View File

@ -37,6 +37,8 @@ hold information about one contributor to Audacity.
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/statbmp.h> #include <wx/statbmp.h>
#include <wx/intl.h> #include <wx/intl.h>
#include <wx/sstream.h>
#include <wx/txtstrm.h>
#include "FileNames.h" #include "FileNames.h"
#include "HelpText.h" #include "HelpText.h"
@ -306,110 +308,141 @@ void AboutDialog::PopulateAudacityPage( ShuttleGui & S )
{ {
CreateCreditsList(); CreateCreditsList();
wxString par1Str = auto par1Str =
// DA: Says that it is a customised version. // DA: Says that it is a customised version.
#ifdef EXPERIMENTAL_DA #ifdef EXPERIMENTAL_DA
wxT( wxT(
"Audacity, which this is a customised version of, is a free program written by a worldwide team of [[https://www.audacityteam.org/about/credits|volunteers]]. \ "Audacity, which this is a customised version of, is a free program written by a worldwide team of [[https://www.audacityteam.org/about/credits|volunteers]]. \
Audacity is [[https://www.audacityteam.org/download|available]] for Windows, Mac, and GNU/Linux (and other Unix-like systems)."); Audacity is [[https://www.audacityteam.org/download|available]] for Windows, Mac, and GNU/Linux (and other Unix-like systems).")
#else #else
_( XO(
"Audacity is a free program written by a worldwide team of [[https://www.audacityteam.org/about/credits|volunteers]]. \ "Audacity is a free program written by a worldwide team of [[https://www.audacityteam.org/about/credits|volunteers]]. \
Audacity is [[https://www.audacityteam.org/download|available]] for Windows, Mac, and GNU/Linux (and other Unix-like systems)."); Audacity is [[https://www.audacityteam.org/download|available]] for Windows, Mac, and GNU/Linux (and other Unix-like systems).")
#endif #endif
;
// This trick here means that the English language version won't mention using // This trick here means that the English language version won't mention using
// English, whereas all translated versions will. // English, whereas all translated versions will.
wxString par2StrUntranslated = wxT( auto par2Str = XO(
"If you find a bug or have a suggestion for us, please write, in English, to our [[https://forum.audacityteam.org/|forum]]. \
For help, view the tips and tricks on our [[https://wiki.audacityteam.org/|wiki]] or \
visit our [[https://forum.audacityteam.org/|forum]].");
wxString par2Str = _(
"If you find a bug or have a suggestion for us, please write, in English, to our [[https://forum.audacityteam.org/|forum]]. \ "If you find a bug or have a suggestion for us, please write, in English, to our [[https://forum.audacityteam.org/|forum]]. \
For help, view the tips and tricks on our [[https://wiki.audacityteam.org/|wiki]] or \ For help, view the tips and tricks on our [[https://wiki.audacityteam.org/|wiki]] or \
visit our [[https://forum.audacityteam.org/|forum]]."); visit our [[https://forum.audacityteam.org/|forum]].");
auto par2StrTranslated = par2Str.Translation();
if( par2Str == par2StrUntranslated ) if( par2StrTranslated == par2Str.MSGID().GET() )
par2Str.Replace( wxT(", in English,"), wxT("") ); par2StrTranslated.Replace( wxT(", in English,"), wxT("") );
wxString translatorCredits; auto translatorCreditsMsgid = XO("translator_credits");
auto translatorCredits = translatorCreditsMsgid.Translation();
/* i18n-hint: The translation of "translator_credits" will appear /* i18n-hint: The translation of "translator_credits" will appear
* in the credits in the About Audacity window. Use this to add * in the credits in the About Audacity window. Use this to add
* your own name(s) to the credits. * your own name(s) to the credits.
* *
* For example: "English translation by Dominic Mazzoni." */ * For example: "English translation by Dominic Mazzoni." */
if (_("translator_credits") != wxString(wxT("translator_credits"))) if ( translatorCredits == translatorCreditsMsgid.MSGID().GET() )
{ // We're in an English locale
translatorCredits = _("translator_credits") + wxT("<br>"); translatorCredits.clear();
} else
translatorCredits += wxT("<br>");
wxString creditStr = FormatHtmlText( wxStringOutputStream o;
wxString( wxT("<center>") ) + wxTextOutputStream informationStr( o ); // string to build up list of information in
informationStr
<< wxT("<center>")
// DA: Description and provenance in About box // DA: Description and provenance in About box
#ifdef EXPERIMENTAL_DA #ifdef EXPERIMENTAL_DA
#undef _ #undef _
#define _(s) wxGetTranslation((s)) #define _(s) wxGetTranslation((s))
wxT("<h3>DarkAudacity ") + wxString(AUDACITY_VERSION_STRING) + wxT("</center></h3>") + << wxT("<h3>DarkAudacity ")
wxT("Customised version of the Audacity free, open source, cross-platform software " ) + << wxString(AUDACITY_VERSION_STRING)
wxT("for recording and editing sounds.") + << wxT("</center></h3>")
wxT("<p><br>&nbsp; &nbsp; <b>Audacity<sup>&reg;</sup></b> software is copyright &copy; 1999-2018 Audacity Team.<br>") + << wxT("Customised version of the Audacity free, open source, cross-platform software " )
wxT("&nbsp; &nbsp; The name <b>Audacity</b> is a registered trademark of Dominic Mazzoni.<br><br>") + << wxT("for recording and editing sounds.")
<< wxT("<p><br>&nbsp; &nbsp; <b>Audacity<sup>&reg;</sup></b> software is copyright &copy; 1999-2018 Audacity Team.<br>")
<< wxT("&nbsp; &nbsp; The name <b>Audacity</b> is a registered trademark of Dominic Mazzoni.<br><br>")
#else #else
_("<h3>Audacity ") + wxString(AUDACITY_VERSION_STRING) + wxT("</center></h3>") + << XO("<h3>Audacity ")
_("Audacity the free, open source, cross-platform software for recording and editing sounds.") + << wxString(AUDACITY_VERSION_STRING)
<< wxT("</center></h3>")
<< XO("Audacity the free, open source, cross-platform software for recording and editing sounds.")
#endif #endif
//wxT("<p><br>") + par1Str + // << wxT("<p><br>")
//wxT("<p>") + par2Str + // << par1Str
wxT("<h3>") + _("Credits") + wxT("</h3>") + wxT("<p>") + // << wxT("<p>")
// << par2Str
<< wxT("<h3>")
<< XO("Credits")
<< wxT("</h3>")
<< wxT("<p>")
// DA: Customisation credit // DA: Customisation credit
#ifdef EXPERIMENTAL_DA #ifdef EXPERIMENTAL_DA
wxT("<p><b>") + wxString::Format(_("DarkAudacity Customisation")) + wxT("</b><br>") + << wxT("<p><b>")
wxT("James Crook, art, coding &amp; design<br>") + << XO("DarkAudacity Customisation")
<< wxT("</b><br>")
<< wxT("James Crook, art, coding &amp; design<br>")
#endif #endif
wxT("<p><b>") + _("Audacity Team Members") + wxT("</b><br>") + << wxT("<p><b>")
GetCreditsByRole(roleTeamMember) + << XO("Audacity Team Members")
<< wxT("</b><br>")
<< GetCreditsByRole(roleTeamMember)
wxT("<p><b> ") + _("Emeritus:") + wxT("</b><br>") + << wxT("<p><b> ")
_("Distinguished Audacity Team members, not currently active") + wxT("<br><br>") + << XO("Emeritus:")
GetCreditsByRole(roleEmeritusTeam) + << wxT("</b><br>")
<< XO("Distinguished Audacity Team members, not currently active")
<< wxT("<br><br>")
<< GetCreditsByRole(roleEmeritusTeam)
wxT("<p><b>") + _("Contributors") + wxT("</b><br>") + << wxT("<p><b>")
GetCreditsByRole(roleContributor) + << XO("Contributors")
<< wxT("</b><br>")
<< GetCreditsByRole(roleContributor)
wxT("<p><b>") + _("Website and Graphics") + wxT("</b><br>") + << wxT("<p><b>")
GetCreditsByRole(roleGraphics) + << XO("Website and Graphics")
<< wxT("</b><br>")
<< GetCreditsByRole(roleGraphics)
;
(translatorCredits.empty() if(!translatorCredits.empty()) informationStr
? wxT("") << wxT("<p><b>")
: (wxT("<p><b>") + _("Translators") + wxT("</b><br>") + << XO("Translators")
translatorCredits)) + << wxT("</b><br>")
<< translatorCredits
;
wxT("<p><b>") + _("Libraries") + wxT("</b><br>") + informationStr
_("Audacity includes code from the following projects:") + wxT("<br><br>") + << wxT("<p><b>")
GetCreditsByRole(roleLibrary) + << XO("Libraries")
<< wxT("</b><br>")
<< XO("Audacity includes code from the following projects:")
<< wxT("<br><br>")
<< GetCreditsByRole(roleLibrary)
wxT("<p><b>") + _("Special thanks:") + wxT("</b><br>") + << wxT("<p><b>")
GetCreditsByRole(roleThanks) + << XO("Special thanks:")
<< wxT("</b><br>")
<< GetCreditsByRole(roleThanks)
wxT("<p><br>") + _("Audacity website: ") + wxT("[[https://www.audacityteam.org/|https://www.audacityteam.org/]]") + << wxT("<p><br>")
<< XO("Audacity website: ")
<< wxT("[[https://www.audacityteam.org/|https://www.audacityteam.org/]]")
// DA: Link for DA url too // DA: Link for DA url too
#ifdef EXPERIMENTAL_DA #ifdef EXPERIMENTAL_DA
wxT("<br>DarkAudacity website: [[http://www.darkaudacity.com/|https://www.darkaudacity.com/]]") + << wxT("<br>DarkAudacity website: [[http://www.darkaudacity.com/|https://www.darkaudacity.com/]]")
#else #else
_("<p><br>&nbsp; &nbsp; <b>Audacity<sup>&reg;</sup></b> software is copyright &copy; 1999-2018 Audacity Team.<br>") << XO("<p><br>&nbsp; &nbsp; <b>Audacity<sup>&reg;</sup></b> software is copyright &copy; 1999-2018 Audacity Team.<br>")
+ << XO("&nbsp; &nbsp; The name <b>Audacity</b> is a registered trademark of Dominic Mazzoni.<br><br>")
_("&nbsp; &nbsp; The name <b>Audacity</b> is a registered trademark of Dominic Mazzoni.<br><br>") +
#endif #endif
wxT("</center>") << wxT("</center>")
); ;
auto pPage = S.StartNotebookPage( XO("Audacity") ); auto pPage = S.StartNotebookPage( XO("Audacity") );
S.StartVerticalLay(1); S.StartVerticalLay(1);
@ -446,7 +479,7 @@ visit our [[https://forum.audacityteam.org/|forum]].");
wxDefaultPosition, wxDefaultPosition,
wxSize(ABOUT_DIALOG_WIDTH, 359), wxSize(ABOUT_DIALOG_WIDTH, 359),
wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER); wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER);
html->SetPage(creditStr); html->SetPage( FormatHtmlText( o.GetString() ) );
/* locate the html renderer where it fits in the dialogue */ /* locate the html renderer where it fits in the dialogue */
S.Prop(1).Position( wxEXPAND ).Focus() S.Prop(1).Position( wxEXPAND ).Focus()
@ -463,7 +496,8 @@ visit our [[https://forum.audacityteam.org/|forum]].");
* about the build we might wish to know should be visible here */ * about the build we might wish to know should be visible here */
void AboutDialog::PopulateInformationPage( ShuttleGui & S ) void AboutDialog::PopulateInformationPage( ShuttleGui & S )
{ {
wxString informationStr; // string to build up list of information in wxStringOutputStream o;
wxTextOutputStream informationStr( o ); // string to build up list of information in
S.StartNotebookPage( XO("Build Information") ); // start the tab S.StartNotebookPage( XO("Build Information") ); // start the tab
S.StartVerticalLay(2); // create the window S.StartVerticalLay(2); // create the window
HtmlWindow *html = safenew LinkingHtmlWindow(S.GetParent(), -1, wxDefaultPosition, HtmlWindow *html = safenew LinkingHtmlWindow(S.GetParent(), -1, wxDefaultPosition,
@ -476,18 +510,20 @@ void AboutDialog::PopulateInformationPage( ShuttleGui & S )
/* this builds up the list of information to go in the window in the string /* this builds up the list of information to go in the window in the string
* informationStr */ * informationStr */
informationStr = wxT("<h2><center>"); informationStr
informationStr += _("Build Information"); << wxT("<h2><center>")
informationStr += wxT("</center></h2>\n"); << XO("Build Information")
informationStr += VerCheckHtml(); << wxT("</center></h2>\n")
// top level heading << VerCheckHtml()
informationStr += wxT("<h3>"); // top level heading
informationStr += _("File Format Support"); << wxT("<h3>")
informationStr += wxT("</h3>\n<p>"); << XO("File Format Support")
<< wxT("</h3>\n<p>");
// 2nd level headings to split things up a bit // 2nd level headings to split things up a bit
informationStr += wxT("<table>"); // start table of libraries informationStr
<< wxT("<table>"); // start table of libraries
#ifdef USE_LIBMAD #ifdef USE_LIBMAD
@ -553,11 +589,12 @@ void AboutDialog::PopulateInformationPage( ShuttleGui & S )
AddBuildinfoRow(&informationStr, wxT("gstreamer"), XO("Import via GStreamer"), disabled); AddBuildinfoRow(&informationStr, wxT("gstreamer"), XO("Import via GStreamer"), disabled);
#endif #endif
informationStr += wxT("</table>\n"); //end table of file format libraries informationStr
informationStr += wxT("<h3>"); << wxT("</table>\n") //end table of file format libraries
/* i18n-hint: Libraries that are essential to audacity */ << wxT("<h3>")
informationStr += _("Core Libraries"); /* i18n-hint: Libraries that are essential to audacity */
informationStr += wxT("</h3>\n<table>"); // start table of features << XO("Core Libraries")
<< wxT("</h3>\n<table>"); // start table of features
AddBuildinfoRow(&informationStr, wxT("libsoxr"), AddBuildinfoRow(&informationStr, wxT("libsoxr"),
XO("Sample rate conversion"), enabled); XO("Sample rate conversion"), enabled);
@ -568,10 +605,11 @@ void AboutDialog::PopulateInformationPage( ShuttleGui & S )
AddBuildinfoRow(&informationStr, wxT("wxWidgets"), AddBuildinfoRow(&informationStr, wxT("wxWidgets"),
XO("Cross-platform GUI library"), wxVERSION_NUM_DOT_STRING_T); XO("Cross-platform GUI library"), wxVERSION_NUM_DOT_STRING_T);
informationStr += wxT("</table>\n"); //end table of libraries informationStr
informationStr += wxT("<h3>"); << wxT("</table>\n") //end table of libraries
informationStr += _("Features"); << wxT("<h3>")
informationStr += wxT("</h3>\n<table>"); // start table of features << XO("Features")
<< wxT("</h3>\n<table>"); // start table of features
#ifdef EXPERIMENTAL_DA #ifdef EXPERIMENTAL_DA
AddBuildinfoRow(&informationStr, wxT("Theme"), XO("Dark Theme Extras"), enabled); AddBuildinfoRow(&informationStr, wxT("Theme"), XO("Dark Theme Extras"), enabled);
@ -651,12 +689,13 @@ void AboutDialog::PopulateInformationPage( ShuttleGui & S )
disabled); disabled);
# endif # endif
informationStr += wxT("</table>\n"); // end of table of features informationStr << wxT("</table>\n"); // end of table of features
informationStr += wxT("<h3>"); informationStr
<< wxT("<h3>")
/* i18n-hint: Information about when audacity was compiled */ /* i18n-hint: Information about when audacity was compiled */
informationStr += _("Build Information"); << XO("Build Information")
informationStr += wxT("</h3>\n<table>"); << wxT("</h3>\n<table>");
// Current date // Current date
AddBuildinfoRow(&informationStr, XO("Program build date:"), __TDATE__); AddBuildinfoRow(&informationStr, XO("Program build date:"), __TDATE__);
@ -702,11 +741,9 @@ void AboutDialog::PopulateInformationPage( ShuttleGui & S )
AddBuildinfoRow(&informationStr, XO("Settings folder:"), \ AddBuildinfoRow(&informationStr, XO("Settings folder:"), \
FileNames::DataDir()); FileNames::DataDir());
// end of table // end of table
informationStr += wxT("</table>\n"); informationStr << wxT("</table>\n");
informationStr = FormatHtmlText( informationStr ); html->SetPage( FormatHtmlText( o.GetString() ) ); // push the page into the html renderer
html->SetPage(informationStr); // push the page into the html renderer
S.Prop(2) S.Prop(2)
.Position( wxEXPAND ) .Position( wxEXPAND )
.AddWindow( html ); // make it fill the page .AddWindow( html ); // make it fill the page
@ -1064,16 +1101,17 @@ wxString AboutDialog::GetCreditsByRole(AboutDialog::Role role)
* Used when creating the build information tab to show if each optional * Used when creating the build information tab to show if each optional
* library is enabled or not, and what it does */ * library is enabled or not, and what it does */
void AboutDialog::AddBuildinfoRow( void AboutDialog::AddBuildinfoRow(
wxString* htmlstring, const wxChar * libname, wxTextOutputStream *str, const wxChar * libname,
const TranslatableString &libdesc, const wxString &status) const TranslatableString &libdesc, const wxString &status)
{ {
*htmlstring += wxT("<tr><td>"); *str
*htmlstring += libname; << wxT("<tr><td>")
*htmlstring += wxT("</td><td>("); << libname
*htmlstring += libdesc.Translation(); << wxT("</td><td>(")
*htmlstring += wxT(")</td><td>"); << libdesc
*htmlstring += status; << wxT(")</td><td>")
*htmlstring += wxT("</td></tr>"); << status
<< wxT("</td></tr>");
} }
/** \brief Add a table row saying if a library is used or not /** \brief Add a table row saying if a library is used or not
@ -1081,13 +1119,15 @@ void AboutDialog::AddBuildinfoRow(
* Used when creating the build information tab to show build dates and * Used when creating the build information tab to show build dates and
* file paths */ * file paths */
void AboutDialog::AddBuildinfoRow( void AboutDialog::AddBuildinfoRow(
wxString* htmlstring, const TranslatableString &description, const wxChar *spec) wxTextOutputStream *str,
const TranslatableString &description, const wxChar *spec)
{ {
*htmlstring += wxT("<tr><td>"); *str
*htmlstring += description.Translation(); << wxT("<tr><td>")
*htmlstring += wxT("</td><td>"); << description
*htmlstring += spec; << wxT("</td><td>")
*htmlstring += wxT("</td></tr>"); << spec
<< wxT("</td></tr>");
} }
AboutDialog::~AboutDialog() AboutDialog::~AboutDialog()

View File

@ -15,6 +15,7 @@
#include "widgets/wxPanelWrapper.h" // to inherit #include "widgets/wxPanelWrapper.h" // to inherit
class wxStaticBitmap; class wxStaticBitmap;
class wxTextOutputStream;
class ShuttleGui; class ShuttleGui;
@ -64,10 +65,10 @@ class AboutDialog final : public wxDialogWrapper {
void AddCredit( const wxString &name, TranslatableString format, Role role ); void AddCredit( const wxString &name, TranslatableString format, Role role );
wxString GetCreditsByRole(AboutDialog::Role role); wxString GetCreditsByRole(AboutDialog::Role role);
void AddBuildinfoRow( wxString* htmlstring, const wxChar * libname, void AddBuildinfoRow( wxTextOutputStream *str, const wxChar * libname,
const TranslatableString &libdesc, const wxString &status); const TranslatableString &libdesc, const wxString &status);
void AddBuildinfoRow( wxString* htmlstring, const TranslatableString &description, void AddBuildinfoRow( wxTextOutputStream *str,
const wxChar *spec); const TranslatableString &description, const wxChar *spec);
}; };
#endif #endif

View File

@ -842,7 +842,8 @@ wxString AudioIOBase::GetDeviceInfo()
wxTextOutputStream s(o, wxEOL_UNIX); wxTextOutputStream s(o, wxEOL_UNIX);
if (IsStreamActive()) { if (IsStreamActive()) {
return _("Stream is active ... unable to gather information.\n"); return XO("Stream is active ... unable to gather information.\n")
.Translation();
} }
@ -855,8 +856,8 @@ wxString AudioIOBase::GetDeviceInfo()
wxLogDebug(wxT("Portaudio reports %d audio devices"),cnt); wxLogDebug(wxT("Portaudio reports %d audio devices"),cnt);
s << wxT("==============================\n"); s << wxT("==============================\n");
s << wxString::Format(_("Default recording device number: %d\n"), recDeviceNum); s << XO("Default recording device number: %d\n").Format( recDeviceNum );
s << wxString::Format(_("Default playback device number: %d\n"), playDeviceNum); s << XO("Default playback device number: %d\n").Format( playDeviceNum);
wxString recDevice = gPrefs->Read(wxT("/AudioIO/RecordingDevice"), wxT("")); wxString recDevice = gPrefs->Read(wxT("/AudioIO/RecordingDevice"), wxT(""));
wxString playDevice = gPrefs->Read(wxT("/AudioIO/PlaybackDevice"), wxT("")); wxString playDevice = gPrefs->Read(wxT("/AudioIO/PlaybackDevice"), wxT(""));
@ -864,7 +865,7 @@ wxString AudioIOBase::GetDeviceInfo()
// This gets info on all available audio devices (input and output) // This gets info on all available audio devices (input and output)
if (cnt <= 0) { if (cnt <= 0) {
s << _("No devices found\n"); s << XO("No devices found\n");
return o.GetString(); return o.GetString();
} }
@ -875,25 +876,25 @@ wxString AudioIOBase::GetDeviceInfo()
info = Pa_GetDeviceInfo(j); info = Pa_GetDeviceInfo(j);
if (!info) { if (!info) {
s << wxString::Format(_("Device info unavailable for: %d\n"), j); s << XO("Device info unavailable for: %d\n").Format( j );
continue; continue;
} }
wxString name = DeviceName(info); wxString name = DeviceName(info);
s << wxString::Format(_("Device ID: %d\n"), j); s << XO("Device ID: %d\n").Format( j );
s << wxString::Format(_("Device name: %s\n"), name); s << XO("Device name: %s\n").Format( name );
s << wxString::Format(_("Host name: %s\n"), HostName(info)); s << XO("Host name: %s\n").Format( HostName(info) );
s << wxString::Format(_("Recording channels: %d\n"), info->maxInputChannels); s << XO("Recording channels: %d\n").Format( info->maxInputChannels );
s << wxString::Format(_("Playback channels: %d\n"), info->maxOutputChannels); s << XO("Playback channels: %d\n").Format( info->maxOutputChannels );
s << wxString::Format(_("Low Recording Latency: %g\n"), info->defaultLowInputLatency); s << XO("Low Recording Latency: %g\n").Format( info->defaultLowInputLatency );
s << wxString::Format(_("Low Playback Latency: %g\n"), info->defaultLowOutputLatency); s << XO("Low Playback Latency: %g\n").Format( info->defaultLowOutputLatency );
s << wxString::Format(_("High Recording Latency: %g\n"), info->defaultHighInputLatency); s << XO("High Recording Latency: %g\n").Format( info->defaultHighInputLatency );
s << wxString::Format(_("High Playback Latency: %g\n"), info->defaultHighOutputLatency); s << XO("High Playback Latency: %g\n").Format( info->defaultHighOutputLatency );
auto rates = GetSupportedPlaybackRates(j, 0.0); auto rates = GetSupportedPlaybackRates(j, 0.0);
/* i18n-hint: Supported, meaning made available by the system */ /* i18n-hint: Supported, meaning made available by the system */
s << _("Supported Rates:\n"); s << XO("Supported Rates:\n");
for (int k = 0; k < (int) rates.size(); k++) { for (int k = 0; k < (int) rates.size(); k++) {
s << wxT(" ") << (int)rates[k] << wxT("\n"); s << wxT(" ") << (int)rates[k] << wxT("\n");
} }
@ -919,27 +920,27 @@ wxString AudioIOBase::GetDeviceInfo()
s << wxT("==============================\n"); s << wxT("==============================\n");
if (haveRecDevice) if (haveRecDevice)
s << wxString::Format(_("Selected recording device: %d - %s\n"), recDeviceNum, recDevice); s << XO("Selected recording device: %d - %s\n").Format( recDeviceNum, recDevice );
else else
s << wxString::Format(_("No recording device found for '%s'.\n"), recDevice); s << XO("No recording device found for '%s'.\n").Format( recDevice );
if (havePlayDevice) if (havePlayDevice)
s << wxString::Format(_("Selected playback device: %d - %s\n"), playDeviceNum, playDevice); s << XO("Selected playback device: %d - %s\n").Format( playDeviceNum, playDevice );
else else
s << wxString::Format(_("No playback device found for '%s'.\n"), playDevice); s << XO("No playback device found for '%s'.\n").Format( playDevice );
std::vector<long> supportedSampleRates; std::vector<long> supportedSampleRates;
if (havePlayDevice && haveRecDevice) { if (havePlayDevice && haveRecDevice) {
supportedSampleRates = GetSupportedSampleRates(playDeviceNum, recDeviceNum); supportedSampleRates = GetSupportedSampleRates(playDeviceNum, recDeviceNum);
s << _("Supported Rates:\n"); s << XO("Supported Rates:\n");
for (int k = 0; k < (int) supportedSampleRates.size(); k++) { for (int k = 0; k < (int) supportedSampleRates.size(); k++) {
s << wxT(" ") << (int)supportedSampleRates[k] << wxT("\n"); s << wxT(" ") << (int)supportedSampleRates[k] << wxT("\n");
} }
} }
else { else {
s << _("Cannot check mutual sample rates without both devices.\n"); s << XO("Cannot check mutual sample rates without both devices.\n");
return o.GetString(); return o.GetString();
} }
@ -999,42 +1000,42 @@ wxString AudioIOBase::GetDeviceInfo()
} }
if (error) { if (error) {
s << wxString::Format(_("Received %d while opening devices\n"), error); s << XO("Received %d while opening devices\n").Format( error );
return o.GetString(); return o.GetString();
} }
PxMixer *PortMixer = Px_OpenMixer(stream, 0); PxMixer *PortMixer = Px_OpenMixer(stream, 0);
if (!PortMixer) { if (!PortMixer) {
s << _("Unable to open Portmixer\n"); s << XO("Unable to open Portmixer\n");
Pa_CloseStream(stream); Pa_CloseStream(stream);
return o.GetString(); return o.GetString();
} }
s << wxT("==============================\n"); s << wxT("==============================\n");
s << _("Available mixers:\n"); s << XO("Available mixers:\n");
// FIXME: ? PortMixer errors on query not reported in GetDeviceInfo // FIXME: ? PortMixer errors on query not reported in GetDeviceInfo
cnt = Px_GetNumMixers(stream); cnt = Px_GetNumMixers(stream);
for (int i = 0; i < cnt; i++) { for (int i = 0; i < cnt; i++) {
wxString name = wxSafeConvertMB2WX(Px_GetMixerName(stream, i)); wxString name = wxSafeConvertMB2WX(Px_GetMixerName(stream, i));
s << wxString::Format(_("%d - %s\n"), i, name); s << XO("%d - %s\n").Format( i, name );
} }
s << wxT("==============================\n"); s << wxT("==============================\n");
s << _("Available recording sources:\n"); s << XO("Available recording sources:\n");
cnt = Px_GetNumInputSources(PortMixer); cnt = Px_GetNumInputSources(PortMixer);
for (int i = 0; i < cnt; i++) { for (int i = 0; i < cnt; i++) {
wxString name = wxSafeConvertMB2WX(Px_GetInputSourceName(PortMixer, i)); wxString name = wxSafeConvertMB2WX(Px_GetInputSourceName(PortMixer, i));
s << wxString::Format(_("%d - %s\n"), i, name); s << XO("%d - %s\n").Format( i, name );
} }
s << wxT("==============================\n"); s << wxT("==============================\n");
s << _("Available playback volumes:\n"); s << XO("Available playback volumes:\n");
cnt = Px_GetNumOutputVolumes(PortMixer); cnt = Px_GetNumOutputVolumes(PortMixer);
for (int i = 0; i < cnt; i++) { for (int i = 0; i < cnt; i++) {
wxString name = wxSafeConvertMB2WX(Px_GetOutputVolumeName(PortMixer, i)); wxString name = wxSafeConvertMB2WX(Px_GetOutputVolumeName(PortMixer, i));
s << wxString::Format(_("%d - %s\n"), i, name); s << XO("%d - %s\n").Format( i, name );
} }
// Determine mixer capabilities - it it doesn't support either // Determine mixer capabilities - it it doesn't support either
@ -1067,11 +1068,11 @@ wxString AudioIOBase::GetDeviceInfo()
s << wxT("==============================\n"); s << wxT("==============================\n");
s << ( EmulateMixerInputVol s << ( EmulateMixerInputVol
? _("Recording volume is emulated\n") ? XO("Recording volume is emulated\n")
: _("Recording volume is native\n") ); : XO("Recording volume is native\n") );
s << ( EmulateMixerOutputVol s << ( EmulateMixerOutputVol
? _("Playback volume is emulated\n") ? XO("Playback volume is emulated\n")
: _("Playback volume is native\n") ); : XO("Playback volume is native\n") );
Px_CloseMixer(PortMixer); Px_CloseMixer(PortMixer);
@ -1088,7 +1089,8 @@ wxString AudioIOBase::GetMidiDeviceInfo()
wxTextOutputStream s(o, wxEOL_UNIX); wxTextOutputStream s(o, wxEOL_UNIX);
if (IsStreamActive()) { if (IsStreamActive()) {
return _("Stream is active ... unable to gather information.\n"); return XO("Stream is active ... unable to gather information.\n")
.Translation();
} }
@ -1101,15 +1103,15 @@ wxString AudioIOBase::GetMidiDeviceInfo()
wxLogDebug(wxT("PortMidi reports %d MIDI devices"), cnt); wxLogDebug(wxT("PortMidi reports %d MIDI devices"), cnt);
s << wxT("==============================\n"); s << wxT("==============================\n");
s << wxString::Format(_("Default recording device number: %d\n"), recDeviceNum); s << XO("Default recording device number: %d\n").Format( recDeviceNum );
s << wxString::Format(_("Default playback device number: %d\n"), playDeviceNum); s << XO("Default playback device number: %d\n").Format( playDeviceNum );
wxString recDevice = gPrefs->Read(wxT("/MidiIO/RecordingDevice"), wxT("")); wxString recDevice = gPrefs->Read(wxT("/MidiIO/RecordingDevice"), wxT(""));
wxString playDevice = gPrefs->Read(wxT("/MidiIO/PlaybackDevice"), wxT("")); wxString playDevice = gPrefs->Read(wxT("/MidiIO/PlaybackDevice"), wxT(""));
// This gets info on all available audio devices (input and output) // This gets info on all available audio devices (input and output)
if (cnt <= 0) { if (cnt <= 0) {
s << _("No devices found\n"); s << XO("No devices found\n");
return o.GetString(); return o.GetString();
} }
@ -1118,20 +1120,20 @@ wxString AudioIOBase::GetMidiDeviceInfo()
const PmDeviceInfo* info = Pm_GetDeviceInfo(i); const PmDeviceInfo* info = Pm_GetDeviceInfo(i);
if (!info) { if (!info) {
s << wxString::Format(_("Device info unavailable for: %d\n"), i); s << XO("Device info unavailable for: %d\n").Format( i );
continue; continue;
} }
wxString name = wxSafeConvertMB2WX(info->name); wxString name = wxSafeConvertMB2WX(info->name);
wxString hostName = wxSafeConvertMB2WX(info->interf); wxString hostName = wxSafeConvertMB2WX(info->interf);
s << wxString::Format(_("Device ID: %d\n"), i); s << XO("Device ID: %d\n").Format( i );
s << wxString::Format(_("Device name: %s\n"), name); s << XO("Device name: %s\n").Format( name );
s << wxString::Format(_("Host name: %s\n"), hostName); s << XO("Host name: %s\n").Format( hostName );
/* i18n-hint: Supported, meaning made available by the system */ /* i18n-hint: Supported, meaning made available by the system */
s << wxString::Format(_("Supports output: %d\n"), info->output); s << XO("Supports output: %d\n").Format( info->output );
s << wxString::Format(_("Supports input: %d\n"), info->input); s << XO("Supports input: %d\n").Format( info->input );
s << wxString::Format(_("Opened: %d\n"), info->opened); s << XO("Opened: %d\n").Format( info->opened );
if (name == playDevice && info->output) if (name == playDevice && info->output)
playDeviceNum = i; playDeviceNum = i;
@ -1154,14 +1156,14 @@ wxString AudioIOBase::GetMidiDeviceInfo()
s << wxT("==============================\n"); s << wxT("==============================\n");
if (haveRecDevice) if (haveRecDevice)
s << wxString::Format(_("Selected MIDI recording device: %d - %s\n"), recDeviceNum, recDevice); s << XO("Selected MIDI recording device: %d - %s\n").Format( recDeviceNum, recDevice );
else else
s << wxString::Format(_("No MIDI recording device found for '%s'.\n"), recDevice); s << XO("No MIDI recording device found for '%s'.\n").Format( recDevice );
if (havePlayDevice) if (havePlayDevice)
s << wxString::Format(_("Selected MIDI playback device: %d - %s\n"), playDeviceNum, playDevice); s << XO("Selected MIDI playback device: %d - %s\n").Format( playDeviceNum, playDevice );
else else
s << wxString::Format(_("No MIDI playback device found for '%s'.\n"), playDevice); s << XO("No MIDI playback device found for '%s'.\n").Format( playDevice );
// Mention our conditional compilation flags for Alpha only // Mention our conditional compilation flags for Alpha only
#ifdef IS_ALPHA #ifdef IS_ALPHA

View File

@ -62,7 +62,7 @@ private:
void OnClear( wxCommandEvent &event ); void OnClear( wxCommandEvent &event );
void OnClose( wxCommandEvent &event ); void OnClose( wxCommandEvent &event );
void Printf(const wxChar *format, ...); void Printf(const TranslatableString &str);
void HoldPrint(bool hold); void HoldPrint(bool hold);
void FlushPrint(); void FlushPrint();
@ -257,7 +257,7 @@ void BenchmarkDialog::OnSave( wxCommandEvent & WXUNUSED(event))
{ {
/* i18n-hint: Benchmark means a software speed test; /* i18n-hint: Benchmark means a software speed test;
leave untranslated file extension .txt */ leave untranslated file extension .txt */
wxString fName = _("benchmark.txt"); auto fName = XO("benchmark.txt").Translation();
fName = FileNames::SelectFile(FileNames::Operation::Export, fName = FileNames::SelectFile(FileNames::Operation::Export,
XO("Export Benchmark Data as:"), XO("Export Benchmark Data as:"),
@ -279,17 +279,12 @@ void BenchmarkDialog::OnClear(wxCommandEvent & WXUNUSED(event))
mText->Clear(); mText->Clear();
} }
void BenchmarkDialog::Printf(const wxChar *format, ...) void BenchmarkDialog::Printf(const TranslatableString &str)
{ {
va_list argptr; auto s = str.Translation();
va_start(argptr, format);
wxString s = wxString::FormatV(format, argptr);
mToPrint += s; mToPrint += s;
if (!mHoldPrint) if (!mHoldPrint)
FlushPrint(); FlushPrint();
va_end(argptr);
} }
void BenchmarkDialog::HoldPrint(bool hold) void BenchmarkDialog::HoldPrint(bool hold)
@ -385,8 +380,8 @@ void BenchmarkDialog::OnRun( wxCommandEvent & WXUNUSED(event))
// They are (and are supposed to be) a different size to // They are (and are supposed to be) a different size to
// the blocks that make the blockfiles. That way we get to // the blocks that make the blockfiles. That way we get to
// do some testing of when edit chunks cross blockfile boundaries. // do some testing of when edit chunks cross blockfile boundaries.
Printf(_("Using %d chunks of %d samples each, for a total of %.1f MB.\n"), Printf( XO("Using %ld chunks of %ld samples each, for a total of %.1f MB.\n")
nChunks, chunkSize, nChunks*chunkSize*sizeof(short)/1048576.0); .Format( nChunks, chunkSize, nChunks*chunkSize*sizeof(short)/1048576.0 ) );
int trials = numEdits; int trials = numEdits;
@ -394,7 +389,7 @@ void BenchmarkDialog::OnRun( wxCommandEvent & WXUNUSED(event))
Shorts small1{ nChunks }; Shorts small1{ nChunks };
Shorts block{ chunkSize }; Shorts block{ chunkSize };
Printf(_("Preparing...\n")); Printf( XO("Preparing...\n") );
wxTheApp->Yield(); wxTheApp->Yield();
FlushPrint(); FlushPrint();
@ -422,12 +417,15 @@ void BenchmarkDialog::OnRun( wxCommandEvent & WXUNUSED(event))
t->GetEndTime(); t->GetEndTime();
if (t->GetClipByIndex(0)->GetSequence()->GetNumSamples() != nChunks * chunkSize) { if (t->GetClipByIndex(0)->GetSequence()->GetNumSamples() != nChunks * chunkSize) {
Printf(_("Expected len %d, track len %lld.\n"), nChunks * chunkSize, Printf( XO("Expected len %ld, track len %lld.\n")
t->GetClipByIndex(0)->GetSequence()->GetNumSamples().as_long_long()); .Format(
nChunks * chunkSize,
t->GetClipByIndex(0)->GetSequence()->GetNumSamples()
.as_long_long() ) );
goto fail; goto fail;
} }
Printf(_("Performing %d edits...\n"), trials); Printf( XO("Performing %d edits...\n").Format( trials ) );
wxTheApp->Yield(); wxTheApp->Yield();
FlushPrint(); FlushPrint();
@ -441,18 +439,22 @@ void BenchmarkDialog::OnRun( wxCommandEvent & WXUNUSED(event))
// 1 <= xlen <= nChunks - x0 // 1 <= xlen <= nChunks - x0
const size_t xlen = 1 + (rand() % (nChunks - x0)); const size_t xlen = 1 + (rand() % (nChunks - x0));
if (mEditDetail) if (mEditDetail)
Printf(_("Cut: %d - %d \n"), x0 * chunkSize, (x0 + xlen) * chunkSize); Printf( XO("Cut: %ld - %ld \n")
.Format( x0 * chunkSize, (x0 + xlen) * chunkSize) );
Track::Holder tmp; Track::Holder tmp;
try { try {
tmp = t->Cut(double (x0 * chunkSize), double ((x0 + xlen) * chunkSize)); tmp = t->Cut(double (x0 * chunkSize), double ((x0 + xlen) * chunkSize));
} }
catch (const AudacityException&) { catch (const AudacityException&) {
Printf(_("Trial %d\n"), z); Printf( XO("Trial %d\n").Format( z ) );
Printf(_("Cut (%d, %d) failed.\n"), (x0 * chunkSize), Printf( XO("Cut (%ld, %ld) failed.\n")
(x0 + xlen) * chunkSize); .Format( (x0 * chunkSize), (x0 + xlen) * chunkSize) );
Printf(_("Expected len %d, track len %lld.\n"), nChunks * chunkSize, Printf( XO("Expected len %ld, track len %lld.\n")
t->GetClipByIndex(0)->GetSequence()->GetNumSamples().as_long_long()); .Format(
nChunks * chunkSize,
t->GetClipByIndex(0)->GetSequence()->GetNumSamples()
.as_long_long() ) );
goto fail; goto fail;
} }
@ -461,20 +463,23 @@ void BenchmarkDialog::OnRun( wxCommandEvent & WXUNUSED(event))
const size_t y0 = rand() % (nChunks - xlen + 1); const size_t y0 = rand() % (nChunks - xlen + 1);
if (mEditDetail) if (mEditDetail)
Printf(_("Paste: %d\n"), y0 * chunkSize); Printf( XO("Paste: %ld\n").Format( y0 * chunkSize ) );
try { try {
t->Paste((double)(y0 * chunkSize), tmp.get()); t->Paste((double)(y0 * chunkSize), tmp.get());
} }
catch (const AudacityException&) { catch (const AudacityException&) {
Printf(_("Trial %d\nFailed on Paste.\n"), z); Printf( XO("Trial %d\nFailed on Paste.\n").Format( z ) );
goto fail; goto fail;
} }
if (t->GetClipByIndex(0)->GetSequence()->GetNumSamples() != nChunks * chunkSize) { if (t->GetClipByIndex(0)->GetSequence()->GetNumSamples() != nChunks * chunkSize) {
Printf(_("Trial %d\n"), z); Printf( XO("Trial %d\n").Format( z ) );
Printf(_("Expected len %d, track len %lld.\n"), nChunks * chunkSize, Printf( XO("Expected len %ld, track len %lld.\n")
t->GetClipByIndex(0)->GetSequence()->GetNumSamples().as_long_long()); .Format(
nChunks * chunkSize,
t->GetClipByIndex(0)->GetSequence()->GetNumSamples()
.as_long_long() ) );
goto fail; goto fail;
} }
@ -492,19 +497,19 @@ void BenchmarkDialog::OnRun( wxCommandEvent & WXUNUSED(event))
seq->DebugPrintf(seq->GetBlockArray(), seq->GetNumSamples(), &tempStr); seq->DebugPrintf(seq->GetBlockArray(), seq->GetNumSamples(), &tempStr);
mToPrint += tempStr; mToPrint += tempStr;
} }
Printf(_("Time to perform %d edits: %ld ms\n"), trials, elapsed); Printf( XO("Time to perform %d edits: %ld ms\n").Format( trials, elapsed ) );
FlushPrint(); FlushPrint();
wxTheApp->Yield(); wxTheApp->Yield();
#if 0 #if 0
Printf(_("Checking file pointer leaks:\n")); Printf( XO("Checking file pointer leaks:\n") );
Printf(_("Track # blocks: %d\n"), t->GetBlockArray()->size()); Printf( XO("Track # blocks: %ld\n").Format( t->GetBlockArray()->size() ) );
Printf(_("Disk # blocks: \n")); Printf( XO("Disk # blocks: \n") );
system("ls .audacity_temp/* | wc --lines"); system("ls .audacity_temp/* | wc --lines");
#endif #endif
Printf(_("Doing correctness check...\n")); Printf( XO("Doing correctness check...\n") );
FlushPrint(); FlushPrint();
wxTheApp->Yield(); wxTheApp->Yield();
@ -517,19 +522,19 @@ void BenchmarkDialog::OnRun( wxCommandEvent & WXUNUSED(event))
if (block[b] != v) { if (block[b] != v) {
bad++; bad++;
if (bad < 10) if (bad < 10)
Printf(_("Bad: chunk %d sample %d\n"), i, b); Printf( XO("Bad: chunk %ld sample %ld\n").Format( i, b ) );
b = chunkSize; b = chunkSize;
} }
} }
if (bad == 0) if (bad == 0)
Printf(_("Passed correctness check!\n")); Printf( XO("Passed correctness check!\n") );
else else
Printf(_("Errors in %d/%d chunks\n"), bad, nChunks); Printf( XO("Errors in %d/%ld chunks\n").Format( bad, nChunks ) );
elapsed = timer.Time(); elapsed = timer.Time();
Printf(_("Time to check all data: %ld ms\n"), elapsed); Printf( XO("Time to check all data: %ld ms\n").Format( elapsed ) );
Printf(_("Reading data again...\n")); Printf( XO("Reading data again...\n") );
wxTheApp->Yield(); wxTheApp->Yield();
FlushPrint(); FlushPrint();
@ -546,20 +551,20 @@ void BenchmarkDialog::OnRun( wxCommandEvent & WXUNUSED(event))
elapsed = timer.Time(); elapsed = timer.Time();
Printf(_("Time to check all data (2): %ld ms\n"), elapsed); Printf( XO("Time to check all data (2): %ld ms\n").Format( elapsed ) );
Printf(_("At 44100 Hz, 16-bits per sample, the estimated number of\n simultaneous tracks that could be played at once: %.1f\n"), Printf( XO("At 44100 Hz, 16-bits per sample, the estimated number of\n simultaneous tracks that could be played at once: %.1f\n" )
(nChunks*chunkSize/44100.0)/(elapsed/1000.0)); .Format( (nChunks*chunkSize/44100.0)/(elapsed/1000.0) ) );
goto success; goto success;
fail: fail:
Printf(_("TEST FAILED!!!\n")); Printf( XO("TEST FAILED!!!\n") );
success: success:
dd.reset(); dd.reset();
Printf(_("Benchmark completed successfully.\n")); Printf( XO("Benchmark completed successfully.\n") );
HoldPrint(false); HoldPrint(false);
} }

View File

@ -68,6 +68,9 @@ and in the spectrogram spectral selection.
#include <wx/textctrl.h> #include <wx/textctrl.h>
#include <wx/textfile.h> #include <wx/textfile.h>
#include <wx/wfstream.h>
#include <wx/txtstrm.h>
#include <math.h> #include <math.h>
#include "ShuttleGui.h" #include "ShuttleGui.h"
@ -1073,31 +1076,32 @@ void FrequencyPlotDialog::OnExport(wxCommandEvent & WXUNUSED(event))
if (fName.empty()) if (fName.empty())
return; return;
wxTextFile f(fName); wxFFileOutputStream ffStream{ fName };
f.Create(); if (!ffStream.IsOk()) {
f.Open();
if (!f.IsOpened()) {
AudacityMessageBox( XO("Couldn't write to file: %s").Format( fName ) ); AudacityMessageBox( XO("Couldn't write to file: %s").Format( fName ) );
return; return;
} }
wxTextOutputStream ss(ffStream);
const int processedSize = mAnalyst->GetProcessedSize(); const int processedSize = mAnalyst->GetProcessedSize();
const float *const processed = mAnalyst->GetProcessed(); const float *const processed = mAnalyst->GetProcessed();
if (mAlgChoice->GetSelection() == 0) { if (mAlgChoice->GetSelection() == 0) {
f.AddLine(_("Frequency (Hz)\tLevel (dB)")); ss
<< XO("Frequency (Hz)\tLevel (dB)") << '\n';
for (int i = 1; i < processedSize; i++) for (int i = 1; i < processedSize; i++)
f.AddLine(wxString:: ss
Format(wxT("%f\t%f"), i * mRate / mWindowSize, << wxString::Format(wxT("%f\t%f\n"),
processed[i])); i * mRate / mWindowSize, processed[i] );
} else { }
f.AddLine(_("Lag (seconds)\tFrequency (Hz)\tLevel")); else {
for (int i = 1; i < processedSize; i++) ss
f.AddLine(wxString::Format(wxT("%f\t%f\t%f"), << XO("Lag (seconds)\tFrequency (Hz)\tLevel") << '\n';
i / mRate, mRate / i, processed[i])); for (int i = 1; i < processedSize; i++)
ss
<< wxString::Format(wxT("%f\t%f\t%f\n"),
i / mRate, mRate / i, processed[i] );
} }
f.Write();
f.Close();
} }
void FrequencyPlotDialog::OnReplot(wxCommandEvent & WXUNUSED(event)) void FrequencyPlotDialog::OnReplot(wxCommandEvent & WXUNUSED(event))

View File

@ -19,6 +19,8 @@
#include <wx/string.h> #include <wx/string.h>
#include <wx/intl.h> #include <wx/intl.h>
#include <wx/sstream.h>
#include <wx/txtstrm.h>
#include "FileNames.h" #include "FileNames.h"
#include "Internat.h" #include "Internat.h"
@ -206,50 +208,80 @@ TranslatableString TitleText( const wxString & Key )
static wxString HelpTextBuiltIn( const wxString & Key ) static wxString HelpTextBuiltIn( const wxString & Key )
{ {
// PRL: Is it necessary to define these outside of conditional compilation so that both get into the .pot file? // PRL: Is it necessary to define these outside of conditional compilation so that both get into the .pot file?
auto alphamsg = _("<br><br>The version of Audacity you are using is an <b>Alpha test version</b>."); const auto alphamsg = XO(
auto betamsg = _("<br><br>The version of Audacity you are using is a <b>Beta test version</b>."); "<br><br>The version of Audacity you are using is an <b>Alpha test version</b>.");
const auto betamsg = XO(
"<br><br>The version of Audacity you are using is a <b>Beta test version</b>.");
if (Key == wxT("welcome")) if (Key == wxT("welcome"))
{ {
/* i18n-hint: Preserve '[[help:Quick_Help|' as it's the name of a link.*/ /* i18n-hint: Preserve '[[help:Quick_Help|' as it's the name of a link.*/
/* i18n-hint: Preserve '[[help:Main_Page|' as it's the name of a link.*/ /* i18n-hint: Preserve '[[help:Main_Page|' as it's the name of a link.*/
wxString result = wxStringOutputStream o;
wxString(wxT("")) + wxTextOutputStream s(o);
s
#if defined(IS_ALPHA) || defined(IS_BETA) #if defined(IS_ALPHA) || defined(IS_BETA)
wxT("<hr><center><h3>") + _("Get the Official Released Version of Audacity") + wxT("</h3></center>") + << wxT("<hr><center><h3>")
VerCheckHtml() + << XO("Get the Official Released Version of Audacity")
<< wxT("</h3></center>")
<< VerCheckHtml()
#ifdef IS_ALPHA #ifdef IS_ALPHA
alphamsg << alphamsg
#else #else
betamsg << betamsg
#endif #endif
+ " " + << wxT(" ")
_("We strongly recommend that you use our latest stable released version, which has full documentation and support.<br><br>") + << XO(
_("You can help us get Audacity ready for release by joining our [[https://www.audacityteam.org/community/|community]].<hr><br><br>") + "We strongly recommend that you use our latest stable released version, which has full documentation and support.<br><br>")
<< XO(
"You can help us get Audacity ready for release by joining our [[https://www.audacityteam.org/community/|community]].<hr><br><br>")
#endif #endif
// DA: Support methods text. // DA: Support methods text.
#ifdef EXPERIMENTAL_DA #ifdef EXPERIMENTAL_DA
// Deliberately not translated. // Deliberately not translated.
wxT("<center><h3>DarkAudacity ") + AUDACITY_VERSION_STRING + wxT("</h3></center>") + << wxT("<center><h3>DarkAudacity ")
wxT("<br><br>DarkAudacity is based on Audacity:") + wxT("<ul><li>") + << AUDACITY_VERSION_STRING
wxT(" [[http://www.darkaudacity.com|www.darkaudacity.com]] - for differences between them.") + wxT("</li><li>") + << wxT("</h3></center>")
wxT(" email to [[mailto:james@audacityteam.org|james@audacityteam.org]] - for help using DarkAudacity.") + wxT("</li><li>") + << wxT("<br><br>DarkAudacity is based on Audacity:")
wxT(" [[http://www.darkaudacity.com/video.html|Tutorials]] - for getting started with DarkAudacity.") + wxT("</li></ul>") + << wxT("<ul><li>")
<< wxT(" [[http://www.darkaudacity.com|www.darkaudacity.com]] - for differences between them.")
wxT("<br><br>Audacity has these support methods:") + wxT("<ul><li>") + << wxT("</li><li>")
wxT(" [[https://manual.audacityteam.org/|Manual]] - for comprehensive Audacity documentation") + wxT("</li><li>") + << wxT(
wxT(" [[https://forum.audacityteam.org/|Forum]] - for large knowledge base on using Audacity.") + wxT("</li></ul>"); " email to [[mailto:james@audacityteam.org|james@audacityteam.org]] - for help using DarkAudacity.")
<< wxT("</li><li>")
<< wxT(
" [[http://www.darkaudacity.com/video.html|Tutorials]] - for getting started with DarkAudacity.")
<< wxT("</li></ul>")
<< wxT("<br><br>Audacity has these support methods:")
<< wxT("<ul><li>")
<< wxT(" [[https://manual.audacityteam.org/|Manual]] - for comprehensive Audacity documentation")
<< wxT("</li><li>")
<< wxT(" [[https://forum.audacityteam.org/|Forum]] - for large knowledge base on using Audacity.")
<< wxT("</li></ul>")
#else #else
wxT("<center><h3>Audacity ") + AUDACITY_VERSION_STRING + wxT("</h3><h3>") + << wxT("<center><h3>Audacity ")
_("How to get help") + wxT("</h3></center>") + << AUDACITY_VERSION_STRING
_("These are our support methods:") + wxT("<p><ul><li>") + << wxT("</h3><h3>")
_("[[help:Quick_Help|Quick Help]] - if not installed locally, [[https://manual.audacityteam.org/quick_help.html|view online]]") + wxT("</li><li>") + << XO("How to get help")
_(" [[help:Main_Page|Manual]] - if not installed locally, [[https://manual.audacityteam.org/|view online]]") + wxT("</li><li>") + << wxT("</h3></center>")
_(" [[https://forum.audacityteam.org/|Forum]] - ask your question directly, online.") + wxT("</li></ul></p><p>") + wxT("<b>") + << XO("These are our support methods:")
_("More:</b> Visit our [[https://wiki.audacityteam.org/index.php|Wiki]] for tips, tricks, extra tutorials and effects plug-ins.") + wxT("</p>"); << wxT("<p><ul><li>")
<< XO("[[help:Quick_Help|Quick Help]] - if not installed locally, [[https://manual.audacityteam.org/quick_help.html|view online]]")
<< wxT("</li><li>")
<< XO(
" [[help:Main_Page|Manual]] - if not installed locally, [[https://manual.audacityteam.org/|view online]]")
<< wxT("</li><li>")
<< XO(
" [[https://forum.audacityteam.org/|Forum]] - ask your question directly, online.")
<< wxT("</li></ul></p><p>")
<< wxT("<b>")
<< XO("More:</b> Visit our [[https://wiki.audacityteam.org/index.php|Wiki]] for tips, tricks, extra tutorials and effects plug-ins.")
<< wxT("</p>")
#endif #endif
;
auto result = o.GetString();
#ifdef USE_ALPHA_MANUAL #ifdef USE_ALPHA_MANUAL
result.Replace( "//manual.audacityteam.org/quick_help.html","//alphamanual.audacityteam.org/man/Quick_Help" ); result.Replace( "//manual.audacityteam.org/quick_help.html","//alphamanual.audacityteam.org/man/Quick_Help" );
result.Replace( "//manual.audacityteam.org/","//alphamanual.audacityteam.org/man/" ); result.Replace( "//manual.audacityteam.org/","//alphamanual.audacityteam.org/man/" );
@ -259,18 +291,24 @@ static wxString HelpTextBuiltIn( const wxString & Key )
} }
if(Key==wxT("wma-proprietary")) if(Key==wxT("wma-proprietary"))
{ {
return WrapText( wxStringOutputStream o;
wxString(wxT("<p>"))+ wxTextOutputStream s(o);
_("Audacity can import unprotected files in many other formats (such as M4A and WMA, \ s
<< wxT("<p>")
<< XO(
"Audacity can import unprotected files in many other formats (such as M4A and WMA, \
compressed WAV files from portable recorders and audio from video files) if you download and install \ compressed WAV files from portable recorders and audio from video files) if you download and install \
the optional [[https://manual.audacityteam.org/man/faq_opening_and_saving_files.html#foreign| \ the optional [[https://manual.audacityteam.org/man/faq_opening_and_saving_files.html#foreign| \
FFmpeg library]] to your computer.") + wxT("</p><p>") + FFmpeg library]] to your computer.")
_("You can also read our help on importing \ << wxT("</p><p>")
<< XO(
"You can also read our help on importing \
[[https://manual.audacityteam.org/man/playing_and_recording.html#midi|MIDI files]] \ [[https://manual.audacityteam.org/man/playing_and_recording.html#midi|MIDI files]] \
and tracks from [[https://manual.audacityteam.org/man/faq_opening_and_saving_files.html#fromcd| \ and tracks from [[https://manual.audacityteam.org/man/faq_opening_and_saving_files.html#fromcd| \
audio CDs]].") audio CDs]].")
+ wxT("</p>") << wxT("</p>")
); ;
return WrapText( o.GetString() );
} }
// Remote help allows us to link to a local copy of the help if it exists, // Remote help allows us to link to a local copy of the help if it exists,
@ -278,23 +316,30 @@ audio CDs]].")
// It's used by the menu item Help > Index // It's used by the menu item Help > Index
if(Key == wxT("remotehelp") ) if(Key == wxT("remotehelp") )
{ {
wxStringOutputStream o;
wxTextOutputStream s(o);
s
// *URL* will be replaced by whatever URL we are looking for. // *URL* will be replaced by whatever URL we are looking for.
// DA: View the manual on line is expected. // DA: View the manual on line is expected.
#ifdef EXPERIMENTAL_DA #ifdef EXPERIMENTAL_DA
return WrapText(_("The Manual does not appear to be installed. \ << XO(
"The Manual does not appear to be installed. \
Please [[*URL*|view the Manual online]].<br><br>\ Please [[*URL*|view the Manual online]].<br><br>\
To always view the Manual online, change \"Location of Manual\" in \ To always view the Manual online, change \"Location of Manual\" in \
Interface Preferences to \"From Internet\".")); Interface Preferences to \"From Internet\".")
#else #else
return WrapText( _("The Manual does not appear to be installed. \ << XO(
"The Manual does not appear to be installed. \
Please [[*URL*|view the Manual online]] or \ Please [[*URL*|view the Manual online]] or \
[[https://manual.audacityteam.org/man/unzipping_the_manual.html| \ [[https://manual.audacityteam.org/man/unzipping_the_manual.html| \
download the Manual]].<br><br>\ download the Manual]].<br><br>\
To always view the Manual online, change \"Location of Manual\" in \ To always view the Manual online, change \"Location of Manual\" in \
Interface Preferences to \"From Internet\".")); Interface Preferences to \"From Internet\".")
#endif #endif
;
return WrapText( o.GetString() );
} }
return wxT(""); return {};
} }
wxString HelpText( const wxString & Key ) wxString HelpText( const wxString & Key )
@ -342,11 +387,15 @@ const wxString VerCheckArgs(){
// Text of hyperlink to check versions. // Text of hyperlink to check versions.
const wxString VerCheckHtml(){ const wxString VerCheckHtml(){
wxStringOutputStream o;
wxString result = "<center>[["; wxTextOutputStream s(o);
result += VerCheckUrl() + "|" + _("Check Online"); s
result += "]]</center>\n"; << "<center>[["
return result; << VerCheckUrl()
<< "|"
<< XO("Check Online")
<< "]]</center>\n";
return o.GetString();
} }
// Url with Version check args attached. // Url with Version check args attached.

View File

@ -36,6 +36,8 @@
#include <wx/filedlg.h> #include <wx/filedlg.h>
#include <wx/valtext.h> #include <wx/valtext.h>
#include <wx/log.h> #include <wx/log.h>
#include <wx/wfstream.h>
#include <wx/txtstrm.h>
#include "../PlatformCompatibility.h" #include "../PlatformCompatibility.h"
@ -408,28 +410,29 @@ namespace {
// Should these variations in formats be collapsed further? // Should these variations in formats be collapsed further?
// Pass nullptr when value is not yet defined // Pass nullptr when value is not yet defined
wxString FormatRMSMessage( float *pValue ) TranslatableString FormatRMSMessage( float *pValue )
{ {
/* i18n-hint: RMS abbreviates root mean square, a certain averaging method */ /* i18n-hint: RMS abbreviates root mean square, a certain averaging method */
wxString format0{ _("RMS = %s.") }; auto format0 = XO("RMS = %s.");
/* i18n-hint: dB abbreviates decibels */ /* i18n-hint: dB abbreviates decibels */
wxString format1{ _("%s dB") }; auto format1 = XO("%s dB");
wxString value; TranslatableString value;
if ( pValue ) if ( pValue ) {
if( fabs( *pValue ) != std::numeric_limits<float>::infinity() ) { if( fabs( *pValue ) != std::numeric_limits<float>::infinity() ) {
auto number = wxString::Format( _("%.2f"), *pValue ); auto number = wxString::Format( wxT("%.2f"), *pValue );
value = wxString::Format( format1, number ); value = format1.Format( number );
} }
else else
value = _("zero"); value = XO("zero");
}
else else
value = wxString::Format( format1, "" ); value = format1.Format( "" );
return wxString::Format( format0, value ); return format0.Format( value );
} }
wxString FormatDifference( float diffdB ) wxString FormatDifference( float diffdB )
@ -447,19 +450,19 @@ namespace {
} }
} }
wxString FormatDifferenceForExport( float diffdB ) TranslatableString FormatDifferenceForExport( float diffdB )
{ {
if( diffdB != diffdB ) //test for NaN, reliant on IEEE implementation if( diffdB != diffdB ) //test for NaN, reliant on IEEE implementation
return _("Difference is indeterminate."); return XO("Difference is indeterminate.");
else else
if( fabs(diffdB) != std::numeric_limits<float>::infinity() ) if( fabs(diffdB) != std::numeric_limits<float>::infinity() )
/* i18n-hint: dB abbreviates decibels */ /* i18n-hint: dB abbreviates decibels */
/* i18n-hint: RMS abbreviates root mean square, a certain averaging method */ /* i18n-hint: RMS abbreviates root mean square, a certain averaging method */
return wxString::Format(_("Difference = %.2f RMS dB."), diffdB ); return XO("Difference = %.2f RMS dB.").Format( diffdB );
else else
/* i18n-hint: dB abbreviates decibels */ /* i18n-hint: dB abbreviates decibels */
/* i18n-hint: RMS abbreviates root mean square, a certain averaging method */ /* i18n-hint: RMS abbreviates root mean square, a certain averaging method */
return _("Difference = infinite RMS dB."); return XO("Difference = infinite RMS dB.");
} }
} }
@ -540,58 +543,76 @@ void ContrastDialog::OnExport(wxCommandEvent & WXUNUSED(event))
if (fName.empty()) if (fName.empty())
return; return;
wxTextFile f(fName); wxFFileOutputStream ffStream{ fName };
f.Create();
f.Open(); if (!ffStream.IsOk()) {
if (!f.IsOpened()) {
AudacityMessageBox( XO("Couldn't write to file: %s").Format( fName ) ); AudacityMessageBox( XO("Couldn't write to file: %s").Format( fName ) );
return; return;
} }
f.AddLine(wxT("===================================")); wxTextOutputStream ss(ffStream);
ss
<< wxT("===================================") << '\n'
/* i18n-hint: WCAG abbreviates Web Content Accessibility Guidelines */ /* i18n-hint: WCAG abbreviates Web Content Accessibility Guidelines */
f.AddLine(_("WCAG 2.0 Success Criteria 1.4.7 Contrast Results")); << XO("WCAG 2.0 Success Criteria 1.4.7 Contrast Results") << '\n'
f.AddLine(wxT("")); << '\n'
f.AddLine(wxString::Format(_("Filename = %s."), project->GetFileName() )); << XO("Filename = %s.").Format( project->GetFileName() ) << '\n'
f.AddLine(wxT("")); << '\n'
f.AddLine(_("Foreground")); << XO("Foreground") << '\n';
float t = (float)mForegroundStartT->GetValue(); float t = (float)mForegroundStartT->GetValue();
int h = (int)(t/3600); // there must be a standard function for this! int h = (int)(t/3600); // there must be a standard function for this!
int m = (int)((t - h*3600)/60); int m = (int)((t - h*3600)/60);
float s = t - h*3600.0 - m*60.0; float s = t - h*3600.0 - m*60.0;
f.AddLine(wxString::Format(_("Time started = %2d hour(s), %2d minute(s), %.2f seconds."), h, m, s ));
ss
<< XO("Time started = %2d hour(s), %2d minute(s), %.2f seconds.")
.Format( h, m, s ) << '\n';
t = (float)mForegroundEndT->GetValue(); t = (float)mForegroundEndT->GetValue();
h = (int)(t/3600); h = (int)(t/3600);
m = (int)((t - h*3600)/60); m = (int)((t - h*3600)/60);
s = t - h*3600.0 - m*60.0; s = t - h*3600.0 - m*60.0;
f.AddLine(wxString::Format(_("Time ended = %2d hour(s), %2d minute(s), %.2f seconds."), h, m, s ));
f.AddLine( FormatRMSMessage( mForegroundIsDefined ? &foregrounddB : nullptr ) ); ss
f.AddLine(wxT("")); << XO("Time ended = %2d hour(s), %2d minute(s), %.2f seconds.")
f.AddLine(_("Background")); .Format( h, m, s ) << '\n'
<< FormatRMSMessage( mForegroundIsDefined ? &foregrounddB : nullptr ) << '\n'
<< '\n'
<< XO("Background") << '\n';
t = (float)mBackgroundStartT->GetValue(); t = (float)mBackgroundStartT->GetValue();
h = (int)(t/3600); h = (int)(t/3600);
m = (int)((t - h*3600)/60); m = (int)((t - h*3600)/60);
s = t - h*3600.0 - m*60.0; s = t - h*3600.0 - m*60.0;
f.AddLine(wxString::Format(_("Time started = %2d hour(s), %2d minute(s), %.2f seconds."), h, m, s ));
ss
<< XO("Time started = %2d hour(s), %2d minute(s), %.2f seconds.")
.Format( h, m, s ) << '\n';
t = (float)mBackgroundEndT->GetValue(); t = (float)mBackgroundEndT->GetValue();
h = (int)(t/3600); h = (int)(t/3600);
m = (int)((t - h*3600)/60); m = (int)((t - h*3600)/60);
s = t - h*3600.0 - m*60.0; s = t - h*3600.0 - m*60.0;
f.AddLine(wxString::Format(_("Time ended = %2d hour(s), %2d minute(s), %.2f seconds."), h, m, s ));
f.AddLine( FormatRMSMessage( mBackgroundIsDefined ? &backgrounddB : nullptr ) ); ss
f.AddLine(wxT("")); << XO("Time ended = %2d hour(s), %2d minute(s), %.2f seconds.")
f.AddLine(_("Results")); .Format( h, m, s ) << '\n'
<< FormatRMSMessage( mBackgroundIsDefined ? &backgrounddB : nullptr ) << '\n'
<< '\n'
<< XO("Results") << '\n';
float diffdB = foregrounddB - backgrounddB; float diffdB = foregrounddB - backgrounddB;
f.AddLine( FormatDifferenceForExport( diffdB ) ); ss
if( diffdB > 20. ) << FormatDifferenceForExport( diffdB ) << '\n'
f.AddLine(_("Success Criteria 1.4.7 of WCAG 2.0: Pass")); << (( diffdB > 20. )
else ? XO("Success Criteria 1.4.7 of WCAG 2.0: Pass")
f.AddLine(_("Success Criteria 1.4.7 of WCAG 2.0: Fail")); : XO("Success Criteria 1.4.7 of WCAG 2.0: Fail")) << '\n'
<< '\n'
<< XO("Data gathered") << '\n';
f.AddLine(wxT(""));
f.AddLine(_("Data gathered"));
wxString sNow;
wxDateTime now = wxDateTime::Now(); wxDateTime now = wxDateTime::Now();
int year = now.GetYear(); int year = now.GetYear();
wxDateTime::Month month = now.GetMonth(); wxDateTime::Month month = now.GetMonth();
@ -600,15 +621,14 @@ void ContrastDialog::OnExport(wxCommandEvent & WXUNUSED(event))
int hour = now.GetHour(); int hour = now.GetHour();
int minute = now.GetMinute(); int minute = now.GetMinute();
int second = now.GetSecond(); int second = now.GetSecond();
sNow = wxString::Format(wxT("%d %s %02d %02dh %02dm %02ds"), /* i18n-hint: day of month, month, year, hour, minute, second */
dom, monthName, year, hour, minute, second); auto sNow = XO("%d %s %02d %02dh %02dm %02ds")
f.AddLine(sNow); .Format( dom, monthName, year, hour, minute, second );
f.AddLine(wxT("===================================")); ss <<
f.AddLine(wxT("")); sNow << '\n'
<< wxT("===================================") << '\n'
f.Write(); << '\n';
f.Close();
} }
void ContrastDialog::OnReset(wxCommandEvent & /*event*/) void ContrastDialog::OnReset(wxCommandEvent & /*event*/)