Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to make use of internationalization?
Forum Updated to NodeBB v4.3 + New Features

How to make use of internationalization?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 4 Posters 1.5k Views 2 Watching
  • 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.
  • Nisha_RN Offline
    Nisha_RN Offline
    Nisha_R
    wrote on last edited by A Former User
    #1

    This is main.cpp file

    #include <QGuiApplication>
    #include <QtGui>
    #include <QQuickView>
    #include <QTranslator>
    #include <QQmlContext>
    #include <QQmlProperty>
    #include <QCoreApplication>
    
    int main(int argc, char *argv[]) {
    QGuiApplication app(argc, argv);
    QQuickView view;
    QTranslator *translator1=new  QTranslator();
    translator1->load("xyz.ts");
    QCoreApplication::installTranslator(translator1);
    view.setSource(QUrl::fromLocalFile("C:/Users/nisha.r/Desktop/untitled/asa.qml"));
    view.show();
     return app.exec();
    }
    
    

    This is asa.qml file

    import QtQuick 2.7
    import QtQuick.Window 2.2
    Rectangle{
    
    Text {
        anchors.fill: parent
    text:qsTr("hello")
    }
    }
    
    

    ts file that is loaded is not reflected when executed.

    Julien BJ 1 Reply Last reply
    0
    • Nisha_RN Nisha_R

      This is main.cpp file

      #include <QGuiApplication>
      #include <QtGui>
      #include <QQuickView>
      #include <QTranslator>
      #include <QQmlContext>
      #include <QQmlProperty>
      #include <QCoreApplication>
      
      int main(int argc, char *argv[]) {
      QGuiApplication app(argc, argv);
      QQuickView view;
      QTranslator *translator1=new  QTranslator();
      translator1->load("xyz.ts");
      QCoreApplication::installTranslator(translator1);
      view.setSource(QUrl::fromLocalFile("C:/Users/nisha.r/Desktop/untitled/asa.qml"));
      view.show();
       return app.exec();
      }
      
      

      This is asa.qml file

      import QtQuick 2.7
      import QtQuick.Window 2.2
      Rectangle{
      
      Text {
          anchors.fill: parent
      text:qsTr("hello")
      }
      }
      
      

      ts file that is loaded is not reflected when executed.

      Julien BJ Offline
      Julien BJ Offline
      Julien B
      wrote on last edited by
      #2

      Hello @Nisha_R,

      You must convert the .ts file to a .qm file using lrelease.

      Then load your .qm file in your application.

      1 Reply Last reply
      0
      • Nisha_RN Offline
        Nisha_RN Offline
        Nisha_R
        wrote on last edited by Nisha_R
        #3

        @Julien-B thank you,
        i have tried with that , but still the same.

        ekkescornerE 1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          Hope you have included all your strings in cml using qstr. Run lupdate on the pro file. This generates the *.ts files. Now use Linquist tool & open the .ts file. Do all the conversions. Generate the *.qm(qm not QML). Now load the .qm file and install it as you done. This works.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply
          4
          • Nisha_RN Nisha_R

            @Julien-B thank you,
            i have tried with that , but still the same.

            ekkescornerE Offline
            ekkescornerE Offline
            ekkescorner
            Qt Champions 2016
            wrote on last edited by
            #5

            @Nisha_R perhaps my blog post will give you some ideas.

            ekke ... Qt Champion 2016 | 2024 ... mobile business apps
            5.15 --> 6.9 https://t1p.de/ekkeChecklist
            QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

            1 Reply Last reply
            4
            • Nisha_RN Offline
              Nisha_RN Offline
              Nisha_R
              wrote on last edited by Nisha_R
              #6

              @dheerendra thank you it worked, i had missed giving a path for qm file. in load function.
              @ekkescorner i shall look into it, thank you.

              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