diff --git a/src/Dependencies.cpp b/src/Dependencies.cpp index 148ff4eb2..561211b5a 100644 --- a/src/Dependencies.cpp +++ b/src/Dependencies.cpp @@ -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(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(); } } diff --git a/src/FFmpeg.cpp b/src/FFmpeg.cpp index 8948b85cc..805c075f9 100644 --- a/src/FFmpeg.cpp +++ b/src/FFmpeg.cpp @@ -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(); diff --git a/src/FFmpeg.h b/src/FFmpeg.h index 3d0ab31c7..abe685f35 100644 --- a/src/FFmpeg.h +++ b/src/FFmpeg.h @@ -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) diff --git a/src/HistoryWindow.cpp b/src/HistoryWindow.cpp index 4251ad9c5..10b0f6e6a 100644 --- a/src/HistoryWindow.cpp +++ b/src/HistoryWindow.cpp @@ -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); diff --git a/src/Internat.cpp b/src/Internat.cpp index 7687f4bd3..8eb1d8cc1 100644 --- a/src/Internat.cpp +++ b/src/Internat.cpp @@ -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) { diff --git a/src/Internat.h b/src/Internat.h index e529c5661..a6aa0b26a 100644 --- a/src/Internat.h +++ b/src/Internat.h @@ -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) diff --git a/src/LabelDialog.cpp b/src/LabelDialog.cpp index a124290ac..3d7b77e74 100644 --- a/src/LabelDialog.cpp +++ b/src/LabelDialog.cpp @@ -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 diff --git a/src/MixerBoard.cpp b/src/MixerBoard.cpp index 085480c10..26b34b011 100644 --- a/src/MixerBoard.cpp +++ b/src/MixerBoard.cpp @@ -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(mMuteSoloWidth, MUTE_SOLO_HEIGHT); // Leave empty because unused. - str = _("Solo"); + str = XO("Solo"); MakeButtonBitmap( dc, bitmap, bev, str, up ); mImageSoloUp = std::make_unique(bitmap.ConvertToImage()); mImageSoloOver = std::make_unique(bitmap.ConvertToImage()); // Same as up, for now. diff --git a/src/MixerBoard.h b/src/MixerBoard.h index d61b1b0d8..b74691c0e 100644 --- a/src/MixerBoard.h +++ b/src/MixerBoard.h @@ -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; diff --git a/src/ProjectFileIO.cpp b/src/ProjectFileIO.cpp index eaeda687f..45752ae68 100644 --- a/src/ProjectFileIO.cpp +++ b/src/ProjectFileIO.cpp @@ -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 = _(""); + wxString fileVersion; wxString audacityVersion = _(""); int requiredTags = 0; long longVpos = 0; diff --git a/src/UndoManager.cpp b/src/UndoManager.cpp index 601dd80ee..1e39c3545 100644 --- a/src/UndoManager.cpp +++ b/src/UndoManager.cpp @@ -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 diff --git a/src/UndoManager.h b/src/UndoManager.h index 78ad8340e..3daf36160 100644 --- a/src/UndoManager.h +++ b/src/UndoManager.h @@ -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, diff --git a/src/effects/Contrast.cpp b/src/effects/Contrast.cpp index 3f4bf7385..e77e84b2a 100644 --- a/src/effects/Contrast.cpp +++ b/src/effects/Contrast.cpp @@ -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::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) { diff --git a/src/export/ExportMP3.cpp b/src/export/ExportMP3.cpp index 20cca32a2..1eb6262fb 100644 --- a/src/export/ExportMP3.cpp +++ b/src/export/ExportMP3.cpp @@ -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 diff --git a/src/export/ExportMP3.h b/src/export/ExportMP3.h index 27c53482f..11528fe83 100644 --- a/src/export/ExportMP3.h +++ b/src/export/ExportMP3.h @@ -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 diff --git a/src/menus/ClipMenus.cpp b/src/menus/ClipMenus.cpp index 66a7809d1..b4b4ecbc0 100644 --- a/src/menus/ClipMenus.cpp +++ b/src/menus/ClipMenus.cpp @@ -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; } diff --git a/src/prefs/DirectoriesPrefs.cpp b/src/prefs/DirectoriesPrefs.cpp index a3f9365a5..34ee1c10f 100644 --- a/src/prefs/DirectoriesPrefs.cpp +++ b/src/prefs/DirectoriesPrefs.cpp @@ -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) } } diff --git a/src/prefs/LibraryPrefs.cpp b/src/prefs/LibraryPrefs.cpp index 7b8979c07..54aa70b8c 100644 --- a/src/prefs/LibraryPrefs.cpp +++ b/src/prefs/LibraryPrefs.cpp @@ -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) }