feat: 软件语言支持相关调动。
This commit is contained in:
parent
2a897e0099
commit
7e33b3b87a
|
@ -383,8 +383,7 @@ foreach(TS_FILE IN LISTS TS_FILES)
|
|||
"${LANG_NEED_COPY_PREFIX}/about.md"
|
||||
"${LANG_NEED_COPY_PREFIX}/components.md"
|
||||
"${LANG_NEED_COPY_PREFIX}/credits.md"
|
||||
"${LANG_NEED_COPY_PREFIX}/devs.md"
|
||||
"${LANG_NEED_COPY_PREFIX}/trans.md")
|
||||
"${LANG_NEED_COPY_PREFIX}/devs.md")
|
||||
add_custom_target(
|
||||
copy_lang_files
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${LANG_NEED_COPY} ${QM_DIR}
|
||||
|
@ -393,7 +392,7 @@ foreach(TS_FILE IN LISTS TS_FILES)
|
|||
set(LANG_PAK "${QM_DIR}/${LANG_PAK_NAME}")
|
||||
|
||||
set(LANG_COMPRESS_CONTENT "winghex.qm" "about.md" "components.md"
|
||||
"credits.md" "devs.md" "trans.md")
|
||||
"credits.md" "devs.md")
|
||||
|
||||
add_custom_target(
|
||||
pak_lang_files
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
|
||||
* 简体中文:寂静的羽夏(wingsummer)【原生支持】
|
|
@ -788,7 +788,7 @@
|
|||
<context>
|
||||
<name>LanguageManager</name>
|
||||
<message>
|
||||
<location filename="../../src/class/languagemanager.cpp" line="131"/>
|
||||
<location filename="../../src/class/languagemanager.cpp" line="112"/>
|
||||
<source>Chinese(Simplified)</source>
|
||||
<translation>中文(简体)</translation>
|
||||
</message>
|
||||
|
|
|
@ -107,6 +107,7 @@
|
|||
<file>images/workspace.png</file>
|
||||
<file>images/writable.png</file>
|
||||
<file>src/TESTCODE.as</file>
|
||||
<file>src/translist.md</file>
|
||||
</qresource>
|
||||
<qresource prefix="/qpathedit/icons">
|
||||
<file alias="dialog.ico">3rdparty/QPathEdit/Fatcow-Farm-Fresh-Dialog.ico</file>
|
||||
|
|
|
@ -56,24 +56,7 @@ LanguageManager::LanguageManager() {
|
|||
_defaultLocale = QLocale::system();
|
||||
|
||||
if (m_langs.isEmpty()) {
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||
if (QLocale::China == _defaultLocale.territory()
|
||||
#else
|
||||
if (QLocale::China == _defaultLocale.country()
|
||||
#endif
|
||||
) {
|
||||
QMessageBox::critical(
|
||||
nullptr, QStringLiteral("程序损坏"),
|
||||
QStringLiteral(
|
||||
"语言文件已损坏,请尝试重装软件以解决这个问题。"));
|
||||
} else {
|
||||
QMessageBox::critical(
|
||||
nullptr, QStringLiteral("Corruption"),
|
||||
QStringLiteral("The language file has been damaged. "
|
||||
"Please try reinstalling the software to "
|
||||
"solve the problem."));
|
||||
}
|
||||
qApp->exit(-1);
|
||||
abortAndExit();
|
||||
}
|
||||
|
||||
bool found = false;
|
||||
|
@ -123,9 +106,7 @@ LanguageManager::LanguageManager() {
|
|||
qApp->installTranslator(translator);
|
||||
}
|
||||
} else {
|
||||
WingMessageBox::critical(
|
||||
nullptr, qAppName(),
|
||||
"Translation files loading error! Please try to reinstall.");
|
||||
abortAndExit();
|
||||
}
|
||||
|
||||
m_langMap = {{"zh_CN", tr("Chinese(Simplified)")}};
|
||||
|
@ -141,22 +122,24 @@ bool LanguageManager::unpackTr(const QString &filename) {
|
|||
}
|
||||
|
||||
QZipReader reader(filename);
|
||||
|
||||
if (reader.count() != 5) {
|
||||
return false;
|
||||
}
|
||||
|
||||
_data = {};
|
||||
for (auto &file : reader.fileInfoList()) {
|
||||
if (file.isValid() && file.isFile) {
|
||||
if (file.filePath.endsWith(QStringLiteral("winghex.qm"))) {
|
||||
if (file.filePath == QStringLiteral("winghex.qm")) {
|
||||
_data.trFiles = reader.fileData(file.filePath);
|
||||
} else if (file.filePath.endsWith(QStringLiteral("about.md"))) {
|
||||
} else if (file.filePath == QStringLiteral("about.md")) {
|
||||
_data.about = reader.fileData(file.filePath);
|
||||
} else if (file.filePath.endsWith(
|
||||
QStringLiteral("components.md"))) {
|
||||
} else if (file.filePath == QStringLiteral("components.md")) {
|
||||
_data.component = reader.fileData(file.filePath);
|
||||
} else if (file.filePath.endsWith(QStringLiteral("credits.md"))) {
|
||||
} else if (file.filePath == QStringLiteral("credits.md")) {
|
||||
_data.credit = reader.fileData(file.filePath);
|
||||
} else if (file.filePath.endsWith(QStringLiteral("devs.md"))) {
|
||||
} else if (file.filePath == QStringLiteral("devs.md")) {
|
||||
_data.dev = reader.fileData(file.filePath);
|
||||
} else if (file.filePath.endsWith(QStringLiteral("trans.md"))) {
|
||||
_data.trans = reader.fileData(file.filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +147,27 @@ bool LanguageManager::unpackTr(const QString &filename) {
|
|||
|
||||
return !_data.trFiles.isEmpty() && !_data.about.isEmpty() &&
|
||||
!_data.component.isEmpty() && !_data.credit.isEmpty() &&
|
||||
!_data.dev.isEmpty() && !_data.trans.isEmpty();
|
||||
!_data.dev.isEmpty();
|
||||
}
|
||||
|
||||
void LanguageManager::abortAndExit() {
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||
if (QLocale::China == _defaultLocale.territory()
|
||||
#else
|
||||
if (QLocale::China == _defaultLocale.country()
|
||||
#endif
|
||||
) {
|
||||
WingMessageBox::critical(
|
||||
nullptr, QStringLiteral("程序损坏"),
|
||||
QStringLiteral("语言文件已损坏,请尝试重装软件以解决这个问题。"));
|
||||
} else {
|
||||
WingMessageBox::critical(
|
||||
nullptr, QStringLiteral("Corruption"),
|
||||
QStringLiteral("The language file has been damaged. "
|
||||
"Please try reinstalling the software to "
|
||||
"solve the problem."));
|
||||
}
|
||||
qApp->exit(-1);
|
||||
}
|
||||
|
||||
QLocale LanguageManager::defaultLocale() const { return _defaultLocale; }
|
||||
|
|
|
@ -33,7 +33,6 @@ public:
|
|||
QString component;
|
||||
QString dev;
|
||||
QString credit;
|
||||
QString trans;
|
||||
};
|
||||
|
||||
public:
|
||||
|
@ -53,6 +52,8 @@ private:
|
|||
private:
|
||||
bool unpackTr(const QString &filename);
|
||||
|
||||
void abortAndExit();
|
||||
|
||||
private:
|
||||
LanguageData _data;
|
||||
|
||||
|
|
|
@ -44,15 +44,13 @@ void ASObjTreeWidget::setEngine(asIScriptEngine *engine) {
|
|||
|
||||
auto header = QString::fromUtf8(node->role(QCodeNode::Name));
|
||||
auto item = new QTreeWidgetItem({header});
|
||||
item->setData(0, Qt::UserRole, node->qualifiedBaseName(true));
|
||||
item->setToolTip(0, header);
|
||||
item->setToolTip(0, node->qualifiedBaseName(true));
|
||||
item->setIcon(0, node->data(Qt::DecorationRole).value<QIcon>());
|
||||
|
||||
for (auto &n : node->children()) {
|
||||
QStringList contents{QString::fromUtf8(n->role(QCodeNode::Name)),
|
||||
n->data(Qt::ToolTipRole).toString()};
|
||||
auto c = new QTreeWidgetItem(contents);
|
||||
c->setData(0, Qt::UserRole, n->qualifiedBaseName(true));
|
||||
c->setToolTip(0, contents.at(0));
|
||||
c->setToolTip(1, contents.at(1));
|
||||
c->setIcon(0, n->data(Qt::DecorationRole).value<QIcon>());
|
||||
|
|
|
@ -29,7 +29,6 @@ AboutSoftwareDialog::AboutSoftwareDialog(QWidget *parent)
|
|||
ui->tbBaseObj->setMarkdown(data.component);
|
||||
ui->tbCredit->setMarkdown(data.credit);
|
||||
ui->tbDev->setMarkdown(data.dev);
|
||||
ui->tbTr->setMarkdown(data.trans);
|
||||
ui->lblVersion->setText(qApp->applicationVersion());
|
||||
ui->lblBuildDate->setText(QStringLiteral(__DATE__));
|
||||
|
||||
|
@ -40,6 +39,13 @@ AboutSoftwareDialog::AboutSoftwareDialog(QWidget *parent)
|
|||
auto ltxt = license.readAll();
|
||||
ui->tbLicense->setText(ltxt);
|
||||
|
||||
QFile trans(QStringLiteral(":/com.wingsummer.winghex/src/translist.md"));
|
||||
ret = trans.open(QFile::ReadOnly);
|
||||
Q_ASSERT(ret);
|
||||
Q_UNUSED(ret);
|
||||
auto ttxt = trans.readAll();
|
||||
ui->tbTr->setMarkdown(ttxt);
|
||||
|
||||
_dialog = new FramelessDialogBase(parent);
|
||||
_dialog->buildUpContent(this);
|
||||
_dialog->setWindowTitle(this->windowTitle());
|
||||
|
|
|
@ -47,11 +47,6 @@ namespace WingHex {
|
|||
|
||||
Q_DECL_UNUSED constexpr auto SDKVERSION = 13;
|
||||
|
||||
Q_DECL_UNUSED static QString GETPLUGINQM(const QString &name) {
|
||||
return QCoreApplication::applicationDirPath() +
|
||||
QStringLiteral("/plglang/") + name;
|
||||
};
|
||||
|
||||
Q_DECL_UNUSED static QString PLUGINDIR() {
|
||||
return QCoreApplication::applicationDirPath() + QStringLiteral("/plugin");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
* 简体中文:寂静的羽夏(wingsummer)
|
Loading…
Reference in New Issue