Hi,
i have in .h file this:
#define ITEM "textToTranslate"
how can i translate it?
and second, i have in file some text, which is loaded into QDraw. how can i transtale this text. text for translating is still same.
Hi,
i have in .h file this:
#define ITEM "textToTranslate"
how can i translate it?
and second, i have in file some text, which is loaded into QDraw. how can i transtale this text. text for translating is still same.
You could try:
#define ITEM QT_TR_NOOP("textToTranslate")
and then tr(ITEM) but in general using such defines in C++ is not a very good approach.
Much cleaner solution is:
Qt Code:
const char * const ITEM = QT_TR_NOOP("textToTranslate"); sth->setText(tr(ITEM));To copy to clipboard, switch view to plain text mode
What is QDraw?and second, i have in file some text, which is loaded into QDraw.
You'd need to manually teach your message catalog about the string to be translated. It's better to avoid such solutions. What do you need it for?how can i transtale this text. text for translating is still same.
A possible solution could be to reimplement QTranslator::translate().
Last edited by wysota; 16th December 2013 at 14:38.
stevocz (17th December 2013)
thank you for reply.
i am try
#define ITEM QT_TR_NOOP("textToTranslate")
and then tr(ITEM)
but doesnt work. textToTranslate missing in ts file.
What is QDraw?
sorry i mean in painter drawText
i have one application which create xml file and text. this text is for show in second application
Last edited by stevocz; 16th December 2013 at 14:01.
second possibility doesnt work too. after lupdate, textToTranslate missing in ts file.
maybe i'm missing something here, but isn't it SUPPOSED to not be able to translate "textToTranslate" ? Without spaces its not really a word.
textToTranslat is only example. i have text with spaces and text with only one word.
something is wrong, but i don't know what, because i can't transtale this:
ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Ok"));
ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel"));
application after start crash
but other things work ok.
stevocz (17th December 2013)
i am stupidi call Ok button but i have Save button.
but #define or const char * const ITEM still not work
Last edited by stevocz; 17th December 2013 at 08:39.
I am edited one example
and QDialogButtonBox text is in .ts file but translate doesn' work. why?
The translation mark is outside a context. Either put it in a context or use QT_TRANSLATE_NOOP instead of QT_TR_NOOP passing a context to the call. Make sure the same context is used with the tr() call.
stevocz (17th December 2013)
can you fix it and send me back this application?
because i am try this:
const char * const TEXT_TO_TRANSLATE = QT_TRANSLATE_NOOP("translateCategory", "Translate");
and "Translate" is in .ts file, but in application text isn't changed.
and please fix QDialogButtonBox
maybe a stupid question, but why translate the QDialogButtonBox strings again?
Those strings from Qt should already be translate for Qt.
If they aren't, maybe the Qt translation catalogue wasn't loaded?
See http://qt-project.org/doc/qt-4.8/i18...ng-translation
Cheers,
_
when i am erased .ts file and create new, QT_TRANSLATE_NOOP works ok
this
const char * const TEXT_TO_TRANSLATE = QT_TRANSLATE_NOOP("translateCategory", "translate");
ui.label_2->setText(QApplication::translate("translateCategor y",TEXT_TO_TRANSLATE));
and this
const char * const TEXT_TO_TRANSLATE = QT_TRANSLATE_NOOP("QObject", "translate");
ui.label_2->setText(QObject::tr(TEXT_TO_TRANSLATE));
booth work.
or best for this example
const char * const TEXT_TO_TRANSLATE = QT_TRANSLATE_NOOP("MainWindow", "translate");
ui.label_2->setText(tr(TEXT_TO_TRANSLATE));
work too.
Last edited by stevocz; 17th December 2013 at 14:28.
yes, tr() is modified and works. now i must edit QDialogButtonBox.
but how? i am tried load QLibraryInfo but doesnt work
Bookmarks