I'm having issues with the translation of my Qgis plugin.
static const QString sName = QObject::tr( "Editeur Monoscopique 3D" );
MyClass::MyClass( QgisInterface * theQgisInterface ):
QgisPlugin( sName)
{
QSettings tSettings;
QString qsUserLocale = tSettings.value( "locale/userLocale", "" ).toString();
if ( ( qsUserLocale != "fr_FR" ) && ( qsUserLocale != "fr" ) )
{
QString qsTranslationPath = ":/prefix/en_US.qm" ;
QFileInfo tFileInfo (qsTranslationPath) ;
if (tFileInfo.exists())
{
//QTranslator translator;
if (m_tTranslator.load( "en_US", ":/prefix" ) )
qApp->installTranslator(&m_tTranslator);
}
}
}
The problem is that sName
is declared before installing the translator qApp->installTranslator(&m_tTranslator);
and so its text is not translated !
How can I fix this?