Translations loaded but not installed : QLinguist
-
Hi,
I work an interface software and I want to translate the items from French to English.
For this I use QLinguist Tool to do the translation. However, I have same problem, My app will not able to make the translation.
I have follown all documentation of Qlinguist but no solution. I am able to load the qm file et install the translation but nothing is translate.Here, you have my main and pro file :
main:
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
bool English =true;
// Changer la langue par défaut des widgets dans la langue du système (traduit les boutons des QMessageBox par ex.)if(English) { QTranslator translator; a.removeTranslator(&translator); const QStringList uilang = QLocale::system().uiLanguages(); for (const QString & locale : uilang) { const QString baseName = "MESS2DBC_"+ QLocale(locale).name(); if(translator.load(":/i18n/"+baseName)){ qDebug("Translator loaded"); a.installTranslator(&translator); break; } else { a.removeTranslator(&translator); } } } MainWindow w; w.show(); // le premier argument est le nom de l'executable, le second et suivant les commandes passés au programme if(argc == 2) // s'il y a 2 argument charger directement le projet M2C en paramètre de l'application { // Cela peut se produire quand on ouvre un M2C directement depuis windows ou par glisser-déposer sur l'executable w.chargerProjet(argv[1]); } return a.exec();
}
Pro File:
.
.....
....RESOURCES +=
IHM/ressource.qrcOTHER_FILES +=
ParserLDF/parser_ldf.y
ParserLDF/parser_ldf.lexTRANSLATIONS = MESS2DBC_en_US.ts \
CONFIG += lrelease
CONFIG += embed_translationsRC_ICONS = app-icon.ico
#EEL Custom define
DEFINES += APP_VERSION=\"4.6.15\"DISTFILES +=
MESS2DBC_en_US.qmIf someone has a solution to my problem, his help will be a great pleasure for me
-
@SYAWA said in Translations loaded but not installed : QLinguist:
if(English)
{
QTranslator translator;
...
}Basic c++ - how long does this object live?