Solved //: repeats text in the TS file
-
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.
-
@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?
-
@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 7MainWindow::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
-
@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.
-
@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). -
The issue is that extra comment duplicates the given text. How will varying the context help me?
-
@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. -
@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..