Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Translations loaded but not installed : QLinguist
Qt 6.11 is out! See what's new in the release blog

Translations loaded but not installed : QLinguist

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
2 Posts 2 Posters 702 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SYAWA
    wrote on last edited by
    #1

    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.qrc

    OTHER_FILES +=
    ParserLDF/parser_ldf.y
    ParserLDF/parser_ldf.lex

    TRANSLATIONS = MESS2DBC_en_US.ts \

    CONFIG += lrelease
    CONFIG += embed_translations

    RC_ICONS = app-icon.ico

    #EEL Custom define
    DEFINES += APP_VERSION=\"4.6.15\"

    DISTFILES +=
    MESS2DBC_en_US.qm

    If someone has a solution to my problem, his help will be a great pleasure for me

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @SYAWA said in Translations loaded but not installed : QLinguist:

      if(English)
      {
      QTranslator translator;
      ...
      }

      Basic c++ - how long does this object live?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved