Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. qtranslator with dynamic labels
Forum Updated to NodeBB v4.3 + New Features

qtranslator with dynamic labels

Scheduled Pinned Locked Moved Solved General and Desktop
45 Posts 4 Posters 9.6k Views 1 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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #26

    Hi
    No, the translation is not automatic.
    You use lupdate to extract the texts to the TS
    Then qt linguist to open and help translate
    then qt linguist can compile the ts to qm
    and you load the qm version to translate the app.

    But try to do the sample @J-Hilk links.
    Its very basic and shows the procedure very well.

    ? 1 Reply Last reply
    0
    • mrjjM mrjj

      Hi
      No, the translation is not automatic.
      You use lupdate to extract the texts to the TS
      Then qt linguist to open and help translate
      then qt linguist can compile the ts to qm
      and you load the qm version to translate the app.

      But try to do the sample @J-Hilk links.
      Its very basic and shows the procedure very well.

      ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #27

      @mrjj ok, I found a tutorial, tomorrow I try, thanks anyway

      mrjjM 1 Reply Last reply
      0
      • ? A Former User

        @mrjj ok, I found a tutorial, tomorrow I try, thanks anyway

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #28

        @vale88
        Hi
        Just a note.

        • but I would like see an exaple of file ts to see how I must write it

        You don't write the ts file your self. that part is from extracting the texts with the tool

        ? 1 Reply Last reply
        1
        • mrjjM mrjj

          @vale88
          Hi
          Just a note.

          • but I would like see an exaple of file ts to see how I must write it

          You don't write the ts file your self. that part is from extracting the texts with the tool

          ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #29

          @mrjj I found an example in youTube, without see I didn't understand, I solved, I used prompt di comandi, thanks anyway

          mrjjM Pablo J. RoginaP 2 Replies Last reply
          0
          • ? A Former User

            @mrjj I found an example in youTube, without see I didn't understand, I solved, I used prompt di comandi, thanks anyway

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #30

            @vale88
            Ok. super :)

            ? 1 Reply Last reply
            0
            • mrjjM mrjj

              @vale88
              Ok. super :)

              ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #31

              @mrjj only a thing..if I change something in my project, must I recreated my file ts? or I can update it

              mrjjM 1 Reply Last reply
              0
              • ? A Former User

                @mrjj only a thing..if I change something in my project, must I recreated my file ts? or I can update it

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #32

                @vale88
                You can update it.
                Just like how you created it first time.
                It will then add new texts to the file.

                1 Reply Last reply
                1
                • ? A Former User

                  @mrjj I found an example in youTube, without see I didn't understand, I solved, I used prompt di comandi, thanks anyway

                  Pablo J. RoginaP Offline
                  Pablo J. RoginaP Offline
                  Pablo J. Rogina
                  wrote on last edited by
                  #33

                  @vale88 said in qtranslator with dynamic labels:

                  I found an example in youTube

                  It'd be great you can share the link so other users in your same condition could benefit.

                  In addition, since your issue seems solved, please don't forget to update your post. Thanks.

                  Upvote the answer(s) that helped you solve the issue
                  Use "Topic Tools" button to mark your post as Solved
                  Add screenshots via postimage.org
                  Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                  ? 1 Reply Last reply
                  1
                  • Pablo J. RoginaP Pablo J. Rogina

                    @vale88 said in qtranslator with dynamic labels:

                    I found an example in youTube

                    It'd be great you can share the link so other users in your same condition could benefit.

                    In addition, since your issue seems solved, please don't forget to update your post. Thanks.

                    ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #34

                    @Pablo-J.-Rogina https://www.youtube.com/watch?v=In5QH_ZrDJE
                    but I noticed that if I push in button english then labels are written in english because I put tr, but the labels just written in Italian aren't changed in english if I click button after...is it normal?

                    mrjjM Pablo J. RoginaP 2 Replies Last reply
                    0
                    • ? A Former User

                      @Pablo-J.-Rogina https://www.youtube.com/watch?v=In5QH_ZrDJE
                      but I noticed that if I push in button english then labels are written in english because I put tr, but the labels just written in Italian aren't changed in english if I click button after...is it normal?

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #35

                      @vale88
                      Hi
                      Yes that is normal.
                      Only when you call setText , new text can be used if you loaded a installTranslator
                      in the mean time.

                      ? 1 Reply Last reply
                      0
                      • mrjjM mrjj

                        @vale88
                        Hi
                        Yes that is normal.
                        Only when you call setText , new text can be used if you loaded a installTranslator
                        in the mean time.

                        ? Offline
                        ? Offline
                        A Former User
                        wrote on last edited by
                        #36

                        @mrjj a ok, is there a way to solve it?if I try manually it isn't work because there the translator

                        mrjjM 1 Reply Last reply
                        0
                        • ? A Former User

                          @mrjj a ok, is there a way to solve it?if I try manually it isn't work because there the translator

                          mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by
                          #37

                          @vale88
                          Hi
                          Im not sure what you are doing.
                          After you loaded a new translator.
                          You must call setText on all Labels etc. to have them show translated text.

                          ? 1 Reply Last reply
                          0
                          • mrjjM mrjj

                            @vale88
                            Hi
                            Im not sure what you are doing.
                            After you loaded a new translator.
                            You must call setText on all Labels etc. to have them show translated text.

                            ? Offline
                            ? Offline
                            A Former User
                            wrote on last edited by
                            #38

                            @mrjj maybe i understood what you say, but I shoul control the text of the label and then setText inside I think

                            mrjjM 1 Reply Last reply
                            0
                            • ? A Former User

                              @mrjj maybe i understood what you say, but I shoul control the text of the label and then setText inside I think

                              mrjjM Offline
                              mrjjM Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on last edited by
                              #39

                              @vale88
                              An alternative to fiddling around changing language at runtime.
                              You could allow the user to select the language. save the selection to a file
                              and load that in main. when app starts.
                              Then to use new language, all you have to do is restart app.

                              1 Reply Last reply
                              0
                              • ? A Former User

                                @Pablo-J.-Rogina https://www.youtube.com/watch?v=In5QH_ZrDJE
                                but I noticed that if I push in button english then labels are written in english because I put tr, but the labels just written in Italian aren't changed in english if I click button after...is it normal?

                                Pablo J. RoginaP Offline
                                Pablo J. RoginaP Offline
                                Pablo J. Rogina
                                wrote on last edited by
                                #40

                                @vale88 said in qtranslator with dynamic labels:

                                ut I noticed that if I push in button english then labels are written in english because I put tr, but the labels just written in Italian aren't changed in english if I click button after

                                Could you please show both screenshot(s) of the issue and the corresponding snippet of source code?

                                Upvote the answer(s) that helped you solve the issue
                                Use "Topic Tools" button to mark your post as Solved
                                Add screenshots via postimage.org
                                Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                                ? 2 Replies Last reply
                                1
                                • Pablo J. RoginaP Pablo J. Rogina

                                  @vale88 said in qtranslator with dynamic labels:

                                  ut I noticed that if I push in button english then labels are written in english because I put tr, but the labels just written in Italian aren't changed in english if I click button after

                                  Could you please show both screenshot(s) of the issue and the corresponding snippet of source code?

                                  ? Offline
                                  ? Offline
                                  A Former User
                                  wrote on last edited by
                                  #41

                                  @Pablo-J.-Rogina

                                  void MainWindow::on_Traduzione_Inglese_clicked()
                                  {
                                  
                                      qApp->installTranslator(&inglese);
                                  
                                  
                                      ui->Traduzione_Italiano->setDisabled(false);
                                    
                                      
                                  }
                                  
                                  

                                  there is also change event, if I click the button before that the label is written there is the translation0_1555079949234_transeng.PNG
                                  but if the label is written and then click the button for translation the label is empty:
                                  0_1555080078884_transnono.PNG

                                  ? 1 Reply Last reply
                                  0
                                  • ? A Former User

                                    @Pablo-J.-Rogina

                                    void MainWindow::on_Traduzione_Inglese_clicked()
                                    {
                                    
                                        qApp->installTranslator(&inglese);
                                    
                                    
                                        ui->Traduzione_Italiano->setDisabled(false);
                                      
                                        
                                    }
                                    
                                    

                                    there is also change event, if I click the button before that the label is written there is the translation0_1555079949234_transeng.PNG
                                    but if the label is written and then click the button for translation the label is empty:
                                    0_1555080078884_transnono.PNG

                                    ? Offline
                                    ? Offline
                                    A Former User
                                    wrote on last edited by
                                    #42

                                    @vale88 void MainWindow::changeEvent(QEvent* event)
                                    {

                                    if(event->type() == QEvent::LanguageChange)
                                    {
                                        ui->retranslateUi(this);
                                    
                                        if(text=="CONF. CARICATA")
                                         ui->Info->setText("CONF. LOADED");
                                    
                                    }
                                    
                                    QWidget::changeEvent(event);
                                    

                                    }
                                    in this way it works, but it's manual

                                    1 Reply Last reply
                                    0
                                    • Pablo J. RoginaP Pablo J. Rogina

                                      @vale88 said in qtranslator with dynamic labels:

                                      ut I noticed that if I push in button english then labels are written in english because I put tr, but the labels just written in Italian aren't changed in english if I click button after

                                      Could you please show both screenshot(s) of the issue and the corresponding snippet of source code?

                                      ? Offline
                                      ? Offline
                                      A Former User
                                      wrote on last edited by
                                      #43

                                      @Pablo-J.-Rogina is there a way less manual?

                                      mrjjM 1 Reply Last reply
                                      0
                                      • ? A Former User

                                        @Pablo-J.-Rogina is there a way less manual?

                                        mrjjM Offline
                                        mrjjM Offline
                                        mrjj
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #44

                                        @vale88
                                        Hi
                                        Any widget that is not made with UI , must be manually handled.
                                        That is, call its setText again.

                                        ? 1 Reply Last reply
                                        1
                                        • mrjjM mrjj

                                          @vale88
                                          Hi
                                          Any widget that is not made with UI , must be manually handled.
                                          That is, call its setText again.

                                          ? Offline
                                          ? Offline
                                          A Former User
                                          wrote on last edited by
                                          #45

                                          @mrjj thanks

                                          1 Reply Last reply
                                          0

                                          • Login

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