Uses of TranslatableString in src/import

This commit is contained in:
Paul Licameli 2019-12-13 10:49:57 -05:00
parent f137bc197a
commit d32d464471
16 changed files with 175 additions and 85 deletions

View File

@ -67,7 +67,7 @@ public:
// Get a description of the file type this importer can import.
// Examples: "Ogg Vorbis", "MP3", "Uncompressed PCM"
virtual wxString GetPluginFormatDescription() = 0;
virtual TranslatableString GetPluginFormatDescription() = 0;
// Get a list of extensions this plugin expects to be able to
// import. If a filename matches any of these extensions,
@ -134,7 +134,7 @@ public:
// This is similar to GetImporterDescription, but if possible the
// importer will return a more specific description of the
// specific file that is open.
virtual wxString GetFileDescription() = 0;
virtual TranslatableString GetFileDescription() = 0;
// Return stream descriptions list
virtual void GetStreamInfo(wxArrayString & streamInfo) = 0;

View File

@ -346,7 +346,7 @@ void ApplyMacroDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event))
for (const auto &format : l) {
const Format *f = &format;
wxString newfilter = f->formatName + wxT("|");
wxString newfilter = f->formatName.Translation() + wxT("|");
for (size_t i = 0; i < f->formatExtensions.size(); i++) {
if (!newfilter.Contains(wxT("*.") + f->formatExtensions[i] + wxT(";")))
newfilter += wxT("*.") + f->formatExtensions[i] + wxT(";");

View File

@ -111,11 +111,11 @@ public:
// Importer plugins only
const wxString & GetImporterIdentifier() const;
const wxString & GetImporterFilterDescription() const;
const TranslatableString & GetImporterFilterDescription() const;
const FileExtensions & GetImporterExtensions() const;
void SetImporterIdentifier(const wxString & identifier);
void SetImporterFilterDescription(const wxString & filterDesc);
void SetImporterFilterDescription(const TranslatableString & filterDesc);
void SetImporterExtensions(FileExtensions extensions);
private:

View File

@ -986,7 +986,7 @@ wxArrayString ProjectFileManager::ShowOpenDialog(const wxString &extraformat, co
/* this loop runs once per supported _format_ */
const Format *f = &format;
wxString newfilter = f->formatName + wxT("|");
wxString newfilter = f->formatName.Translation() + wxT("|");
// bung format name into string plus | separator
for (size_t i = 0; i < f->formatExtensions.size(); i++) {
/* this loop runs once per valid _file extension_ for file containing
@ -1661,7 +1661,7 @@ bool ProjectFileManager::Import(
auto &dirManager = DirManager::Get( project );
auto oldTags = Tags::Get( project ).shared_from_this();
TrackHolders newTracks;
wxString errorMessage;
TranslatableString errorMessage;
{
// Backup Tags, before the import. Be prepared to roll back changes.
@ -1683,7 +1683,7 @@ bool ProjectFileManager::Import(
// Error message derived from Importer::Import
// Additional help via a Help button links to the manual.
ShowErrorDialog(&GetProjectFrame( project ), _("Error Importing"),
errorMessage, wxT("Importing_Audio"));
errorMessage.Translation(), wxT("Importing_Audio"));
}
if (!success)
return false;

View File

@ -345,7 +345,7 @@ bool Importer::Import(const FilePath &fName,
TrackFactory *trackFactory,
TrackHolders &tracks,
Tags *tags,
wxString &errorMessage)
TranslatableString &errorMessage)
{
AudacityProject *pProj = GetActiveProject();
auto cleanup = valueRestorer( pProj->mbBusyImporting, true );
@ -356,7 +356,9 @@ bool Importer::Import(const FilePath &fName,
#ifdef USE_MIDI
// MIDI files must be imported, not opened
if (FileNames::IsMidi(fName)) {
errorMessage.Printf(_("\"%s\" \nis a MIDI file, not an audio file. \nAudacity cannot open this type of file for playing, but you can\nedit it by clicking File > Import > MIDI."), fName);
errorMessage = XO(
"\"%s\" \nis a MIDI file, not an audio file. \nAudacity cannot open this type of file for playing, but you can\nedit it by clicking File > Import > MIDI.")
.Format( fName );
return false;
}
#endif
@ -391,7 +393,7 @@ bool Importer::Import(const FilePath &fName,
// store localized strings!
// The bad consequences of a change of locale are not severe -- only that
// a default choice of file type for an open dialog is not remembered
if (plugin->GetPluginFormatDescription().CompareTo(type) == 0)
if (plugin->GetPluginFormatDescription().Translation() == type )
{
// This plugin corresponds to user-selected filter, try it first.
wxLogDebug(wxT("Inserting %s"),plugin->GetPluginStringID());
@ -587,9 +589,8 @@ bool Importer::Import(const FilePath &fName,
{
if( unusableImportPlugin->SupportsExtension(extension) )
{
errorMessage.Printf(_("This version of Audacity was not compiled with %s support."),
unusableImportPlugin->
GetPluginFormatDescription());
errorMessage = XO("This version of Audacity was not compiled with %s support.")
.Format( unusableImportPlugin->GetPluginFormatDescription() );
return false;
}
}
@ -601,101 +602,131 @@ bool Importer::Import(const FilePath &fName,
// if someone has sent us a .cda file, send them away
if (extension.IsSameAs(wxT("cda"), false)) {
/* i18n-hint: %s will be the filename */
errorMessage.Printf(_("\"%s\" is an audio CD track. \nAudacity cannot open audio CDs directly. \nExtract (rip) the CD tracks to an audio format that \nAudacity can import, such as WAV or AIFF."), fName);
errorMessage = XO(
"\"%s\" is an audio CD track. \nAudacity cannot open audio CDs directly. \nExtract (rip) the CD tracks to an audio format that \nAudacity can import, such as WAV or AIFF.")
.Format( fName );
return false;
}
// playlist type files
if ((extension.IsSameAs(wxT("m3u"), false))||(extension.IsSameAs(wxT("ram"), false))||(extension.IsSameAs(wxT("pls"), false))) {
errorMessage.Printf(_("\"%s\" is a playlist file. \nAudacity cannot open this file because it only contains links to other files. \nYou may be able to open it in a text editor and download the actual audio files."), fName);
errorMessage = XO(
"\"%s\" is a playlist file. \nAudacity cannot open this file because it only contains links to other files. \nYou may be able to open it in a text editor and download the actual audio files.")
.Format( fName );
return false;
}
//WMA files of various forms
if ((extension.IsSameAs(wxT("wma"), false))||(extension.IsSameAs(wxT("asf"), false))) {
errorMessage.Printf(_("\"%s\" is a Windows Media Audio file. \nAudacity cannot open this type of file due to patent restrictions. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName);
errorMessage = XO(
"\"%s\" is a Windows Media Audio file. \nAudacity cannot open this type of file due to patent restrictions. \nYou need to convert it to a supported audio format, such as WAV or AIFF.")
.Format( fName );
return false;
}
//AAC files of various forms (probably not encrypted)
if ((extension.IsSameAs(wxT("aac"), false))||(extension.IsSameAs(wxT("m4a"), false))||(extension.IsSameAs(wxT("m4r"), false))||(extension.IsSameAs(wxT("mp4"), false))) {
errorMessage.Printf(_("\"%s\" is an Advanced Audio Coding file.\nWithout the optional FFmpeg library, Audacity cannot open this type of file.\nOtherwise, you need to convert it to a supported audio format, such as WAV or AIFF."), fName);
errorMessage = XO(
"\"%s\" is an Advanced Audio Coding file.\nWithout the optional FFmpeg library, Audacity cannot open this type of file.\nOtherwise, you need to convert it to a supported audio format, such as WAV or AIFF.")
.Format( fName );
return false;
}
// encrypted itunes files
if ((extension.IsSameAs(wxT("m4p"), false))) {
errorMessage.Printf(_("\"%s\" is an encrypted audio file. \nThese typically are from an online music store. \nAudacity cannot open this type of file due to the encryption. \nTry recording the file into Audacity, or burn it to audio CD then \nextract the CD track to a supported audio format such as WAV or AIFF."), fName);
errorMessage = XO(
"\"%s\" is an encrypted audio file. \nThese typically are from an online music store. \nAudacity cannot open this type of file due to the encryption. \nTry recording the file into Audacity, or burn it to audio CD then \nextract the CD track to a supported audio format such as WAV or AIFF.")
.Format( fName );
return false;
}
// Real Inc. files of various sorts
if ((extension.IsSameAs(wxT("ra"), false))||(extension.IsSameAs(wxT("rm"), false))||(extension.IsSameAs(wxT("rpm"), false))) {
errorMessage.Printf(_("\"%s\" is a RealPlayer media file. \nAudacity cannot open this proprietary format. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName);
errorMessage = XO(
"\"%s\" is a RealPlayer media file. \nAudacity cannot open this proprietary format. \nYou need to convert it to a supported audio format, such as WAV or AIFF.")
.Format( fName );
return false;
}
// Other notes-based formats
if ((extension.IsSameAs(wxT("kar"), false))||(extension.IsSameAs(wxT("mod"), false))||(extension.IsSameAs(wxT("rmi"), false))) {
errorMessage.Printf(_("\"%s\" is a notes-based file, not an audio file. \nAudacity cannot open this type of file. \nTry converting it to an audio file such as WAV or AIFF and \nthen import it, or record it into Audacity."), fName);
errorMessage = XO(
"\"%s\" is a notes-based file, not an audio file. \nAudacity cannot open this type of file. \nTry converting it to an audio file such as WAV or AIFF and \nthen import it, or record it into Audacity.")
.Format( fName );
return false;
}
// MusePack files
if ((extension.IsSameAs(wxT("mp+"), false))||(extension.IsSameAs(wxT("mpc"), false))||(extension.IsSameAs(wxT("mpp"), false))) {
errorMessage.Printf(_("\"%s\" is a Musepack audio file. \nAudacity cannot open this type of file. \nIf you think it might be an mp3 file, rename it to end with \".mp3\" \nand try importing it again. Otherwise you need to convert it to a supported audio \nformat, such as WAV or AIFF."), fName);
errorMessage = XO(
"\"%s\" is a Musepack audio file. \nAudacity cannot open this type of file. \nIf you think it might be an mp3 file, rename it to end with \".mp3\" \nand try importing it again. Otherwise you need to convert it to a supported audio \nformat, such as WAV or AIFF.")
.Format( fName );
return false;
}
// WavPack files
if ((extension.IsSameAs(wxT("wv"), false))||(extension.IsSameAs(wxT("wvc"), false))) {
errorMessage.Printf(_("\"%s\" is a Wavpack audio file. \nAudacity cannot open this type of file. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName);
errorMessage = XO(
"\"%s\" is a Wavpack audio file. \nAudacity cannot open this type of file. \nYou need to convert it to a supported audio format, such as WAV or AIFF.")
.Format( fName );
return false;
}
// AC3 files
if ((extension.IsSameAs(wxT("ac3"), false))) {
errorMessage.Printf(_("\"%s\" is a Dolby Digital audio file. \nAudacity cannot currently open this type of file. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName);
errorMessage = XO(
"\"%s\" is a Dolby Digital audio file. \nAudacity cannot currently open this type of file. \nYou need to convert it to a supported audio format, such as WAV or AIFF.")
.Format( fName );
return false;
}
// Speex files
if ((extension.IsSameAs(wxT("spx"), false))) {
errorMessage.Printf(_("\"%s\" is an Ogg Speex audio file. \nAudacity cannot currently open this type of file. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName);
errorMessage = XO(
"\"%s\" is an Ogg Speex audio file. \nAudacity cannot currently open this type of file. \nYou need to convert it to a supported audio format, such as WAV or AIFF.")
.Format( fName );
return false;
}
// Video files of various forms
if ((extension.IsSameAs(wxT("mpg"), false))||(extension.IsSameAs(wxT("mpeg"), false))||(extension.IsSameAs(wxT("avi"), false))||(extension.IsSameAs(wxT("wmv"), false))||(extension.IsSameAs(wxT("rv"), false))) {
errorMessage.Printf(_("\"%s\" is a video file. \nAudacity cannot currently open this type of file. \nYou need to extract the audio to a supported format, such as WAV or AIFF."), fName);
errorMessage = XO(
"\"%s\" is a video file. \nAudacity cannot currently open this type of file. \nYou need to extract the audio to a supported format, such as WAV or AIFF.")
.Format( fName );
return false;
}
// Audacity project
if (extension.IsSameAs(wxT("aup"), false)) {
errorMessage.Printf(_("\"%s\" is an Audacity Project file. \nUse the 'File > Open' command to open Audacity Projects."), fName);
errorMessage = XO(
"\"%s\" is an Audacity Project file. \nUse the 'File > Open' command to open Audacity Projects.")
.Format( fName );
return false;
}
if( !wxFileExists(fName)){
errorMessage.Printf(_("File \"%s\" not found."), fName);
errorMessage = XO( "File \"%s\" not found.").Format( fName );
return false;
}
// we were not able to recognize the file type
errorMessage.Printf(_("Audacity did not recognize the type of the file '%s'.\nTry installing FFmpeg. For uncompressed files, also try File > Import > Raw Data."),fName);
errorMessage = XO(
"Audacity did not recognize the type of the file '%s'.\nTry installing FFmpeg. For uncompressed files, also try File > Import > Raw Data.")
.Format( fName );
}
else
{
// We DO have a plugin for this file, but import failed.
wxString pluglist;
TranslatableString pluglist;
for (const auto &plugin : compatiblePlugins)
{
if (pluglist.empty())
pluglist = plugin->GetPluginFormatDescription();
else
pluglist = wxString::Format( _("%s, %s"),
pluglist, plugin->GetPluginFormatDescription() );
pluglist = XO("%s, %s")
.Format( pluglist, plugin->GetPluginFormatDescription() );
}
errorMessage.Printf(_("Audacity recognized the type of the file '%s'.\nImporters supposedly supporting such files are:\n%s,\nbut none of them understood this file format."),fName, pluglist);
errorMessage = XO(
"Audacity recognized the type of the file '%s'.\nImporters supposedly supporting such files are:\n%s,\nbut none of them understood this file format.")
.Format( fName, pluglist );
}
return false;
@ -774,9 +805,8 @@ ImportFileHandle::~ImportFileHandle()
void ImportFileHandle::CreateProgress()
{
wxFileName ff( mFilename );
wxString title;
title.Printf(_("Importing %s"), GetFileDescription());
auto title = XO("Importing %s").Format( GetFileDescription() ).Translation();
mProgress = std::make_unique< ProgressDialog >( title, ff.GetFullName() );
}

View File

@ -31,10 +31,10 @@ typedef bool (*progress_callback_t)( void *userData, float percent );
class Format {
public:
wxString formatName;
TranslatableString formatName;
FileExtensions formatExtensions;
Format(const wxString &_formatName,
Format(const TranslatableString &_formatName,
FileExtensions _formatExtensions):
formatName(_formatName),
formatExtensions( std::move( _formatExtensions ) )
@ -155,7 +155,7 @@ public:
TrackFactory *trackFactory,
TrackHolders &tracks,
Tags *tags,
wxString &errorMessage);
TranslatableString &errorMessage);
private:
static Importer mInstance;

View File

@ -39,7 +39,7 @@ Licensed under the GNU General Public License v2 or later
#include "../widgets/ProgressDialog.h"
#define DESC _("FFmpeg-compatible files")
#define DESC XO("FFmpeg-compatible files")
//TODO: remove non-audio extensions
#if defined(USE_FFMPEG)
@ -180,7 +180,7 @@ public:
~FFmpegImportPlugin() { }
wxString GetPluginStringID() override { return wxT("libav"); }
wxString GetPluginFormatDescription() override;
TranslatableString GetPluginFormatDescription() override;
///! Probes the file and opens it if appropriate
std::unique_ptr<ImportFileHandle> Open(const FilePath &Filename) override;
@ -204,7 +204,7 @@ public:
bool InitCodecs();
wxString GetFileDescription() override;
TranslatableString GetFileDescription() override;
ByteCount GetFileUncompressedBytes() override;
///! Imports audio
@ -286,7 +286,7 @@ private:
};
wxString FFmpegImportPlugin::GetPluginFormatDescription()
TranslatableString FFmpegImportPlugin::GetPluginFormatDescription()
{
return DESC;
}
@ -465,7 +465,7 @@ bool FFmpegImportFileHandle::InitCodecs()
return true;
}
wxString FFmpegImportFileHandle::GetFileDescription()
TranslatableString FFmpegImportFileHandle::GetFileDescription()
{
return DESC;
}

View File

@ -49,7 +49,7 @@
#define FLAC_HEADER "fLaC"
#define DESC _("FLAC files")
#define DESC XO("FLAC files")
static const auto exts = {
wxT("flac"),
@ -134,7 +134,7 @@ class FLACImportPlugin final : public ImportPlugin
~FLACImportPlugin() { }
wxString GetPluginStringID() override { return wxT("libflac"); }
wxString GetPluginFormatDescription() override;
TranslatableString GetPluginFormatDescription() override;
std::unique_ptr<ImportFileHandle> Open(const FilePath &Filename) override;
unsigned SequenceNumber() const override;
@ -150,7 +150,7 @@ public:
bool Init();
wxString GetFileDescription() override;
TranslatableString GetFileDescription() override;
ByteCount GetFileUncompressedBytes() override;
ProgressResult Import(TrackFactory *trackFactory, TrackHolders &outTracks,
Tags *tags) override;
@ -285,7 +285,7 @@ FLAC__StreamDecoderWriteStatus MyFLACFile::write_callback(const FLAC__Frame *fra
}, MakeSimpleGuard(FLAC__STREAM_DECODER_WRITE_STATUS_ABORT) );
}
wxString FLACImportPlugin::GetPluginFormatDescription()
TranslatableString FLACImportPlugin::GetPluginFormatDescription()
{
return DESC;
}
@ -425,7 +425,7 @@ bool FLACImportFileHandle::Init()
return true;
}
wxString FLACImportFileHandle::GetFileDescription()
TranslatableString FLACImportFileHandle::GetFileDescription()
{
return DESC;
}

View File

@ -31,7 +31,7 @@ Licensed under the GNU General Public License v2 or later
#include <wx/window.h>
#include <wx/log.h>
#define DESC _("GStreamer-compatible files")
#define DESC XO("GStreamer-compatible files")
// On Windows we don't have configure script to turn this on or off,
@ -165,7 +165,7 @@ public:
///\return true if successful, false otherwise
bool Init();
wxString GetFileDescription() override;
TranslatableString GetFileDescription() override;
ByteCount GetFileUncompressedBytes() override;
///! Called by Import.cpp
@ -240,7 +240,7 @@ public:
///! Destructor
virtual ~GStreamerImportPlugin();
wxString GetPluginFormatDescription() override;
TranslatableString GetPluginFormatDescription() override;
wxString GetPluginStringID() override;
@ -323,7 +323,7 @@ GStreamerImportPlugin::~GStreamerImportPlugin()
// ----------------------------------------------------------------------------
// Return the plugin description
wxString
TranslatableString
GStreamerImportPlugin::GetPluginFormatDescription()
{
return DESC;
@ -994,7 +994,7 @@ GStreamerImportFileHandle::Init()
// ----------------------------------------------------------------------------
// Return file dialog filter description
wxString
TranslatableString
GStreamerImportFileHandle::GetFileDescription()
{
return DESC;

View File

@ -96,7 +96,7 @@
#define BINARY_FILE_CHECK_BUFFER_SIZE 1024
#define DESC _("List of Files in basic text format")
#define DESC XO("List of Files in basic text format")
static const auto exts = {
wxT("lof")
@ -113,7 +113,7 @@ public:
~LOFImportPlugin() { }
wxString GetPluginStringID() override { return wxT("lof"); }
wxString GetPluginFormatDescription() override;
TranslatableString GetPluginFormatDescription() override;
std::unique_ptr<ImportFileHandle> Open(const FilePath &Filename) override;
unsigned SequenceNumber() const override;
@ -126,7 +126,7 @@ public:
LOFImportFileHandle(const FilePath & name, std::unique_ptr<wxTextFile> &&file);
~LOFImportFileHandle();
wxString GetFileDescription() override;
TranslatableString GetFileDescription() override;
ByteCount GetFileUncompressedBytes() override;
ProgressResult Import(TrackFactory *trackFactory, TrackHolders &outTracks,
Tags *tags) override;
@ -172,7 +172,7 @@ LOFImportFileHandle::LOFImportFileHandle
{
}
wxString LOFImportPlugin::GetPluginFormatDescription()
TranslatableString LOFImportPlugin::GetPluginFormatDescription()
{
return DESC;
}
@ -211,7 +211,7 @@ std::unique_ptr<ImportFileHandle> LOFImportPlugin::Open(const FilePath &filename
return std::make_unique<LOFImportFileHandle>(filename, std::move(file));
}
wxString LOFImportFileHandle::GetFileDescription()
TranslatableString LOFImportFileHandle::GetFileDescription()
{
return DESC;
}

View File

@ -45,7 +45,7 @@
#include "../prefs/QualityPrefs.h"
#include "../widgets/ProgressDialog.h"
#define DESC _("MP3 files")
#define DESC XO("MP3 files")
static const auto exts = {
wxT("mp3"),
@ -114,7 +114,7 @@ public:
~MP3ImportPlugin() { }
wxString GetPluginStringID() override { return wxT("libmad"); }
wxString GetPluginFormatDescription() override;
TranslatableString GetPluginFormatDescription() override;
std::unique_ptr<ImportFileHandle> Open(const FilePath &Filename) override;
unsigned SequenceNumber() const override;
@ -131,7 +131,7 @@ public:
~MP3ImportFileHandle();
wxString GetFileDescription() override;
TranslatableString GetFileDescription() override;
ByteCount GetFileUncompressedBytes() override;
ProgressResult Import(TrackFactory *trackFactory, TrackHolders &outTracks,
Tags *tags) override;
@ -172,7 +172,7 @@ inline float scale(mad_fixed_t sample)
}
wxString MP3ImportPlugin::GetPluginFormatDescription()
TranslatableString MP3ImportPlugin::GetPluginFormatDescription()
{
return DESC;
}
@ -190,7 +190,7 @@ std::unique_ptr<ImportFileHandle> MP3ImportPlugin::Open(const FilePath &Filename
return std::make_unique<MP3ImportFileHandle>(std::move(file), Filename);
}
wxString MP3ImportFileHandle::GetFileDescription()
TranslatableString MP3ImportFileHandle::GetFileDescription()
{
return DESC;
}

View File

@ -45,7 +45,7 @@
#include "../widgets/ProgressDialog.h"
#define DESC _("Ogg Vorbis files")
#define DESC XO("Ogg Vorbis files")
static const auto exts = {
wxT("ogg")
@ -88,7 +88,7 @@ public:
~OggImportPlugin() { }
wxString GetPluginStringID() override { return wxT("liboggvorbis"); }
wxString GetPluginFormatDescription() override;
TranslatableString GetPluginFormatDescription() override;
std::unique_ptr<ImportFileHandle> Open(const FilePath &Filename) override;
unsigned SequenceNumber() const override;
@ -119,7 +119,7 @@ public:
}
~OggImportFileHandle();
wxString GetFileDescription() override;
TranslatableString GetFileDescription() override;
ByteCount GetFileUncompressedBytes() override;
ProgressResult Import(TrackFactory *trackFactory, TrackHolders &outTracks,
Tags *tags) override;
@ -158,7 +158,7 @@ private:
};
wxString OggImportPlugin::GetPluginFormatDescription()
TranslatableString OggImportPlugin::GetPluginFormatDescription()
{
return DESC;
}
@ -218,7 +218,7 @@ static Importer::RegisteredImportPlugin registered{
std::make_unique< OggImportPlugin >()
};
wxString OggImportFileHandle::GetFileDescription()
TranslatableString OggImportFileHandle::GetFileDescription()
{
return DESC;
}

View File

@ -71,7 +71,7 @@
}
#endif
#define DESC _("WAV, AIFF, and other uncompressed types")
#define DESC XO("WAV, AIFF, and other uncompressed types")
class PCMImportPlugin final : public ImportPlugin
{
@ -84,7 +84,7 @@ public:
~PCMImportPlugin() { }
wxString GetPluginStringID() override { return wxT("libsndfile"); }
wxString GetPluginFormatDescription() override;
TranslatableString GetPluginFormatDescription() override;
std::unique_ptr<ImportFileHandle> Open(const FilePath &Filename) override;
unsigned SequenceNumber() const override;
@ -97,7 +97,7 @@ public:
PCMImportFileHandle(const FilePath &name, SFFile &&file, SF_INFO info);
~PCMImportFileHandle();
wxString GetFileDescription() override;
TranslatableString GetFileDescription() override;
ByteCount GetFileUncompressedBytes() override;
ProgressResult Import(TrackFactory *trackFactory, TrackHolders &outTracks,
Tags *tags) override;
@ -119,7 +119,7 @@ private:
sampleFormat mFormat;
};
wxString PCMImportPlugin::GetPluginFormatDescription()
TranslatableString PCMImportPlugin::GetPluginFormatDescription()
{
return DESC;
}
@ -220,9 +220,69 @@ PCMImportFileHandle::PCMImportFileHandle(const FilePath &name,
mFormat = floatSample;
}
wxString PCMImportFileHandle::GetFileDescription()
TranslatableString PCMImportFileHandle::GetFileDescription()
{
return SFCall<wxString>(sf_header_name, mInfo.format);
// Library strings
// See the major_formats and subtype_formats tables in command.c in
// libsndfile for this list of possibilities
using Unevaluated = decltype(
/* major_formats */
XO("AIFF (Apple/SGI)")
, XO("AU (Sun/NeXT)")
, XO("AVR (Audio Visual Research)")
, XO("CAF (Apple Core Audio File)")
, XO("FLAC (FLAC Lossless Audio Codec)")
, XO("HTK (HMM Tool Kit)")
, XO("IFF (Amiga IFF/SVX8/SV16)")
, XO("MAT4 (GNU Octave 2.0 / Matlab 4.2)")
, XO("MAT5 (GNU Octave 2.1 / Matlab 5.0)")
, XO("MPC (Akai MPC 2k)")
, XO("OGG (OGG Container format)")
, XO("PAF (Ensoniq PARIS)")
, XO("PVF (Portable Voice Format)")
, XO("RAW (header-less)")
, XO("RF64 (RIFF 64)")
, XO("SD2 (Sound Designer II)")
, XO("SDS (Midi Sample Dump Standard)")
, XO("SF (Berkeley/IRCAM/CARL)")
, XO("VOC (Creative Labs)")
, XO("W64 (SoundFoundry WAVE 64)")
, XO("WAV (Microsoft)")
, XO("WAV (NIST Sphere)")
, XO("WAVEX (Microsoft)")
, XO("WVE (Psion Series 3)")
, XO("XI (FastTracker 2)")
);
using Unevaluated2 = decltype(
/* subtype_formats */
XO("Signed 8 bit PCM")
, XO("Signed 16 bit PCM")
, XO("Signed 24 bit PCM")
, XO("Signed 32 bit PCM")
, XO("Unsigned 8 bit PCM")
, XO("32 bit float")
, XO("64 bit float")
, XO("U-Law")
, XO("A-Law")
, XO("IMA ADPCM")
, XO("Microsoft ADPCM")
, XO("GSM 6.10")
, XO("32kbs G721 ADPCM")
, XO("24kbs G723 ADPCM")
, XO("12 bit DWVW")
, XO("16 bit DWVW")
, XO("24 bit DWVW")
, XO("VOX ADPCM")
, XO("16 bit DPCM")
, XO("8 bit DPCM")
, XO("Vorbis")
);
auto untranslated = SFCall<wxString>(sf_header_name, mInfo.format);
return TranslatableString{
untranslated, {} };
}
auto PCMImportFileHandle::GetFileUncompressedBytes() -> ByteCount

View File

@ -73,7 +73,7 @@ public:
// Get a description of the file type this importer can import.
// Examples: "Ogg Vorbis", "MP3", "Uncompressed PCM"
virtual wxString GetPluginFormatDescription() = 0;
virtual TranslatableString GetPluginFormatDescription() = 0;
// Get a list of extensions this plugin expects to be able to
// import. If a filename matches any of these extensions,
@ -120,10 +120,10 @@ public:
// identify the filename being imported.
void CreateProgress();
// This is similar to GetImporterDescription, but if possible the
// This is similar to GetPluginFormatDescription, but if possible the
// importer will return a more specific description of the
// specific file that is open.
virtual wxString GetFileDescription() = 0;
virtual TranslatableString GetFileDescription() = 0;
// Return an estimate of how many bytes the file will occupy once
// imported. In principle this may exceed main memory, so don't use
@ -162,13 +162,13 @@ class UnusableImportPlugin
{
public:
UnusableImportPlugin(
const wxString &formatName, FileExtensions extensions):
const TranslatableString &formatName, FileExtensions extensions):
mFormatName(formatName),
mExtensions( std::move( extensions ) )
{
}
wxString GetPluginFormatDescription()
TranslatableString GetPluginFormatDescription()
{
return mFormatName;
}
@ -179,7 +179,7 @@ public:
}
private:
wxString mFormatName;
TranslatableString mFormatName;
const FileExtensions mExtensions;
};

View File

@ -121,7 +121,7 @@ class QTImportPlugin final : public ImportPlugin
wxString GetPluginStringID() { return wxT("quicktime"); }
wxString GetPluginFormatDescription();
TranslatableString GetPluginFormatDescription();
std::unique_ptr<ImportFileHandle> Open(const wxString & Filename) override;
unsigned SequenceNumber() const override;
@ -147,7 +147,7 @@ class QTImportFileHandle final : public ImportFileHandle
}
}
wxString GetFileDescription() override;
TranslatableString GetFileDescription() override;
ByteCount GetFileUncompressedBytes() override;
wxInt32 GetStreamCount() override
@ -175,7 +175,7 @@ class QTImportFileHandle final : public ImportFileHandle
Movie mMovie;
};
wxString QTImportPlugin::GetPluginFormatDescription()
TranslatableString QTImportPlugin::GetPluginFormatDescription()
{
return DESC;
}
@ -230,7 +230,7 @@ static Importer::RegisteredImportPlugin registered{
};
wxString QTImportFileHandle::GetFileDescription()
TranslatableString QTImportFileHandle::GetFileDescription()
{
return DESC;
}

View File

@ -467,7 +467,7 @@ void ExtImportPrefs::DoOnRuleTableSelect (int toprow)
if (item->filter_objects[i] != NULL)
{
PluginList->InsertItem (i + shift,
item->filter_objects[i]->GetPluginFormatDescription());
item->filter_objects[i]->GetPluginFormatDescription().Translation());
}
else
{