我在翻译 QActions 时遇到了一些问题
在翻译文件中有 FILETAB_* 字符串的翻译,
但在应用程序中没有使用这些翻译,例如,用户参见
FILETAB_OPEN_FILE。
有人能帮忙吗?
void Application::setLanguage(const QString& locale)
{
// remove previous
if (current)
{
removeTranslator(current);
}
current_locale=locale;
// install new
current = translators.value(locale, 0);
if (current)
{
installTranslator(current);
}
}
void MainWindow::changeEvent(QEvent *event)
{
if (event->type()==QEvent::LanguageChange)
{
retranslateUi(this);
}
QMainWindow::changeEvent(event);
}
void MainWindow::setupFileTabel()
{
fileTableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
fileTableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
setupFileTabelContextMenu();
}
void MainWindow::setupFileTabelContextMenu()
{
fileTabMenu = new QMenu(fileTableWidget);
openFile = new QAction(tr("FILETAB_OPEN_FILE"), fileTabMenu);
QObject::connect(openFile, SIGNAL(triggered()), this, SLOT(OpenFileSelected()));
fileTabMenu->addAction(openFile);
openDir = new QAction(tr("FILETAB_OPEN_FOLDER"), this);
QObject::connect(openDir, SIGNAL(triggered()), this, SLOT(OpenDirSelected()));
fileTabMenu->addAction(openDir);
fileTabMenu->addSeparator();
priority = new QMenu(fileTabMenu);
priority->setTitle(tr("FILETAB_PRIORITY"));
lowPriority = new QAction(tr("FILETAB_PRIORITY_LOW"), fileTabMenu);
lowPriority->setCheckable(true);
QObject::connect(lowPriority, SIGNAL(triggered()), this, SLOT(setLowForCurrentFile()));
priority->addAction(lowPriority);
mediumPriority = new QAction(tr("FILETAB_PRIORITY_MEDIUM"), fileTabMenu);
mediumPriority->setCheckable(true);
QObject::connect(mediumPriority, SIGNAL(triggered()), this, SLOT(setMediumForCurrentFile()));
priority->addAction(mediumPriority);
highPriority = new QAction(tr("FILETAB_PRIORITY_HIGH"), fileTabMenu);
highPriority->setCheckable(true);
QObject::connect(highPriority, SIGNAL(triggered()), this, SLOT(setHighForCurrentFile()));
priority->addAction(highPriority);
fileTabMenu->addMenu(priority);
fileTabMenu->addSeparator();
dontDownload = new QAction(tr("FILETAB_PRIORITY_ZERO"), fileTabMenu);
dontDownload->setCheckable(true);
QObject::connect(dontDownload, SIGNAL(triggered()), this, SLOT(setNotDownloadForCurrentFile()));
fileTabMenu->addAction(dontDownload);
}