Minor fixes in PCM and ensure static wxStrings are translated in dialog.

This commit is contained in:
jean-pierre charras 2021-08-30 14:15:12 +02:00
parent 6c16846b21
commit 6f84f3de1a
3 changed files with 13 additions and 7 deletions

View File

@ -44,7 +44,8 @@
#define GRID_CELL_MARGIN 4
// Notes: These strings are static, so wxGetTranslation must be called to display the
// transalted text
static std::vector<std::pair<PCM_PACKAGE_TYPE, wxString>> PACKAGE_TYPE_LIST = {
{ PT_PLUGIN, _( "Plugins (%d)" ) },
{ PT_LIBRARY, _( "Libraries (%d)" ) },
@ -70,7 +71,8 @@ DIALOG_PCM::DIALOG_PCM( wxWindow* parent ) : DIALOG_PCM_BASE( parent )
for( const auto& entry : PACKAGE_TYPE_LIST )
{
PANEL_PACKAGES_VIEW* panel = new PANEL_PACKAGES_VIEW( m_contentNotebook, m_pcm );
m_contentNotebook->AddPage( panel, wxString::Format( std::get<1>( entry ), 0 ) );
wxString msg = wxGetTranslation( std::get<1>( entry ) );
m_contentNotebook->AddPage( panel, wxString::Format( msg, 0 ) );
m_repositoryContentPanels.insert( { std::get<0>( entry ), panel } );
}
@ -305,7 +307,8 @@ void DIALOG_PCM::setRepositoryData( const wxString& aRepositoryId )
PCM_PACKAGE_TYPE type = PACKAGE_TYPE_LIST[i].first;
m_repositoryContentPanels[type]->SetData( data[type], m_callback );
m_contentNotebook->SetPageText(
i, wxString::Format( PACKAGE_TYPE_LIST[i].second, (int) data[type].size() ) );
i, wxString::Format( wxGetTranslation( PACKAGE_TYPE_LIST[i].second ),
(int) data[type].size() ) );
}
m_dialogNotebook->SetPageText(

View File

@ -75,7 +75,10 @@ PLUGIN_CONTENT_MANAGER::PLUGIN_CONTENT_MANAGER( wxWindow* aParent ) : m_dialog(
}
catch( std::exception& e )
{
wxLogError( wxString::Format( _( "Error loading schema: %s" ), e.what() ) );
if( !schema_file.FileExists() )
wxLogError( wxString::Format( _( "schema file '%s' not found" ), schema_file.GetFullPath() ) );
else
wxLogError( wxString::Format( _( "Error loading schema: %s" ), e.what() ) );
}
// Load currently installed packages

View File

@ -98,7 +98,7 @@ void PCM_TASK_MANAGER::DownloadAndInstall( const PCM_PACKAGE& aPackage, const wx
}
else
{
m_reporter->Report( wxString::Format( _( "Extracting package %s. " ),
m_reporter->Report( wxString::Format( _( "Extracting package '%s'." ),
aPackage.identifier ) );
if( extract( file_path.GetFullPath(), aPackage.identifier ) )
@ -113,7 +113,7 @@ void PCM_TASK_MANAGER::DownloadAndInstall( const PCM_PACKAGE& aPackage, const wx
}
}
m_reporter->Report( wxString::Format( _( "Removing downloaded archive %s. " ),
m_reporter->Report( wxString::Format( _( "Removing downloaded archive '%s'." ),
file_path.GetFullName() ) );
wxRemoveFile( file_path.GetFullPath() );
};
@ -154,7 +154,7 @@ int PCM_TASK_MANAGER::downloadFile( const wxString& aFilePath, const wxString& u
curl.SetFollowRedirects( true );
curl.SetTransferCallback( callback, 250000L );
m_reporter->Report( wxString::Format( _( "Downloading package url: %s" ), url ) );
m_reporter->Report( wxString::Format( _( "Downloading package url: '%s'" ), url ) );
int code = curl.Perform();