Hi,
I have encountered problem with lupdate. It is not able to add few strings to translation file.
Simplified code sample is showed below.
TrProblem.pro
Code:
TARGET = TrProblem TEMPLATE = app TRANSLATIONS = TrProblem_de.ts DEFINES += EV_SOURCE SOURCES += main.cpp\ mainwindow.cpp HEADERS += mainwindow.h \ ../common/defs.h FORMS += mainwindow.ui
defs.h
Code:
#ifndef _DEFS_H_ #define _DEFS_H_ enum some_enum_t { SOME_VALUE_0 = 0, SOME_VALUE_1, SOME_VALUE_2, SOME_VALUE_3 }; #ifdef EV_SOURCE #include <QCoreApplication> class CommonStr { Q_DECLARE_TR_FUNCTIONS(CommonStr) public: static CommonStr& Acquire() { static CommonStr str; return str; } private: CommonStr() {}; }; #define RETURN_TYPE QString #define ACCESS_OBJECT #define TR(STRING) tr(STRING) #else #define ACCESS_OBJECT #define RETURN_TYPE char const * #define TR(STRING) STRING #endif inline RETURN_TYPE ACCESS_OBJECT to_str(product_t pt) { switch(pt) { case SOME_VALUE_0: return TR("SOME_VALUE_0"); case SOME_VALUE_1: return TR("SOME_VALUE_1"); case SOME_VALUE_2: return TR("SOME_VALUE_2"); case SOME_VALUE_3: return TR("SOME_VALUE_3"); default: return TR("UNKNOWN_VALUE"); } } #endif
mainwindow.cpp - CommomStr usage
Code:
#include "mainwindow.h" #include "ui_mainwindow.h" #include "defs.h" ui(new Ui::MainWindow) { ui->setupUi(this); str; } MainWindow::~MainWindow() { delete ui; }
After running command "lupdate -verbose TrProblem.pro" i receive such output:
Is there any problem with such macro definitions for lupdate? I know that tr() function does not work with #defines but if it expands defs.h correctly it should work in my opinion.Quote:
/usr/include/qt4/QtCore/qstringbuilder.h:45: circular inclusion of /usr/include/qt4/QtCore/qstring.h
/usr/include/qt4/QtGui/qwmatrix.h:45: circular inclusion of /usr/include/qt4/QtGui/qmatrix.h
/usr/include/qt4/QtGui/qactiongroup.h:45: circular inclusion of /usr/include/qt4/QtGui/qaction.h
/home/kuba/Develop/translation_problem/common/defs.h:46: tr() cannot be called without context
/home/kuba/Develop/translation_problem/common/defs.h:47: tr() cannot be called without context
/home/kuba/Develop/translation_problem/common/defs.h:48: tr() cannot be called without context
/home/kuba/Develop/translation_problem/common/defs.h:49: tr() cannot be called without context
/home/kuba/Develop/translation_problem/common/defs.h:50: tr() cannot be called without context
Updating 'TrProblem_de.ts'...
Found 1 source text(s) (0 new and 1 already existing)