Skip to content

Commit

Permalink
Fix loading Qt translations on MinGW
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro authored and nyalldawson committed Jun 21, 2021
1 parent d5c3890 commit 94f2599
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/core/qgsapplication.cpp
Expand Up @@ -197,24 +197,30 @@ QgsApplication::QgsApplication( int &argc, char **argv, bool GUIenabled, const Q
* the About, Preferences and Quit items to the Mac Application menu.
* These items must be translated identically in both qt_ and qgis_ files.
*/
QString qtTranslationsPath = QLibraryInfo::location( QLibraryInfo::TranslationsPath );
#ifdef __MINGW32__
QString prefix = QDir( QString( "%1/../" ).arg( QApplication::applicationDirPath() ) ).absolutePath();
qtTranslationsPath = prefix + qtTranslationsPath.mid( QLibraryInfo::location( QLibraryInfo::PrefixPath ).length() );
#endif

mQtTranslator = new QTranslator();
if ( mQtTranslator->load( QStringLiteral( "qt_" ) + *sTranslation(), QLibraryInfo::location( QLibraryInfo::TranslationsPath ) ) )
if ( mQtTranslator->load( QStringLiteral( "qt_" ) + *sTranslation(), qtTranslationsPath ) )
{
installTranslator( mQtTranslator );
}
else
{
QgsDebugMsgLevel( QStringLiteral( "loading of qt translation failed %1/qt_%2" ).arg( QLibraryInfo::location( QLibraryInfo::TranslationsPath ), *sTranslation() ), 2 );
QgsDebugMsgLevel( QStringLiteral( "loading of qt translation failed %1/qt_%2" ).arg( qtTranslationsPath, *sTranslation() ), 2 );
}

mQtBaseTranslator = new QTranslator();
if ( mQtBaseTranslator->load( QStringLiteral( "qtbase_" ) + *sTranslation(), QLibraryInfo::location( QLibraryInfo::TranslationsPath ) ) )
if ( mQtBaseTranslator->load( QStringLiteral( "qtbase_" ) + *sTranslation(), qtTranslationsPath ) )
{
installTranslator( mQtBaseTranslator );
}
else
{
QgsDebugMsg( QStringLiteral( "loading of qtbase translation failed %1/qtbase_%2" ).arg( QLibraryInfo::location( QLibraryInfo::TranslationsPath ), *sTranslation() ) );
QgsDebugMsgLevel( QStringLiteral( "loading of qtbase translation failed %1/qt_%2" ).arg( qtTranslationsPath, *sTranslation() ), 2 );
}
}

Expand Down

0 comments on commit 94f2599

Please sign in to comment.