mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
add Chinese translations for QWebEngineView and QDialogButtonBox
This commit is contained in:
parent
3432c02e83
commit
bbfc12ab18
20
src/main.cpp
20
src/main.cpp
@ -153,19 +153,29 @@ int main(int argc, char *argv[])
|
|||||||
qDebug() << "openSSL" << QSslSocket::sslLibraryBuildVersionString()
|
qDebug() << "openSSL" << QSslSocket::sslLibraryBuildVersionString()
|
||||||
<< QSslSocket::sslLibraryVersionNumber();
|
<< QSslSocket::sslLibraryVersionNumber();
|
||||||
|
|
||||||
// Load missing translation for Qt.
|
// Load missing translation for Qt (QTextEdit/QPlainTextEdit/QTextBrowser).
|
||||||
QTranslator qtTranslator1;
|
QTranslator qtTranslator1;
|
||||||
if (qtTranslator1.load("widgets_" + locale, ":/translations")) {
|
if (qtTranslator1.load("widgets_" + locale, ":/translations")) {
|
||||||
app.installTranslator(&qtTranslator1);
|
app.installTranslator(&qtTranslator1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load translation for Qt.
|
|
||||||
QTranslator qtTranslator2;
|
QTranslator qtTranslator2;
|
||||||
if (!qtTranslator2.load("qt_" + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
|
if (qtTranslator2.load("qdialogbuttonbox_" + locale, ":/translations")) {
|
||||||
qtTranslator2.load("qt_" + locale, "translations");
|
app.installTranslator(&qtTranslator2);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.installTranslator(&qtTranslator2);
|
QTranslator qtTranslator3;
|
||||||
|
if (qtTranslator3.load("qwebengine_" + locale, ":/translations")) {
|
||||||
|
app.installTranslator(&qtTranslator3);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load translation for Qt.
|
||||||
|
QTranslator qtTranslator;
|
||||||
|
if (!qtTranslator.load("qt_" + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
|
||||||
|
qtTranslator.load("qt_" + locale, "translations");
|
||||||
|
}
|
||||||
|
|
||||||
|
app.installTranslator(&qtTranslator);
|
||||||
|
|
||||||
// Load translation for vnote.
|
// Load translation for vnote.
|
||||||
QTranslator translator;
|
QTranslator translator;
|
||||||
|
BIN
src/translations/qdialogbuttonbox_zh_CN.qm
Normal file
BIN
src/translations/qdialogbuttonbox_zh_CN.qm
Normal file
Binary file not shown.
79
src/translations/qdialogbuttonbox_zh_CN.ts
Normal file
79
src/translations/qdialogbuttonbox_zh_CN.ts
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.1" language="zh_CN">
|
||||||
|
<context>
|
||||||
|
<name>QPlatformTheme</name>
|
||||||
|
<message>
|
||||||
|
<source>OK</source>
|
||||||
|
<translation>确定</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Save</source>
|
||||||
|
<translation>保存</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Save All</source>
|
||||||
|
<translation>全部保存</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Open</source>
|
||||||
|
<translation>打开</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>&Yes</source>
|
||||||
|
<translation>是 (&Y)</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Yes to &All</source>
|
||||||
|
<translation>全部选择是 (&A)</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>&No</source>
|
||||||
|
<translation>否 (&N)</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>N&o to All</source>
|
||||||
|
<translation>全部选择否 (&O)</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Abort</source>
|
||||||
|
<translation>终止</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Retry</source>
|
||||||
|
<translation>重试</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Ignore</source>
|
||||||
|
<translation>忽略</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Close</source>
|
||||||
|
<translation>关闭</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Cancel</source>
|
||||||
|
<translation>取消</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Discard</source>
|
||||||
|
<translation>放弃</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Help</source>
|
||||||
|
<translation>帮助</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Apply</source>
|
||||||
|
<translation>应用</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Reset</source>
|
||||||
|
<translation>重置</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Restore Defaults</source>
|
||||||
|
<translation>恢复默认</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
BIN
src/translations/qwebengine_zh_CN.qm
Normal file
BIN
src/translations/qwebengine_zh_CN.qm
Normal file
Binary file not shown.
159
src/translations/qwebengine_zh_CN.ts
Normal file
159
src/translations/qwebengine_zh_CN.ts
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.1" language="zh_CN">
|
||||||
|
<context>
|
||||||
|
<name>QWebEnginePage</name>
|
||||||
|
<message>
|
||||||
|
<source>Back</source>
|
||||||
|
<translation>后退</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Forward</source>
|
||||||
|
<translation>前进</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Stop</source>
|
||||||
|
<translation>停止</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Reload</source>
|
||||||
|
<translation>重新加载</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Reload and Bypass Cache</source>
|
||||||
|
<translation>忽略缓存重新加载</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Cut</source>
|
||||||
|
<translation>剪切</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Copy</source>
|
||||||
|
<translation>复制</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Paste</source>
|
||||||
|
<translation>粘贴</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Undo</source>
|
||||||
|
<translation>撤销</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Redo</source>
|
||||||
|
<translation>恢复</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Select All</source>
|
||||||
|
<translation>选择全部</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Paste and Match Style</source>
|
||||||
|
<translation>粘贴并匹配样式</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Open Link in This Window</source>
|
||||||
|
<translation>在当前窗口打开链接</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Open Link in New Window</source>
|
||||||
|
<translation>在新窗口打开链接</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Open Link in New Tab</source>
|
||||||
|
<translation>在新标签页打开链接</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Open Link in New Background Tab</source>
|
||||||
|
<translation>在后台新标签页打开链接</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Copy Link URL</source>
|
||||||
|
<translation>复制链接地址</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Save Link</source>
|
||||||
|
<translation>保存链接</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Copy Image</source>
|
||||||
|
<translation>复制图片</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Copy Image URL</source>
|
||||||
|
<translation>复制图片地址</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Save Image</source>
|
||||||
|
<translation>保存图片</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Copy Media URL</source>
|
||||||
|
<translation>复制媒体地址</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Toggle Media Controls</source>
|
||||||
|
<translation>切换媒体控件</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Toggle Looping</source>
|
||||||
|
<translation>切换循环</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Toggle Play/Pause</source>
|
||||||
|
<translation>切换播放/暂停</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Toggle Mute</source>
|
||||||
|
<translation>切换静音</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Save Media</source>
|
||||||
|
<translation>保存媒体</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Inspect Element</source>
|
||||||
|
<translation>查看元素</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Exit Full Screen Mode</source>
|
||||||
|
<translation>退出全屏模式</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Close Page</source>
|
||||||
|
<translation>关闭页面</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Unselect</source>
|
||||||
|
<translation>取消选择</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Save &Page</source>
|
||||||
|
<translation>保存页面 (&P)</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Are you sure you want to leave this page?</source>
|
||||||
|
<translation>确认离开本页面?</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Follow Link</source>
|
||||||
|
<translation>打开链接</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>&Back</source>
|
||||||
|
<translation>后退 (&B)</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>&Forward</source>
|
||||||
|
<translation>前进 (&F)</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>&Reload</source>
|
||||||
|
<translation>重新加载 (&R)</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Select folder to upload</source>
|
||||||
|
<translation>选择文件夹上传</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
@ -231,5 +231,7 @@
|
|||||||
<file>resources/docs/tips_external_program_en.md</file>
|
<file>resources/docs/tips_external_program_en.md</file>
|
||||||
<file>resources/docs/tips_external_program_zh.md</file>
|
<file>resources/docs/tips_external_program_zh.md</file>
|
||||||
<file>translations/widgets_zh_CN.qm</file>
|
<file>translations/widgets_zh_CN.qm</file>
|
||||||
|
<file>translations/qdialogbuttonbox_zh_CN.qm</file>
|
||||||
|
<file>translations/qwebengine_zh_CN.qm</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@ -40,7 +40,7 @@ void VWebView::contextMenuEvent(QContextMenuEvent *p_event)
|
|||||||
// and the URL as URLs. If the URL contains Chinese, OneNote or Word could not
|
// and the URL as URLs. If the URL contains Chinese, OneNote or Word could not
|
||||||
// recognize it.
|
// recognize it.
|
||||||
// We need to change it to only-space-encoded text.
|
// We need to change it to only-space-encoded text.
|
||||||
QAction *copyImageUrlAct = getPageAction(actions, QWebEnginePage::CopyImageUrlToClipboard);
|
QAction *copyImageUrlAct = pageAction(QWebEnginePage::CopyImageUrlToClipboard);
|
||||||
if (actions.contains(copyImageUrlAct)) {
|
if (actions.contains(copyImageUrlAct)) {
|
||||||
connect(copyImageUrlAct, &QAction::triggered,
|
connect(copyImageUrlAct, &QAction::triggered,
|
||||||
this, &VWebView::handleCopyImageUrlAction);
|
this, &VWebView::handleCopyImageUrlAction);
|
||||||
@ -69,8 +69,8 @@ void VWebView::contextMenuEvent(QContextMenuEvent *p_event)
|
|||||||
// the fully-encoded URL to fetch the image while Windows seems to not
|
// the fully-encoded URL to fetch the image while Windows seems to not
|
||||||
// recognize it.
|
// recognize it.
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
QAction *defaultCopyImageAct = getPageAction(actions, QWebEnginePage::CopyImageToClipboard);
|
QAction *defaultCopyImageAct = pageAction(QWebEnginePage::CopyImageToClipboard);
|
||||||
if (defaultCopyImageAct && actions.contains(defaultCopyImageAct)) {
|
if (actions.contains(defaultCopyImageAct)) {
|
||||||
QAction *copyImageAct = new QAction(defaultCopyImageAct->text(), menu);
|
QAction *copyImageAct = new QAction(defaultCopyImageAct->text(), menu);
|
||||||
copyImageAct->setToolTip(defaultCopyImageAct->toolTip());
|
copyImageAct->setToolTip(defaultCopyImageAct->toolTip());
|
||||||
connect(copyImageAct, &QAction::triggered,
|
connect(copyImageAct, &QAction::triggered,
|
||||||
@ -164,24 +164,27 @@ void VWebView::hideUnusedActions(QMenu *p_menu)
|
|||||||
|
|
||||||
QList<QAction *> unusedActions;
|
QList<QAction *> unusedActions;
|
||||||
|
|
||||||
// Back.
|
// QWebEnginePage uses different actions of Back/Forward/Reload.
|
||||||
QAction *act = getPageAction(actions, QWebEnginePage::Back);
|
// [Woboq](https://code.woboq.org/qt5/qtwebengine/src/webenginewidgets/api/qwebenginepage.cpp.html#1652)
|
||||||
unusedActions.append(act);
|
// We tell these three actions by name.
|
||||||
|
static const QStringList actionNames({QWebEnginePage::tr("&Back"), QWebEnginePage::tr("&Forward"), QWebEnginePage::tr("&Reload")});
|
||||||
|
|
||||||
// Forward.
|
for (auto it : actions) {
|
||||||
act = getPageAction(actions, QWebEnginePage::Forward);
|
if (actionNames.contains(it->text())) {
|
||||||
unusedActions.append(act);
|
unusedActions.append(it);
|
||||||
|
}
|
||||||
// Reload.
|
}
|
||||||
act = getPageAction(actions, QWebEnginePage::Reload);
|
|
||||||
unusedActions.append(act);
|
|
||||||
|
|
||||||
// ViewSource.
|
// ViewSource.
|
||||||
act = getPageAction(actions, QWebEnginePage::ViewSource);
|
QAction *act = pageAction(QWebEnginePage::ViewSource);
|
||||||
unusedActions.append(act);
|
unusedActions.append(act);
|
||||||
|
|
||||||
// DownloadImageToDisk.
|
// DownloadImageToDisk.
|
||||||
act = getPageAction(actions, QWebEnginePage::DownloadImageToDisk);
|
act = pageAction(QWebEnginePage::DownloadImageToDisk);
|
||||||
|
unusedActions.append(act);
|
||||||
|
|
||||||
|
// DownloadLinkToDisk.
|
||||||
|
act = pageAction(QWebEnginePage::DownloadLinkToDisk);
|
||||||
unusedActions.append(act);
|
unusedActions.append(act);
|
||||||
|
|
||||||
for (auto it : unusedActions) {
|
for (auto it : unusedActions) {
|
||||||
@ -226,20 +229,3 @@ void VWebView::handleCopyAction()
|
|||||||
qDebug() << "clipboard copy Html altered" << html;
|
qDebug() << "clipboard copy Html altered" << html;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QAction *VWebView::getPageAction(const QList<QAction *> &p_actions,
|
|
||||||
QWebEnginePage::WebAction p_webAction)
|
|
||||||
{
|
|
||||||
QAction *act = pageAction(p_webAction);
|
|
||||||
if (act && !p_actions.contains(act)) {
|
|
||||||
QString text = act->text();
|
|
||||||
for (auto it : p_actions) {
|
|
||||||
if (it->text().endsWith(text)) {
|
|
||||||
act = it;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return act;
|
|
||||||
}
|
|
||||||
|
@ -33,10 +33,6 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
void hideUnusedActions(QMenu *p_menu);
|
void hideUnusedActions(QMenu *p_menu);
|
||||||
|
|
||||||
// pageAction() may not return exactly the action in use.
|
|
||||||
QAction *getPageAction(const QList<QAction *> &p_actions,
|
|
||||||
QWebEnginePage::WebAction p_webAction);
|
|
||||||
|
|
||||||
VFile *m_file;
|
VFile *m_file;
|
||||||
|
|
||||||
// Whether this view has hooked the Copy Image Url action.
|
// Whether this view has hooked the Copy Image Url action.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user