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. //: repeats text in the TS file

//: repeats text in the TS file

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 4 Posters 2.1k Views 3 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.
  • V Offline
    V Offline
    vdevadass
    wrote on last edited by raven-worx
    #1

    Hi,

    Consider the following code snippet.

    //: m_var text
    m_var->setText( QApplication::translate("", "VAR ID :", "Disambiguation comment" ) );
    

    Qt generates the following in TS file:

    <message>
            <source>VAR ID:</source>
            <comment>Disambiguation comment</comment>
            <extracomment>m_var text m_var text</extracomment>
            <translation type="unfinished"></translation>
        </message>
    

    How do i correct the extra comment so that it prints only once as displayed below?

    <extracomment>m_var text</extracomment>
    

    Thanks.

    raven-worxR 1 Reply Last reply
    0
    • V vdevadass

      Hi,

      Consider the following code snippet.

      //: m_var text
      m_var->setText( QApplication::translate("", "VAR ID :", "Disambiguation comment" ) );
      

      Qt generates the following in TS file:

      <message>
              <source>VAR ID:</source>
              <comment>Disambiguation comment</comment>
              <extracomment>m_var text m_var text</extracomment>
              <translation type="unfinished"></translation>
          </message>
      

      How do i correct the extra comment so that it prints only once as displayed below?

      <extracomment>m_var text</extracomment>
      

      Thanks.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @vdevadass said in //: repeats text in the TS file:

      //: m_var text
      m_var->setText( QApplication::translate("", "VAR ID :", "Disambiguation comment" ) );

      may it be possible that you use the same identical translation-calls (incl. comment) in multiple locations in your source code?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • Pablo J. RoginaP Offline
        Pablo J. RoginaP Offline
        Pablo J. Rogina
        wrote on last edited by
        #3

        @vdevadass could you please describe your Qt environment? (i.e. Qt release, OS, etc.)
        I tried the following code snippet with Qt 4.8.2 under Windows 7

        MainWindow::MainWindow(QWidget *parent) :
            QMainWindow(parent),
            ui(new Ui::MainWindow)
        {
            ui->setupUi(this);
        
            QLabel* m_var = new QLabel();
        
            //: m_var text
            m_var->setText( QApplication::translate("", "VAR ID :", "Disambiguation comment" ) );
        }
        

        and I got the following contents in translation file (.ts):

        <message>
                <location filename="mainwindow.cpp" line="14"/>
                <source>VAR ID :</source>
                <comment>Disambiguation comment</comment>
                <extracomment>m_var text</extracomment>
                <translation type="unfinished"></translation>
            </message>
        

        exactly as expected according to the documentation

        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

        K 1 Reply Last reply
        -1
        • V Offline
          V Offline
          vdevadass
          wrote on last edited by vdevadass
          #4

          @raven-worx : Some text do repeat in the source code, but for those too i get double the amount of comments.
          For example, lets say i have multiple show texts in users page, the following is my ts file comment
          "<extracomment>show in user view 1
          //----------
          Users view 2
          //----------
          users view 3
          //----------
          show in users view 1
          //----------
          Users view 2
          //----------
          users view 3</extracomment> " (Excluding the //)

          @Pablo-J-Rogina : The Qt version is 4.8.4 and OS is Ubuntu/Linux.

          raven-worxR 1 Reply Last reply
          0
          • V vdevadass

            @raven-worx : Some text do repeat in the source code, but for those too i get double the amount of comments.
            For example, lets say i have multiple show texts in users page, the following is my ts file comment
            "<extracomment>show in user view 1
            //----------
            Users view 2
            //----------
            users view 3
            //----------
            show in users view 1
            //----------
            Users view 2
            //----------
            users view 3</extracomment> " (Excluding the //)

            @Pablo-J-Rogina : The Qt version is 4.8.4 and OS is Ubuntu/Linux.

            raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #5

            @vdevadass said in //: repeats text in the TS file:

            For example, lets say i have multiple show texts in users page

            then you get the extra comment for each usage.
            You can try to give each call to translate() a different context (first parameter).

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • V Offline
              V Offline
              vdevadass
              wrote on last edited by
              #6

              The issue is that extra comment duplicates the given text. How will varying the context help me?

              1 Reply Last reply
              0
              • Pablo J. RoginaP Offline
                Pablo J. RoginaP Offline
                Pablo J. Rogina
                wrote on last edited by
                #7

                @vdevadass Another question you may have is:
                "do I really really need the extra comment?"
                Maybe the answer is yes because you give the translation files to some translators that really need those extra comments to gather more context about the string to translate, but honestly in my experience those cases are not common.

                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
                0
                • Pablo J. RoginaP Pablo J. Rogina

                  @vdevadass could you please describe your Qt environment? (i.e. Qt release, OS, etc.)
                  I tried the following code snippet with Qt 4.8.2 under Windows 7

                  MainWindow::MainWindow(QWidget *parent) :
                      QMainWindow(parent),
                      ui(new Ui::MainWindow)
                  {
                      ui->setupUi(this);
                  
                      QLabel* m_var = new QLabel();
                  
                      //: m_var text
                      m_var->setText( QApplication::translate("", "VAR ID :", "Disambiguation comment" ) );
                  }
                  

                  and I got the following contents in translation file (.ts):

                  <message>
                          <location filename="mainwindow.cpp" line="14"/>
                          <source>VAR ID :</source>
                          <comment>Disambiguation comment</comment>
                          <extracomment>m_var text</extracomment>
                          <translation type="unfinished"></translation>
                      </message>
                  

                  exactly as expected according to the documentation

                  K Offline
                  K Offline
                  kumararajas
                  wrote on last edited by
                  #8

                  @Pablo-J.-Rogina said in //: repeats text in the TS file:

                  @vdevadass could you please describe your Qt environment? (i.e. Qt release, OS, etc.)
                  I tried the following code snippet with Qt 4.8.2 under Windows 7
                  MainWindow::MainWindow(QWidget *parent) :
                  QMainWindow(parent),
                  ui(new Ui::MainWindow)
                  {
                  ui->setupUi(this);

                  QLabel* m_var = new QLabel();
                  
                  //: m_var text
                  m_var->setText( QApplication::translate("", "VAR ID :", "Disambiguation comment" ) );
                  

                  }

                  and I got the following contents in translation file (.ts):
                  <message>
                  <location filename="mainwindow.cpp" line="14"/>
                  <source>VAR ID :</source>
                  <comment>Disambiguation comment</comment>
                  <extracomment>m_var text</extracomment>
                  <translation type="unfinished"></translation>
                  </message>

                  exactly as expected according to the documentation

                  @Venkatesh-V I am just curious to know why @Pablo-J-Rogina 's comment was downvoted? Will be interested to know the reason..

                  --Kumar

                  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