Remove 27 various macro _ ...

... and supply a few missing translations in Dependencies.cpp

And substitute-don't-concatenate in a few places in Internat.cpp
This commit is contained in:
Paul Licameli 2020-05-23 06:41:26 -04:00
parent 3e5789ca14
commit db690d94f7
18 changed files with 76 additions and 98 deletions

View File

@ -449,7 +449,7 @@ void DependencyDialog::PopulateList()
mFileListCtrl->SetItemState(i, 0, wxLIST_STATE_SELECTED); // Deselect.
mFileListCtrl->SetItemTextColour(i, *wxRED);
}
mFileListCtrl->SetItem(i, 1, Internat::FormatSize(byteCount));
mFileListCtrl->SetItem(i, 1, Internat::FormatSize(byteCount).Translation());
mFileListCtrl->SetItemData(i, long(bOriginalExists));
++i;
@ -541,25 +541,24 @@ void DependencyDialog::OnRightClick( wxListEvent& event)
PopupMenu(&menu);
}
void DependencyDialog::OnCopyToClipboard( wxCommandEvent& evt )
void DependencyDialog::OnCopyToClipboard( wxCommandEvent& )
{
static_cast<void>(evt);
wxString Files;
TranslatableString Files;
for (const auto &aliasedFile : mAliasedFiles) {
const wxFileName & fileName = aliasedFile.mFileName;
wxLongLong byteCount = (aliasedFile.mByteCount * 124) / 100;
bool bOriginalExists = aliasedFile.mbOriginalExists;
// All fields quoted, as e.g. size may contain a comma in the number.
Files += wxString::Format( "\"%s\", \"%s\", \"%s\"\n",
Files += XO( "\"%s\", \"%s\", \"%s\"\n").Format(
fileName.GetFullPath(),
Internat::FormatSize( byteCount),
bOriginalExists ? "OK":"Missing" );
Internat::FormatSize( byteCount),
bOriginalExists ? XO("OK") : XO("Missing") );
}
// copy data onto clipboard
if (wxTheClipboard->Open()) {
// Clipboard owns the data you give it
wxTheClipboard->SetData(safenew wxTextDataObject(Files));
wxTheClipboard->SetData(safenew wxTextDataObject(Files.Translation()));
wxTheClipboard->Close();
}
}

View File

@ -33,9 +33,9 @@ License: GPL v2. See License.txt.
#if !defined(USE_FFMPEG)
/// FFmpeg support may or may not be compiled in,
/// but Preferences dialog requires this function nevertheless
wxString GetFFmpegVersion(wxWindow *parent)
TranslatableString GetFFmpegVersion()
{
return wxString(_("FFmpeg support not compiled in"));
return XO("FFmpeg support not compiled in");
}
#else
@ -110,14 +110,14 @@ void FFmpegStartup()
}
}
wxString GetFFmpegVersion(wxWindow * WXUNUSED(parent))
TranslatableString GetFFmpegVersion()
{
PickFFmpegLibs();
wxString versionString = _("FFmpeg library not found");
auto versionString = XO("FFmpeg library not found");
if (FFmpegLibsInst()->ValidLibsLoaded()) {
versionString = FFmpegLibsInst()->GetLibraryVersion();
versionString = Verbatim( FFmpegLibsInst()->GetLibraryVersion() );
}
DropFFmpegLibs();

View File

@ -168,7 +168,7 @@ void av_log_wx_callback(void* ptr, int level, const char* fmt, va_list vl);
//----------------------------------------------------------------------------
// Get FFmpeg library version
//----------------------------------------------------------------------------
wxString GetFFmpegVersion(wxWindow *parent);
TranslatableString GetFFmpegVersion();
/* from here on in, this stuff only applies when ffmpeg is available */
#if defined(USE_FFMPEG)

View File

@ -204,18 +204,17 @@ void HistoryDialog::DoUpdate()
wxLongLong_t total = 0;
mSelected = mManager->GetCurrentState() - 1;
for (i = 0; i < (int)mManager->GetNumStates(); i++) {
TranslatableString desc;
wxString size;
TranslatableString desc, size;
total += mManager->GetLongDescription(i + 1, &desc, &size);
mList->InsertItem(i, desc.Translation(), i == mSelected ? 1 : 0);
mList->SetItem(i, 1, size);
mList->SetItem(i, 1, size.Translation());
}
mTotal->SetValue(Internat::FormatSize(total));
mTotal->SetValue(Internat::FormatSize(total).Translation());
auto clipboardUsage = mManager->GetClipboardSpaceUsage();
mClipboard->SetValue(Internat::FormatSize(clipboardUsage));
mClipboard->SetValue(Internat::FormatSize(clipboardUsage).Translation());
FindWindowById(ID_DISCARD_CLIPBOARD)->Enable(clipboardUsage > 0);
mList->EnsureVisible(mSelected);

View File

@ -188,7 +188,7 @@ wxString Internat::ToDisplayString(double numberToConvert,
return result;
}
wxString Internat::FormatSize(wxLongLong size)
TranslatableString Internat::FormatSize(wxLongLong size)
{
/* wxLongLong contains no built-in conversion to double */
double dSize = size.GetHi() * pow(2.0, 32); // 2 ^ 32
@ -197,27 +197,27 @@ wxString Internat::FormatSize(wxLongLong size)
return FormatSize(dSize);
}
wxString Internat::FormatSize(double size)
TranslatableString Internat::FormatSize(double size)
{
wxString sizeStr;
TranslatableString sizeStr;
if (size == -1)
sizeStr = _("Unable to determine");
sizeStr = XO("Unable to determine");
else {
/* make it look nice, by formatting into k, MB, etc */
if (size < 1024.0)
sizeStr = ToDisplayString(size) + wxT(" ") + _("bytes");
sizeStr = XO("%s bytes").Format( ToDisplayString(size) );
else if (size < 1024.0 * 1024.0) {
/* i18n-hint: Abbreviation for Kilo bytes */
sizeStr = ToDisplayString(size / 1024.0, 1) + wxT(" ") + _("KB");
sizeStr = XO("%s KB").Format( ToDisplayString(size / 1024.0, 1) );
}
else if (size < 1024.0 * 1024.0 * 1024.0) {
/* i18n-hint: Abbreviation for Mega bytes */
sizeStr = ToDisplayString(size / (1024.0 * 1024.0), 1) + wxT(" ") + _("MB");
sizeStr = XO("%s MB").Format( ToDisplayString(size / (1024.0 * 1024.0), 1) );
}
else {
/* i18n-hint: Abbreviation for Giga bytes */
sizeStr = ToDisplayString(size / (1024.0 * 1024.0 * 1024.0), 1) + wxT(" ") + _("GB");
sizeStr = XO("%s GB").Format( ToDisplayString(size / (1024.0 * 1024.0 * 1024.0), 1) );
}
}
@ -247,19 +247,6 @@ bool Internat::SanitiseFilename(wxString &name, const wxString &sub)
return result;
}
wxString Internat::StripAccelerators(const wxString &s)
{
wxString result;
result.reserve(s.length());
for(size_t i = 0; i < s.length(); i++) {
if (s[i] == '\t')
break;
if (s[i] != '&' && s[i] != '.')
result += s[i];
}
return result;
}
TranslatableStrings Msgids(
const EnumValueSymbol strings[], size_t nStrings)
{

View File

@ -123,8 +123,8 @@ public:
/** \brief Convert a number to a string while formatting it in bytes, KB,
* MB, GB */
static wxString FormatSize(wxLongLong size);
static wxString FormatSize(double size);
static TranslatableString FormatSize(wxLongLong size);
static TranslatableString FormatSize(double size);
/** \brief Check a proposed file name string for illegal characters and
* remove them
@ -133,15 +133,6 @@ public:
*/
static bool SanitiseFilename(wxString &name, const wxString &sub);
/** \brief Remove accelerator characters from strings
*
* Utility function - takes a translatable string to be used as a menu item,
* for example _("&Splash...\tAlt+S"), and strips all of the menu
* accelerator stuff from it, to make "Splash". That way the same
* translatable string can be used both when accelerators are needed and
* when they aren't, saving translators effort. */
static wxString StripAccelerators(const wxString& str);
static const wxArrayString &GetExcludedCharacters()
{ return exclude; }
@ -151,8 +142,6 @@ private:
static wxArrayString exclude;
};
#define _NoAcc(X) Internat::StripAccelerators(_(X))
// Convert C strings to wxString
#define UTF8CTOWX(X) wxString((X), wxConvUTF8)
#define LAT1CTOWX(X) wxString((X), wxConvISO8859_1)

View File

@ -133,18 +133,22 @@ void LabelDialog::PopulateLabels()
mGrid->CreateGrid(0, Col_Max);
mGrid->SetDefaultCellAlignment(wxALIGN_LEFT, wxALIGN_CENTER);
/* i18n-hint: (noun). A track contains waves, audio etc.*/
mGrid->SetColLabelValue(0,_("Track"));
/* i18n-hint: (noun)*/
mGrid->SetColLabelValue(1,_("Label"));
/* i18n-hint: (noun) of a label*/
mGrid->SetColLabelValue(2,_("Start Time"));
/* i18n-hint: (noun) of a label*/
mGrid->SetColLabelValue(3,_("End Time"));
/* i18n-hint: (noun) of a label*/
mGrid->SetColLabelValue(4,_("Low Frequency"));
/* i18n-hint: (noun) of a label*/
mGrid->SetColLabelValue(5,_("High Frequency"));
size_t ii = 0;
for ( const auto &label : {
/* i18n-hint: (noun). A track contains waves, audio etc.*/
XO("Track"),
/* i18n-hint: (noun)*/
XO("Label"),
/* i18n-hint: (noun) of a label*/
XO("Start Time"),
/* i18n-hint: (noun) of a label*/
XO("End Time"),
/* i18n-hint: (noun) of a label*/
XO("Low Frequency"),
/* i18n-hint: (noun) of a label*/
XO("High Frequency"),
})
mGrid->SetColLabelValue( ii++, label.Translation() );
// Create and remember editors. No need to DELETE these as the wxGrid will
// do it for us. (The DecRef() that is needed after GetDefaultEditorForType

View File

@ -1187,9 +1187,10 @@ void MixerBoard::UpdateWidth()
//
void MixerBoard::MakeButtonBitmap( wxMemoryDC & dc, wxBitmap & WXUNUSED(bitmap), wxRect & bev, const wxString & str, bool up )
void MixerBoard::MakeButtonBitmap( wxMemoryDC & dc, wxBitmap & WXUNUSED(bitmap), wxRect & bev, const TranslatableString & str, bool up )
{
const auto translation = str.Translation();
int textWidth, textHeight;
int fontSize = 10;
@ -1197,7 +1198,7 @@ void MixerBoard::MakeButtonBitmap( wxMemoryDC & dc, wxBitmap & WXUNUSED(bitmap),
fontSize = 8;
#endif
wxFont font(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
GetTextExtent(str, &textWidth, &textHeight, NULL, NULL, &font);
GetTextExtent(translation, &textWidth, &textHeight, NULL, NULL, &font);
AColor::UseThemeColour( &dc, clrMedium );
dc.DrawRectangle(bev);
@ -1209,15 +1210,15 @@ void MixerBoard::MakeButtonBitmap( wxMemoryDC & dc, wxBitmap & WXUNUSED(bitmap),
dc.SetFont(font);
dc.SetTextForeground(theTheme.Colour(clrTrackPanelText));
dc.SetBackgroundMode(wxTRANSPARENT);
dc.DrawText(str, x, y);
// dc.DrawText(str, 0, 0);
dc.DrawText(translation, x, y);
// dc.DrawText(translation, 0, 0);
}
void MixerBoard::CreateMuteSoloImages()
{
// Much of this is similar to TrackInfo::MuteOrSoloDrawFunction.
wxMemoryDC dc;
wxString str = _("Mute");
auto str = XO("Mute");
//mMuteSoloWidth = textWidth + kQuadrupleInset;
//if (mMuteSoloWidth < kRightSideStackWidth - kInset)
@ -1243,7 +1244,7 @@ void MixerBoard::CreateMuteSoloImages()
mImageMuteDisabled = std::make_unique<wxImage>(mMuteSoloWidth, MUTE_SOLO_HEIGHT); // Leave empty because unused.
str = _("Solo");
str = XO("Solo");
MakeButtonBitmap( dc, bitmap, bev, str, up );
mImageSoloUp = std::make_unique<wxImage>(bitmap.ConvertToImage());
mImageSoloOver = std::make_unique<wxImage>(bitmap.ConvertToImage()); // Same as up, for now.

View File

@ -224,7 +224,7 @@ private:
void ResetMeters(const bool bResetClipping);
void RemoveTrackCluster(size_t nIndex);
void MakeButtonBitmap( wxMemoryDC & dc, wxBitmap & bitmap,
wxRect & bev, const wxString & str, bool up );
wxRect & bev, const TranslatableString & str, bool up );
void CreateMuteSoloImages();
int FindMixerTrackCluster(const PlayableTrack* pTrack,
MixerTrackCluster** hMixerTrackCluster) const;

View File

@ -177,7 +177,7 @@ bool ProjectFileIO::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
auto &dirManager = DirManager::Get( project );
auto &settings = ProjectSettings::Get( project );
bool bFileVersionFound = false;
wxString fileVersion = _("<unrecognized version -- possibly corrupt project file>");
wxString fileVersion;
wxString audacityVersion = _("<unrecognized version -- possibly corrupt project file>");
int requiredTags = 0;
long longVpos = 0;

View File

@ -165,7 +165,7 @@ void UndoManager::CalculateSpaceUsage()
}
wxLongLong_t UndoManager::GetLongDescription(
unsigned int n, TranslatableString *desc, wxString *size)
unsigned int n, TranslatableString *desc, TranslatableString *size)
{
n -= 1; // 1 based to zero based

View File

@ -141,7 +141,7 @@ class AUDACITY_DLL_API UndoManager final
void GetShortDescription(unsigned int n, TranslatableString *desc);
// Return value must first be calculated by CalculateSpaceUsage():
wxLongLong_t GetLongDescription(
unsigned int n, TranslatableString *desc, wxString *size);
unsigned int n, TranslatableString *desc, TranslatableString *size);
void SetLongDescription(unsigned int n, const TranslatableString &desc);
// These functions accept a callback that uses the state,

View File

@ -434,18 +434,18 @@ namespace {
return format0.Format( value );
}
wxString FormatDifference( float diffdB )
TranslatableString FormatDifference( float diffdB )
{
if( diffdB != diffdB ) // test for NaN, reliant on IEEE implementation
return _("indeterminate");
return XO("indeterminate");
else {
if( diffdB != std::numeric_limits<float>::infinity() )
/* i18n-hint: dB abbreviates decibels
* RMS abbreviates root mean square, a certain averaging method */
return wxString::Format(_("%.2f dB RMS"), diffdB);
return XO("%.2f dB RMS").Format( diffdB );
else
/* i18n-hint: dB abbreviates decibels */
return _("Infinite dB difference");
return XO("Infinite dB difference");
}
}
@ -494,7 +494,7 @@ void ContrastDialog::results()
/* i18n-hint: i.e. difference in loudness at the moment. */
mDiffText->SetName(_("Current difference"));
mDiffText->ChangeValue( FormatDifference( diffdB ) );
mDiffText->ChangeValue( FormatDifference( diffdB ).Translation() );
}
if (mForegroundIsDefined) {

View File

@ -2211,10 +2211,10 @@ static Exporter::RegisteredExportPlugin sRegisteredPlugin{ "MP3",
// Return library version
//----------------------------------------------------------------------------
wxString GetMP3Version(wxWindow *parent, bool prompt)
TranslatableString GetMP3Version(wxWindow *parent, bool prompt)
{
MP3Exporter exporter;
wxString versionString = _("MP3 export library not found");
auto versionString = XO("MP3 export library not found");
#ifndef DISABLE_DYNAMIC_LOADING_LAME
if (prompt) {
@ -2223,10 +2223,9 @@ wxString GetMP3Version(wxWindow *parent, bool prompt)
if (exporter.LoadLibrary(parent, prompt ? MP3Exporter::Yes : MP3Exporter::No)) {
#endif // DISABLE_DYNAMIC_LOADING_LAME
versionString = exporter.GetLibraryVersion();
versionString = Verbatim( exporter.GetLibraryVersion() );
#ifdef MP3_EXPORT_BUILT_IN
versionString += " ";
versionString += _("(Built-in)");
versionString.Join( XO("(Built-in)"), " " );
#endif
#ifndef DISABLE_DYNAMIC_LOADING_LAME

View File

@ -29,13 +29,13 @@ extern EnumSetting< MP3RateMode > MP3RateModeSetting;
#define MP3_EXPORT_BUILT_IN 1
#endif
class wxString;
class TranslatableString;
class wxWindow;
//----------------------------------------------------------------------------
// Get MP3 library version
//----------------------------------------------------------------------------
wxString GetMP3Version(wxWindow *parent, bool prompt);
TranslatableString GetMP3Version(wxWindow *parent, bool prompt);
#endif

View File

@ -19,22 +19,22 @@ struct FoundTrack {
int trackNum{};
bool channel{};
wxString ComposeTrackName() const
TranslatableString ComposeTrackName() const
{
auto name = waveTrack->GetName();
auto shortName = name == waveTrack->GetDefaultName()
/* i18n-hint: compose a name identifying an unnamed track by number */
? wxString::Format( _("Track %d"), trackNum )
: name;
? XO("Track %d").Format( trackNum )
: Verbatim(name);
auto longName = shortName;
if (channel) {
// TODO: more-than-two-channels-message
if ( waveTrack->IsLeader() )
/* i18n-hint: given the name of a track, specify its left channel */
longName = wxString::Format(_("%s left"), shortName);
longName = XO("%s left").Format(shortName);
else
/* i18n-hint: given the name of a track, specify its right channel */
longName = wxString::Format(_("%s right"), shortName);
longName = XO("%s right").Format(shortName);
}
return longName;
}

View File

@ -200,7 +200,7 @@ void DirectoriesPrefs::OnChooseTempDir(wxCommandEvent & e)
void DirectoriesPrefs::UpdateFreeSpace(wxCommandEvent & WXUNUSED(event))
{
wxString tempDir;
wxString label;
TranslatableString label;
if (mTempDir != NULL) {
tempDir = mTempDir->GetValue();
@ -212,12 +212,12 @@ void DirectoriesPrefs::UpdateFreeSpace(wxCommandEvent & WXUNUSED(event))
label = Internat::FormatSize(space);
}
else {
label = _("unavailable - above location doesn't exist");
label = XO("unavailable - above location doesn't exist");
}
if( mFreeSpace != NULL ) {
mFreeSpace->SetLabel(label);
mFreeSpace->SetName(label); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
mFreeSpace->SetLabel(label.Translation());
mFreeSpace->SetName(label.Translation()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
}
}

View File

@ -185,7 +185,7 @@ void LibraryPrefs::PopulateOrExchange(ShuttleGui & S)
/// of the MP3 Library version.
void LibraryPrefs::SetMP3VersionText(bool prompt)
{
mMP3Version->SetLabel(GetMP3Version(this, prompt));
mMP3Version->SetLabel(GetMP3Version(this, prompt).Translation());
mMP3Version->SetName(mMP3Version->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
}
@ -205,7 +205,7 @@ void LibraryPrefs::OnMP3DownButton(wxCommandEvent & WXUNUSED(event))
void LibraryPrefs::SetFFmpegVersionText()
{
mFFmpegVersion->SetLabel(GetFFmpegVersion(this));
mFFmpegVersion->SetLabel(GetFFmpegVersion().Translation());
mFFmpegVersion->SetName(mFFmpegVersion->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
}