1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-08 08:01:19 +02:00

Some more uses of TranslatableString

This commit is contained in:
Paul Licameli 2019-12-21 12:49:06 -05:00
commit 1399f12c00
24 changed files with 131 additions and 145 deletions

View File

@ -207,7 +207,8 @@ void MacroCommandDialog::OnItemSelected(wxListEvent &event)
// Later we can put help information there, perhaps.
// Macro command details are one place that we do expose Identifier
// to (more sophisticated) users
mDetails->SetValue( mInternalCommandName.GET() + "\r\n" + command.category );
mDetails->SetValue(
mInternalCommandName.GET() + "\r\n" + command.category.Translation() );
mParameters->SetValue(params);
}
@ -249,7 +250,8 @@ void MacroCommandDialog::SetCommandAndParams(const CommandID &Command, const wxS
// using GET to expose a CommandID to the user!
// Macro command details are one place that we do expose Identifier
// to (more sophisticated) users
mDetails->SetValue( iter->name.Internal() + "\r\n" + iter->category );
mDetails->SetValue(
iter->name.Internal() + "\r\n" + iter->category.Translation() );
mChoices->SetItemState(iter - mCatalog.begin(),
wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);

View File

@ -295,7 +295,7 @@ MacroCommandsCatalog::MacroCommandsCatalog( const AudacityProject *project )
for( const auto &command : SpecialCommands )
commands.push_back( {
{ command.second, command.first },
_("Special Command")
XO("Special Command")
} );
// end CLEANSPEECH remnant
@ -311,7 +311,7 @@ MacroCommandsCatalog::MacroCommandsCatalog( const AudacityProject *project )
commands.push_back( {
{ command, plug->GetSymbol().Msgid() },
plug->GetPluginType() == PluginTypeEffect ?
_("Effect") : _("Menu Command (With Parameters)")
XO("Effect") : XO("Menu Command (With Parameters)")
} );
plug = pm.GetNextPlugin(PluginTypeEffect|PluginTypeAudacityCommand);
}
@ -367,7 +367,7 @@ MacroCommandsCatalog::MacroCommandsCatalog( const AudacityProject *project )
mNames[i], // Internal name.
label // User readable name
},
_("Menu Command (No Parameters)")
XO("Menu Command (No Parameters)")
}
);
}

View File

@ -30,7 +30,7 @@ public:
// A triple of user-visible name, internal string identifier and type/help string.
struct Entry {
ComponentInterfaceSymbol name;
wxString category;
TranslatableString category;
};
using Entries = std::vector<Entry>;

View File

@ -965,8 +965,8 @@ void MacrosWindow::OnAdd(wxCommandEvent & WXUNUSED(event))
{
while (true) {
AudacityTextEntryDialog d(this,
_("Enter name of new macro"),
_("Name of new macro"));
XO("Enter name of new macro"),
XO("Name of new macro"));
d.SetName(d.GetTitle());
wxString name;

View File

@ -59,11 +59,11 @@ void Generate(wxDebugReport::Context ctx)
if (ok && rpt.Process())
{
AudacityTextEntryDialog dlg(NULL,
_("Report generated to:"),
_("Audacity Support Data"),
rpt.GetCompressedFileName(),
wxOK | wxCENTER);
AudacityTextEntryDialog dlg(nullptr,
XO("Report generated to:"),
XO("Audacity Support Data"),
rpt.GetCompressedFileName(),
wxOK | wxCENTER);
dlg.SetName(dlg.GetTitle());
dlg.ShowModal();

View File

@ -332,30 +332,39 @@ int NumWindowFuncs()
return eWinFuncCount;
}
const wxChar *WindowFuncName(int whichFunction)
const TranslatableString WindowFuncName(int whichFunction)
{
switch (whichFunction) {
default:
case eWinFuncRectangular:
return _("Rectangular");
return XO("Rectangular");
case eWinFuncBartlett:
return wxT("Bartlett");
/* i18n-hint a proper name */
return XO("Bartlett");
case eWinFuncHamming:
return wxT("Hamming");
/* i18n-hint a proper name */
return XO("Hamming");
case eWinFuncHanning:
return wxT("Hann");
/* i18n-hint a proper name */
return XO("Hann");
case eWinFuncBlackman:
return wxT("Blackman");
/* i18n-hint a proper name */
return XO("Blackman");
case eWinFuncBlackmanHarris:
return wxT("Blackman-Harris");
/* i18n-hint two proper names */
return XO("Blackman-Harris");
case eWinFuncWelch:
return wxT("Welch");
/* i18n-hint a proper name */
return XO("Welch");
case eWinFuncGaussian25:
return wxT("Gaussian(a=2.5)");
/* i18n-hint a mathematical function named for C. F. Gauss */
return XO("Gaussian(a=2.5)");
case eWinFuncGaussian35:
return wxT("Gaussian(a=3.5)");
/* i18n-hint a mathematical function named for C. F. Gauss */
return XO("Gaussian(a=3.5)");
case eWinFuncGaussian45:
return wxT("Gaussian(a=4.5)");
/* i18n-hint a mathematical function named for C. F. Gauss */
return XO("Gaussian(a=4.5)");
}
}

View File

@ -34,6 +34,8 @@
#include <wx/defs.h>
class TranslatableString;
/*
Salvo Ventura - November 2006
Added more window functions:
@ -138,7 +140,7 @@ void DerivativeOfWindowFunc(int whichFunction, size_t NumSamples, bool extraSamp
* Returns the name of the windowing function (for UI display)
*/
const wxChar *WindowFuncName(int whichFunction);
const TranslatableString WindowFuncName(int whichFunction);
/*
* Returns the number of windowing functions supported

View File

@ -241,10 +241,11 @@ FrequencyPlotDialog::FrequencyPlotDialog(wxWindow * parent, wxWindowID id,
wxArrayStringEx funcChoices;
for (int i = 0, cnt = NumWindowFuncs(); i < cnt; i++)
{
/* i18n-hint: This refers to a "window function",
* such as Hann or Rectangular, used in the
* Frequency analyze dialog box. */
funcChoices.push_back(wxString::Format("%s window", WindowFuncName(i) ) );
funcChoices.push_back(
/* i18n-hint: This refers to a "window function",
* such as Hann or Rectangular, used in the
* Frequency analyze dialog box. */
XO("%s window").Format( WindowFuncName(i) ).Translation() );
}
wxArrayStringEx axisChoices{
@ -949,35 +950,32 @@ void FrequencyPlotDialog::PlotPaint(wxPaintEvent & event)
value = mAnalyst->GetProcessedValue(xPos, xPos + xStep);
}
wxString cursor;
wxString peak;
wxString xpitch;
wxString peakpitch;
const wxChar *xp;
const wxChar *pp;
TranslatableString cursor;
TranslatableString peak;
if (mAlg == SpectrumAnalyst::Spectrum) {
xpitch = PitchName_Absolute(FreqToMIDInote(xPos));
peakpitch = PitchName_Absolute(FreqToMIDInote(bestpeak));
xp = xpitch;
pp = peakpitch;
auto xp = PitchName_Absolute(FreqToMIDInote(xPos));
auto pp = PitchName_Absolute(FreqToMIDInote(bestpeak));
/* i18n-hint: The %d's are replaced by numbers, the %s by musical notes, e.g. A#*/
cursor.Printf(_("%d Hz (%s) = %d dB"), (int)(xPos + 0.5), xp, (int)(value + 0.5));
peak.Printf(_("%d Hz (%s) = %.1f dB"), (int)(bestpeak + 0.5), pp, bestValue);
cursor = XO("%d Hz (%s) = %d dB")
.Format( (int)(xPos + 0.5), xp, (int)(value + 0.5));
/* i18n-hint: The %d's are replaced by numbers, the %s by musical notes, e.g. A#*/
peak = XO("%d Hz (%s) = %.1f dB")
.Format( (int)(bestpeak + 0.5), pp, bestValue );
} else if (xPos > 0.0 && bestpeak > 0.0) {
xpitch = PitchName_Absolute(FreqToMIDInote(1.0 / xPos));
peakpitch = PitchName_Absolute(FreqToMIDInote(1.0 / bestpeak));
xp = xpitch;
pp = peakpitch;
auto xp = PitchName_Absolute(FreqToMIDInote(1.0 / xPos));
auto pp = PitchName_Absolute(FreqToMIDInote(1.0 / bestpeak));
/* i18n-hint: The %d's are replaced by numbers, the %s by musical notes, e.g. A#
* the %.4f are numbers, and 'sec' should be an abbreviation for seconds */
cursor.Printf(_("%.4f sec (%d Hz) (%s) = %f"),
xPos, (int)(1.0 / xPos + 0.5), xp, value);
peak.Printf(_("%.4f sec (%d Hz) (%s) = %.3f"),
bestpeak, (int)(1.0 / bestpeak + 0.5), pp, bestValue);
cursor = XO("%.4f sec (%d Hz) (%s) = %f")
.Format( xPos, (int)(1.0 / xPos + 0.5), xp, value );
/* i18n-hint: The %d's are replaced by numbers, the %s by musical notes, e.g. A#
* the %.4f are numbers, and 'sec' should be an abbreviation for seconds */
peak = XO("%.4f sec (%d Hz) (%s) = %.3f")
.Format( bestpeak, (int)(1.0 / bestpeak + 0.5), pp, bestValue );
}
mCursorText->SetValue(cursor);
mPeakText->SetValue(peak);
mCursorText->SetValue( cursor.Translation() );
mPeakText->SetValue( peak.Translation() );
}
else {
mCursorText->SetValue(wxT(""));

View File

@ -812,10 +812,10 @@ void LabelDialog::OnChangeTrack(wxGridEvent & WXUNUSED(event), int row, RowData
// User selected the "New..." choice so ask for a NEW name
if ( make_iterator_range( mTrackNames ).index( val ) == 0 ) {
AudacityTextEntryDialog d(this,
_("New Label Track"),
_("Enter track name"),
/* i18n-hint: (noun) it's the name of a kind of track.*/
_("Label Track"));
XO("New Label Track"),
XO("Enter track name"),
/* i18n-hint: (noun) it's the name of a kind of track.*/
XO("Label Track").Translation());
// User canceled so repopulating the grid will set the track
// name to the orignal value

View File

@ -57,7 +57,7 @@ int PitchOctave(const double dMIDInote)
}
wxString PitchName(const double dMIDInote, const PitchNameChoice choice)
TranslatableString PitchName(const double dMIDInote, const PitchNameChoice choice)
{
static const TranslatableString sharpnames[12] = {
/* i18n-hint: Name of a musical note in the 12-tone chromatic scale */
@ -148,14 +148,14 @@ wxString PitchName(const double dMIDInote, const PitchNameChoice choice)
default: wxASSERT(false); break;
}
return table[PitchIndex(dMIDInote)].Translation();
return table[PitchIndex(dMIDInote)];
}
wxString PitchName_Absolute(const double dMIDInote, const PitchNameChoice choice)
TranslatableString PitchName_Absolute(const double dMIDInote, const PitchNameChoice choice)
{
// The format string is not localized. Should it be?
return wxString::Format(
wxT("%s%d"), PitchName(dMIDInote, choice), PitchOctave(dMIDInote) );
return Verbatim( wxT("%s%d") )
.Format( PitchName(dMIDInote, choice), PitchOctave(dMIDInote) );
}
double PitchToMIDInote(const unsigned int nPitchIndex, const int nPitchOctave)

View File

@ -18,7 +18,7 @@
#ifndef __AUDACITY_PITCHNAME__
#define __AUDACITY_PITCHNAME__
class wxString;
class TranslatableString;
// FreqToMIDInote takes a frequency in Hz (exponential scale relative to
// alphabetic pitch names) and returns a pitch ID number (linear
@ -44,14 +44,14 @@ enum class PitchNameChoice { Sharps, Flats, Both };
// PitchName takes dMIDInote (per result from
// FreqToMIDInote) and returns a standard pitch/note name [C, C#, etc.).
wxString PitchName(
TranslatableString PitchName(
const double dMIDInote,
const PitchNameChoice choice = PitchNameChoice::Sharps );
// PitchName_Absolute does the same thing as PitchName, but appends
// the octave number, e.g., instead of "C" it will return "C4"
// if the dMIDInote corresonds to middle C, i.e., is 60.
wxString PitchName_Absolute(
TranslatableString PitchName_Absolute(
const double dMIDInote,
const PitchNameChoice choice = PitchNameChoice::Sharps);

View File

@ -735,33 +735,15 @@ private:
#define LABEL_GENRE XO("Genre")
#define LABEL_COMMENTS XO("Comments")
static wxArrayString names()
{
static TranslatableString theNames[] =
{
LABEL_ARTIST,
LABEL_TITLE,
LABEL_ALBUM,
LABEL_TRACK,
LABEL_YEAR,
LABEL_GENRE,
LABEL_COMMENTS
};
class NamesArray final : public TranslatableStringArray
{
void Populate() override
{
for (auto &name : theNames)
mContents.push_back( name.Translation() );
}
};
static NamesArray theArray;
// Yes, return array by value
return theArray.Get();
}
static TranslatableStrings names{
LABEL_ARTIST,
LABEL_TITLE,
LABEL_ALBUM,
LABEL_TRACK,
LABEL_YEAR,
LABEL_GENRE,
LABEL_COMMENTS
};
static const struct
{
@ -911,7 +893,8 @@ void TagsEditorDialog::PopulateOrExchange(ShuttleGui & S)
mGrid->SetColLabelSize(mGrid->GetDefaultRowSize());
auto cs = names();
auto cs = transform_container<wxArrayStringEx>(
names, std::mem_fn( &TranslatableString::Translation ) );
// Build the initial (empty) grid
mGrid->CreateGrid(0, 2);

View File

@ -63,6 +63,4 @@ protected:
ArrayType mContents;
};
typedef TranslatableArray<wxArrayStringEx> TranslatableStringArray;
#endif

View File

@ -255,7 +255,7 @@ void EffectChangePitch::PopulateOrExchange(ShuttleGui & S)
wxArrayStringEx pitch;
for (int ii = 0; ii < 12; ++ii)
pitch.push_back( PitchName( ii, PitchNameChoice::Both ) );
pitch.push_back( PitchName( ii, PitchNameChoice::Both ).Translation() );
S.SetBorder(5);
@ -265,8 +265,9 @@ void EffectChangePitch::PopulateOrExchange(ShuttleGui & S)
{
S.AddTitle(_("Change Pitch without Changing Tempo"));
S.AddTitle(
wxString::Format(_("Estimated Start Pitch: %s%d (%.3f Hz)"),
pitch[m_nFromPitch], m_nFromOctave, m_FromFrequency));
XO("Estimated Start Pitch: %s%d (%.3f Hz)")
.Format( pitch[m_nFromPitch], m_nFromOctave, m_FromFrequency)
.Translation() );
}
S.EndVerticalLay();

View File

@ -3516,8 +3516,8 @@ void EditCurvesDialog::OnRename(wxCommandEvent & WXUNUSED(event))
bad = false;
// build the dialog
AudacityTextEntryDialog dlg( this,
wxString::Format( _("Rename '%s' to..."), mEditCurves[ item ].Name ),
_("Rename...") );
XO("Rename '%s' to...").Format( mEditCurves[ item ].Name ),
XO("Rename...") );
dlg.SetTextValidator( wxFILTER_EXCLUDE_CHAR_LIST );
dlg.SetName(
wxString::Format( _("Rename '%s'"), mEditCurves[ item ].Name ) );

View File

@ -1111,20 +1111,22 @@ wxString ExportMultipleDialog::MakeFileName(const wxString &input)
if(changed)
{ // need to get user to fix file name
// build the dialog
wxString msg;
TranslatableString msg;
wxString excluded = ::wxJoin( Internat::GetExcludedCharacters(), wxChar(' ') );
// TODO: For Russian langauge we should have separate cases for 2 and more than 2 letters.
if( excluded.length() > 1 ){
// i18n-hint: The second %s gives some letters that can't be used.
msg.Printf(_("Label or track \"%s\" is not a legal file name. You cannot use any of: %s\nUse..."), input,
excluded);
msg = XO(
"Label or track \"%s\" is not a legal file name. You cannot use any of: %s\nUse...")
.Format( input, excluded );
} else {
// i18n-hint: The second %s gives a letter that can't be used.
msg.Printf(_("Label or track \"%s\" is not a legal file name. You cannot use \"%s\".\nUse..."), input,
excluded);
msg = XO(
"Label or track \"%s\" is not a legal file name. You cannot use \"%s\".\nUse...")
.Format( input, excluded );
}
AudacityTextEntryDialog dlg( this, msg, _("Save As..."), newname );
AudacityTextEntryDialog dlg( this, msg, XO("Save As..."), newname );
// And tell the validator about excluded chars

View File

@ -159,25 +159,17 @@ const TranslatableStrings &SpectrogramSettings::GetScaleNames()
}
//static
const wxArrayStringEx &SpectrogramSettings::GetAlgorithmNames()
const TranslatableStrings &SpectrogramSettings::GetAlgorithmNames()
{
class AlgorithmNamesArray final : public TranslatableStringArray
{
void Populate() override
{
mContents.insert( mContents.end(), {
// Keep in correspondence with enum SpectrogramSettings::Algorithm:
_("Frequencies") ,
/* i18n-hint: the Reassignment algorithm for spectrograms */
_("Reassignment") ,
/* i18n-hint: EAC abbreviates "Enhanced Autocorrelation" */
_("Pitch (EAC)") ,
} );
}
static const TranslatableStrings results{
// Keep in correspondence with enum SpectrogramSettings::Algorithm:
XO("Frequencies") ,
/* i18n-hint: the Reassignment algorithm for spectrograms */
XO("Reassignment") ,
/* i18n-hint: EAC abbreviates "Enhanced Autocorrelation" */
XO("Pitch (EAC)") ,
};
static AlgorithmNamesArray theArray;
return theArray.Get();
return results;
}
bool SpectrogramSettings::Validate(bool quiet)

View File

@ -67,7 +67,7 @@ public:
};
static const TranslatableStrings &GetScaleNames();
static const wxArrayStringEx &GetAlgorithmNames();
static const TranslatableStrings &GetAlgorithmNames();
static SpectrogramSettings &defaults();
SpectrogramSettings();

View File

@ -112,7 +112,7 @@ void SpectrumPrefs::Populate(size_t windowSize)
PopulatePaddingChoices(windowSize);
for (int i = 0; i < NumWindowFuncs(); i++) {
mTypeChoices.push_back(WindowFuncName(i));
mTypeChoices.push_back( WindowFuncName(i).Translation() );
}
//------------------------- Main section --------------------
@ -242,7 +242,9 @@ void SpectrumPrefs::PopulateOrExchange(ShuttleGui & S)
mAlgorithmChoice =
S.Id(ID_ALGORITHM).TieChoice(_("A&lgorithm:"),
mTempSettings.algorithm,
SpectrogramSettings::GetAlgorithmNames());
transform_container<wxArrayStringEx>(
SpectrogramSettings::GetAlgorithmNames(),
std::mem_fn( &TranslatableString::Translation ) ) );
S.Id(ID_WINDOW_SIZE).TieChoice(_("Window &size:"),
mTempSettings.windowSize,

View File

@ -110,7 +110,9 @@ void WaveformPrefs::PopulateOrExchange(ShuttleGui & S)
mScaleChoice =
S.Id(ID_SCALE).TieChoice(_("S&cale:"),
mTempSettings.scaleType,
WaveformSettings::GetScaleNames());
transform_container<wxArrayStringEx>(
WaveformSettings::GetScaleNames(),
std::mem_fn( &TranslatableString::Translation ) ) );
mRangeChoice =
S.Id(ID_RANGE).TieChoice(_("Waveform dB &range:"),

View File

@ -147,20 +147,14 @@ void WaveformSettings::NextHigherDBRange()
}
//static
const wxArrayStringEx &WaveformSettings::GetScaleNames()
const TranslatableStrings &WaveformSettings::GetScaleNames()
{
class ScaleNamesArray final : public TranslatableStringArray
{
void Populate() override
{
// Keep in correspondence with enum WaveTrack::WaveTrackDisplay:
mContents.push_back(_("Linear"));
mContents.push_back(_("Logarithmic"));
}
static const TranslatableStrings result{
// Keep in correspondence with enum WaveTrack::WaveTrackDisplay:
XO("Linear"),
XO("Logarithmic"),
};
static ScaleNamesArray theArray;
return theArray.Get();
return result;
}
WaveformSettings::~WaveformSettings()

View File

@ -11,7 +11,7 @@ Paul Licameli
#ifndef __AUDACITY_WAVEFORM_SETTINGS__
#define __AUDACITY_WAVEFORM_SETTINGS__
class wxArrayStringEx;
#include "../Internat.h" // for TranslatableStrings
class WaveformSettings
{
@ -58,7 +58,7 @@ public:
stNumScaleTypes,
};
static const wxArrayStringEx &GetScaleNames();
static const TranslatableStrings &GetScaleNames();
ScaleType scaleType;
int dBRange;

View File

@ -2085,8 +2085,8 @@ int LabelTrackView::DialogForLabelName(
position = trackPanel.ClientToScreen(position);
auto &window = GetProjectFrame( project );
AudacityTextEntryDialog dialog{ &window,
_("Name:"),
_("New label"),
XO("Name:"),
XO("New label"),
initialValue,
wxOK | wxCANCEL,
position };

View File

@ -69,13 +69,14 @@ class AudacityTextEntryDialog : public wxTabTraversalWrapper< wxTextEntryDialog
public:
AudacityTextEntryDialog(
wxWindow *parent,
const wxString& message,
const wxString& caption, // don't use = wxGetTextFromUserPromptStr,
const TranslatableString& message,
const TranslatableString& caption, // don't use = wxGetTextFromUserPromptStr,
const wxString& value = {},
long style = wxTextEntryDialogStyle,
const wxPoint& pos = wxDefaultPosition)
: wxTabTraversalWrapper< wxTextEntryDialog>
( parent, message, caption, value, style, pos )
: wxTabTraversalWrapper< wxTextEntryDialog>(
parent,
message.Translation(), caption.Translation(), value, style, pos )
{}
void SetInsertionPointEnd();