我有一个奇怪的问题翻译我的qt应用程序(qt 4.7.4在Windows上)。发生的情况如下:
1.-我执行lupdate并生成一个.ts文件。
2.-我用qt linguist编辑生成的.ts文件。
3.-我用之前的.ts文件执行lrelease。
4.-在Netbeans中,我清理并构建项目,然后运行它。
当我的应用程序运行时,大多数小部件(标签、按钮、标题、菜单操作、菜单)都会根据我之前生成的翻译文件进行翻译。问题是有些元素没有被翻译,尽管我在翻译文件中为它们提供了翻译(Qt语言学家识别它们)。
我的问题是:为什么有些文本正在被翻译,而另一些却被忽视了?
我已经确保每个文本都在tr()中。(正如我之前所说的,它们都出现在Qt Linguist中)。
谢谢你的帮助。
发布于 2013-07-10 15:45:25
所以它只适用于Linux,不适用于mingw32/mingw64。
main.cpp
#include <QtGui/QApplication>
#include "test_w32.h"
#include <QTranslator>
#include <QLocale>
int main(int argc, char** argv)
{
QApplication app(argc, argv);
QString locale = QLocale::system().name();
QTranslator translator;
translator.load(QString("test_w32_") +locale);
app.installTranslator(&translator);
test_w32 foo;
foo.show();
return app.exec();
}test_w32.h
#ifndef test_w32_H
#define test_w32_H
#include <QtGui/QMainWindow>
class test_w32 : public QMainWindow
{
Q_OBJECT
public:
test_w32();
virtual ~test_w32();
};
#endif // test_w32_Htest_w32.cpp
#include "test_w32.h"
#include <QtGui/QLabel>
#include <QtGui/QMenu>
#include <QtGui/QMenuBar>
#include <QtGui/QAction>
test_w32::test_w32()
{
QLabel* l = new QLabel( this );
l->setText(trUtf8( "Hello World!" ));
setCentralWidget( l );
QAction* a = new QAction(this);
a->setText(trUtf8( "Quit" ));
connect(a, SIGNAL(triggered()), SLOT(close()) );
menuBar()->addMenu(trUtf8( "File" ))->addAction( a );
}
test_w32::~test_w32()
{}
#include "test_w32.moc"有什么问题吗?谢谢
https://stackoverflow.com/questions/12062577
复制相似问题