1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-03 17:19:43 +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/statbmp.h>
#include <wx/intl.h>
#include <wx/sstream.h>
#include <wx/txtstrm.h>
#include "FileNames.h"
#include "HelpText.h"
@ -306,110 +308,141 @@ void AboutDialog::PopulateAudacityPage( ShuttleGui & S )
{
CreateCreditsList();
wxString par1Str =
auto par1Str =
// DA: Says that it is a customised version.
#ifdef EXPERIMENTAL_DA
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 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
_(
XO(
"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
;
// This trick here means that the English language version won't mention using
// English, whereas all translated versions will.
wxString par2StrUntranslated = wxT(
"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 = _(
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]].");
auto par2StrTranslated = par2Str.Translation();
if( par2Str == par2StrUntranslated )
par2Str.Replace( wxT(", in English,"), wxT("") );
if( par2StrTranslated == par2Str.MSGID().GET() )
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
* in the credits in the About Audacity window. Use this to add
* your own name(s) to the credits.
*
* For example: "English translation by Dominic Mazzoni." */
if (_("translator_credits") != wxString(wxT("translator_credits")))
{
translatorCredits = _("translator_credits") + wxT("<br>");
}
if ( translatorCredits == translatorCreditsMsgid.MSGID().GET() )
// We're in an English locale
translatorCredits.clear();
else
translatorCredits += wxT("<br>");
wxString creditStr = FormatHtmlText(
wxString( wxT("<center>") ) +
wxStringOutputStream o;
wxTextOutputStream informationStr( o ); // string to build up list of information in
informationStr
<< wxT("<center>")
// DA: Description and provenance in About box
#ifdef EXPERIMENTAL_DA
#undef _
#define _(s) wxGetTranslation((s))
wxT("<h3>DarkAudacity ") + wxString(AUDACITY_VERSION_STRING) + wxT("</center></h3>") +
wxT("Customised version of the Audacity free, open source, cross-platform software " ) +
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>") +
<< wxT("<h3>DarkAudacity ")
<< wxString(AUDACITY_VERSION_STRING)
<< wxT("</center></h3>")
<< wxT("Customised version of the Audacity free, open source, cross-platform software " )
<< 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
_("<h3>Audacity ") + wxString(AUDACITY_VERSION_STRING) + wxT("</center></h3>") +
_("Audacity the free, open source, cross-platform software for recording and editing sounds.") +
<< XO("<h3>Audacity ")
<< wxString(AUDACITY_VERSION_STRING)
<< wxT("</center></h3>")
<< XO("Audacity the free, open source, cross-platform software for recording and editing sounds.")
#endif
//wxT("<p><br>") + par1Str +
//wxT("<p>") + par2Str +
wxT("<h3>") + _("Credits") + wxT("</h3>") + wxT("<p>") +
// << wxT("<p><br>")
// << par1Str
// << wxT("<p>")
// << par2Str
<< wxT("<h3>")
<< XO("Credits")
<< wxT("</h3>")
<< wxT("<p>")
// DA: Customisation credit
#ifdef EXPERIMENTAL_DA
wxT("<p><b>") + wxString::Format(_("DarkAudacity Customisation")) + wxT("</b><br>") +
wxT("James Crook, art, coding &amp; design<br>") +
<< wxT("<p><b>")
<< XO("DarkAudacity Customisation")
<< wxT("</b><br>")
<< wxT("James Crook, art, coding &amp; design<br>")
#endif
wxT("<p><b>") + _("Audacity Team Members") + wxT("</b><br>") +
GetCreditsByRole(roleTeamMember) +
<< wxT("<p><b>")
<< XO("Audacity Team Members")
<< wxT("</b><br>")
<< GetCreditsByRole(roleTeamMember)
wxT("<p><b> ") + _("Emeritus:") + wxT("</b><br>") +
_("Distinguished Audacity Team members, not currently active") + wxT("<br><br>") +
GetCreditsByRole(roleEmeritusTeam) +
<< wxT("<p><b> ")
<< XO("Emeritus:")
<< wxT("</b><br>")
<< XO("Distinguished Audacity Team members, not currently active")
<< wxT("<br><br>")
<< GetCreditsByRole(roleEmeritusTeam)
wxT("<p><b>") + _("Contributors") + wxT("</b><br>") +
GetCreditsByRole(roleContributor) +
<< wxT("<p><b>")
<< XO("Contributors")
<< wxT("</b><br>")
<< GetCreditsByRole(roleContributor)
wxT("<p><b>") + _("Website and Graphics") + wxT("</b><br>") +
GetCreditsByRole(roleGraphics) +
<< wxT("<p><b>")
<< XO("Website and Graphics")
<< wxT("</b><br>")
<< GetCreditsByRole(roleGraphics)
;
(translatorCredits.empty()
? wxT("")
: (wxT("<p><b>") + _("Translators") + wxT("</b><br>") +
translatorCredits)) +
if(!translatorCredits.empty()) informationStr
<< wxT("<p><b>")
<< XO("Translators")
<< wxT("</b><br>")
<< translatorCredits
;
wxT("<p><b>") + _("Libraries") + wxT("</b><br>") +
_("Audacity includes code from the following projects:") + wxT("<br><br>") +
GetCreditsByRole(roleLibrary) +
informationStr
<< wxT("<p><b>")
<< 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>") +
GetCreditsByRole(roleThanks) +
<< wxT("<p><b>")
<< 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
#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
_("<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>")
+
_("&nbsp; &nbsp; The name <b>Audacity</b> is a registered trademark of Dominic Mazzoni.<br><br>") +
<< XO("&nbsp; &nbsp; The name <b>Audacity</b> is a registered trademark of Dominic Mazzoni.<br><br>")
#endif
wxT("</center>")
);
<< wxT("</center>")
;
auto pPage = S.StartNotebookPage( XO("Audacity") );
S.StartVerticalLay(1);
@ -446,7 +479,7 @@ visit our [[https://forum.audacityteam.org/|forum]].");
wxDefaultPosition,
wxSize(ABOUT_DIALOG_WIDTH, 359),
wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER);
html->SetPage(creditStr);
html->SetPage( FormatHtmlText( o.GetString() ) );
/* locate the html renderer where it fits in the dialogue */
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 */
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.StartVerticalLay(2); // create the window
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
* informationStr */
informationStr = wxT("<h2><center>");
informationStr += _("Build Information");
informationStr += wxT("</center></h2>\n");
informationStr += VerCheckHtml();
// top level heading
informationStr += wxT("<h3>");
informationStr += _("File Format Support");
informationStr += wxT("</h3>\n<p>");
informationStr
<< wxT("<h2><center>")
<< XO("Build Information")
<< wxT("</center></h2>\n")
<< VerCheckHtml()
// top level heading
<< wxT("<h3>")
<< XO("File Format Support")
<< wxT("</h3>\n<p>");
// 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
@ -553,11 +589,12 @@ void AboutDialog::PopulateInformationPage( ShuttleGui & S )
AddBuildinfoRow(&informationStr, wxT("gstreamer"), XO("Import via GStreamer"), disabled);
#endif
informationStr += wxT("</table>\n"); //end table of file format libraries
informationStr += wxT("<h3>");
/* i18n-hint: Libraries that are essential to audacity */
informationStr += _("Core Libraries");
informationStr += wxT("</h3>\n<table>"); // start table of features
informationStr
<< wxT("</table>\n") //end table of file format libraries
<< wxT("<h3>")
/* i18n-hint: Libraries that are essential to audacity */
<< XO("Core Libraries")
<< wxT("</h3>\n<table>"); // start table of features
AddBuildinfoRow(&informationStr, wxT("libsoxr"),
XO("Sample rate conversion"), enabled);
@ -568,10 +605,11 @@ void AboutDialog::PopulateInformationPage( ShuttleGui & S )
AddBuildinfoRow(&informationStr, wxT("wxWidgets"),
XO("Cross-platform GUI library"), wxVERSION_NUM_DOT_STRING_T);
informationStr += wxT("</table>\n"); //end table of libraries
informationStr += wxT("<h3>");
informationStr += _("Features");
informationStr += wxT("</h3>\n<table>"); // start table of features
informationStr
<< wxT("</table>\n") //end table of libraries
<< wxT("<h3>")
<< XO("Features")
<< wxT("</h3>\n<table>"); // start table of features
#ifdef EXPERIMENTAL_DA
AddBuildinfoRow(&informationStr, wxT("Theme"), XO("Dark Theme Extras"), enabled);
@ -651,12 +689,13 @@ void AboutDialog::PopulateInformationPage( ShuttleGui & S )
disabled);
# 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 */
informationStr += _("Build Information");
informationStr += wxT("</h3>\n<table>");
<< XO("Build Information")
<< wxT("</h3>\n<table>");
// Current date
AddBuildinfoRow(&informationStr, XO("Program build date:"), __TDATE__);
@ -702,11 +741,9 @@ void AboutDialog::PopulateInformationPage( ShuttleGui & S )
AddBuildinfoRow(&informationStr, XO("Settings folder:"), \
FileNames::DataDir());
// end of table
informationStr += wxT("</table>\n");
informationStr << wxT("</table>\n");
informationStr = FormatHtmlText( informationStr );
html->SetPage(informationStr); // push the page into the html renderer
html->SetPage( FormatHtmlText( o.GetString() ) ); // push the page into the html renderer
S.Prop(2)
.Position( wxEXPAND )
.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
* library is enabled or not, and what it does */
void AboutDialog::AddBuildinfoRow(
wxString* htmlstring, const wxChar * libname,
wxTextOutputStream *str, const wxChar * libname,
const TranslatableString &libdesc, const wxString &status)
{
*htmlstring += wxT("<tr><td>");
*htmlstring += libname;
*htmlstring += wxT("</td><td>(");
*htmlstring += libdesc.Translation();
*htmlstring += wxT(")</td><td>");
*htmlstring += status;
*htmlstring += wxT("</td></tr>");
*str
<< wxT("<tr><td>")
<< libname
<< wxT("</td><td>(")
<< libdesc
<< wxT(")</td><td>")
<< status
<< wxT("</td></tr>");
}
/** \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
* file paths */
void AboutDialog::AddBuildinfoRow(
wxString* htmlstring, const TranslatableString &description, const wxChar *spec)
wxTextOutputStream *str,
const TranslatableString &description, const wxChar *spec)
{
*htmlstring += wxT("<tr><td>");
*htmlstring += description.Translation();
*htmlstring += wxT("</td><td>");
*htmlstring += spec;
*htmlstring += wxT("</td></tr>");
*str
<< wxT("<tr><td>")
<< description
<< wxT("</td><td>")
<< spec
<< wxT("</td></tr>");
}
AboutDialog::~AboutDialog()

View File

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

View File

@ -842,7 +842,8 @@ wxString AudioIOBase::GetDeviceInfo()
wxTextOutputStream s(o, wxEOL_UNIX);
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);
s << wxT("==============================\n");
s << wxString::Format(_("Default recording device number: %d\n"), recDeviceNum);
s << wxString::Format(_("Default playback device number: %d\n"), playDeviceNum);
s << XO("Default recording device number: %d\n").Format( recDeviceNum );
s << XO("Default playback device number: %d\n").Format( playDeviceNum);
wxString recDevice = gPrefs->Read(wxT("/AudioIO/RecordingDevice"), 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)
if (cnt <= 0) {
s << _("No devices found\n");
s << XO("No devices found\n");
return o.GetString();
}
@ -875,25 +876,25 @@ wxString AudioIOBase::GetDeviceInfo()
info = Pa_GetDeviceInfo(j);
if (!info) {
s << wxString::Format(_("Device info unavailable for: %d\n"), j);
s << XO("Device info unavailable for: %d\n").Format( j );
continue;
}
wxString name = DeviceName(info);
s << wxString::Format(_("Device ID: %d\n"), j);
s << wxString::Format(_("Device name: %s\n"), name);
s << wxString::Format(_("Host name: %s\n"), HostName(info));
s << wxString::Format(_("Recording channels: %d\n"), info->maxInputChannels);
s << wxString::Format(_("Playback channels: %d\n"), info->maxOutputChannels);
s << wxString::Format(_("Low Recording Latency: %g\n"), info->defaultLowInputLatency);
s << wxString::Format(_("Low Playback Latency: %g\n"), info->defaultLowOutputLatency);
s << wxString::Format(_("High Recording Latency: %g\n"), info->defaultHighInputLatency);
s << wxString::Format(_("High Playback Latency: %g\n"), info->defaultHighOutputLatency);
s << XO("Device ID: %d\n").Format( j );
s << XO("Device name: %s\n").Format( name );
s << XO("Host name: %s\n").Format( HostName(info) );
s << XO("Recording channels: %d\n").Format( info->maxInputChannels );
s << XO("Playback channels: %d\n").Format( info->maxOutputChannels );
s << XO("Low Recording Latency: %g\n").Format( info->defaultLowInputLatency );
s << XO("Low Playback Latency: %g\n").Format( info->defaultLowOutputLatency );
s << XO("High Recording Latency: %g\n").Format( info->defaultHighInputLatency );
s << XO("High Playback Latency: %g\n").Format( info->defaultHighOutputLatency );
auto rates = GetSupportedPlaybackRates(j, 0.0);
/* 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++) {
s << wxT(" ") << (int)rates[k] << wxT("\n");
}
@ -919,27 +920,27 @@ wxString AudioIOBase::GetDeviceInfo()
s << wxT("==============================\n");
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
s << wxString::Format(_("No recording device found for '%s'.\n"), recDevice);
s << XO("No recording device found for '%s'.\n").Format( recDevice );
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
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;
if (havePlayDevice && haveRecDevice) {
supportedSampleRates = GetSupportedSampleRates(playDeviceNum, recDeviceNum);
s << _("Supported Rates:\n");
s << XO("Supported Rates:\n");
for (int k = 0; k < (int) supportedSampleRates.size(); k++) {
s << wxT(" ") << (int)supportedSampleRates[k] << wxT("\n");
}
}
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();
}
@ -999,42 +1000,42 @@ wxString AudioIOBase::GetDeviceInfo()
}
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();
}
PxMixer *PortMixer = Px_OpenMixer(stream, 0);
if (!PortMixer) {
s << _("Unable to open Portmixer\n");
s << XO("Unable to open Portmixer\n");
Pa_CloseStream(stream);
return o.GetString();
}
s << wxT("==============================\n");
s << _("Available mixers:\n");
s << XO("Available mixers:\n");
// FIXME: ? PortMixer errors on query not reported in GetDeviceInfo
cnt = Px_GetNumMixers(stream);
for (int i = 0; i < cnt; 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 << _("Available recording sources:\n");
s << XO("Available recording sources:\n");
cnt = Px_GetNumInputSources(PortMixer);
for (int i = 0; i < cnt; 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 << _("Available playback volumes:\n");
s << XO("Available playback volumes:\n");
cnt = Px_GetNumOutputVolumes(PortMixer);
for (int i = 0; i < cnt; 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
@ -1067,11 +1068,11 @@ wxString AudioIOBase::GetDeviceInfo()
s << wxT("==============================\n");
s << ( EmulateMixerInputVol
? _("Recording volume is emulated\n")
: _("Recording volume is native\n") );
? XO("Recording volume is emulated\n")
: XO("Recording volume is native\n") );
s << ( EmulateMixerOutputVol
? _("Playback volume is emulated\n")
: _("Playback volume is native\n") );
? XO("Playback volume is emulated\n")
: XO("Playback volume is native\n") );
Px_CloseMixer(PortMixer);
@ -1088,7 +1089,8 @@ wxString AudioIOBase::GetMidiDeviceInfo()
wxTextOutputStream s(o, wxEOL_UNIX);
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);
s << wxT("==============================\n");
s << wxString::Format(_("Default recording device number: %d\n"), recDeviceNum);
s << wxString::Format(_("Default playback device number: %d\n"), playDeviceNum);
s << XO("Default recording device number: %d\n").Format( recDeviceNum );
s << XO("Default playback device number: %d\n").Format( playDeviceNum );
wxString recDevice = gPrefs->Read(wxT("/MidiIO/RecordingDevice"), wxT(""));
wxString playDevice = gPrefs->Read(wxT("/MidiIO/PlaybackDevice"), wxT(""));
// This gets info on all available audio devices (input and output)
if (cnt <= 0) {
s << _("No devices found\n");
s << XO("No devices found\n");
return o.GetString();
}
@ -1118,20 +1120,20 @@ wxString AudioIOBase::GetMidiDeviceInfo()
const PmDeviceInfo* info = Pm_GetDeviceInfo(i);
if (!info) {
s << wxString::Format(_("Device info unavailable for: %d\n"), i);
s << XO("Device info unavailable for: %d\n").Format( i );
continue;
}
wxString name = wxSafeConvertMB2WX(info->name);
wxString hostName = wxSafeConvertMB2WX(info->interf);
s << wxString::Format(_("Device ID: %d\n"), i);
s << wxString::Format(_("Device name: %s\n"), name);
s << wxString::Format(_("Host name: %s\n"), hostName);
s << XO("Device ID: %d\n").Format( i );
s << XO("Device name: %s\n").Format( name );
s << XO("Host name: %s\n").Format( hostName );
/* i18n-hint: Supported, meaning made available by the system */
s << wxString::Format(_("Supports output: %d\n"), info->output);
s << wxString::Format(_("Supports input: %d\n"), info->input);
s << wxString::Format(_("Opened: %d\n"), info->opened);
s << XO("Supports output: %d\n").Format( info->output );
s << XO("Supports input: %d\n").Format( info->input );
s << XO("Opened: %d\n").Format( info->opened );
if (name == playDevice && info->output)
playDeviceNum = i;
@ -1154,14 +1156,14 @@ wxString AudioIOBase::GetMidiDeviceInfo()
s << wxT("==============================\n");
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
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)
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
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
#ifdef IS_ALPHA

View File

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

View File

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

View File

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

View File

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