optimize: add qtwebengine zh_CN support

This commit is contained in:
yifang 2022-03-06 17:05:43 +08:00
parent edf8c8d4f3
commit df7fb33be6
5 changed files with 493 additions and 23 deletions

View file

@ -52,7 +52,11 @@ function Main() {
Copy-Item $sdkDll $archiveName\ Copy-Item $sdkDll $archiveName\
Copy-Item winlibs\lib\msvc\*.dll $archiveName\ Copy-Item winlibs\lib\msvc\*.dll $archiveName\
Copy-Item locale\*.qm $archiveName\locale\ Copy-Item locale\*.qm $archiveName\locale\
# Copy-Item qtsingleapplication\lib\*.dll $archiveName\ Write-Host "copy qwebengine zh_CN translation"
Copy-Item thirdparty\qwebengine_ts\*.qm $archiveName\locale\
$webengineqm="{0}\translations\qtwebengine_*.qm" -f $env:Qt5_Dir
Write-Host "copy qtwebengine qm from $($webengineqm)"
Copy-Item $webengineqm $archiveName\locale\
Write-Host "compress zip..." Write-Host "compress zip..."
# 打包zip # 打包zip
Compress-Archive -Path $archiveName -DestinationPath $archiveName'.zip' Compress-Archive -Path $archiveName -DestinationPath $archiveName'.zip'

36
main.cc
View file

@ -1,4 +1,4 @@
/* This file is (c) 2008-2012 Konstantin Isakov <ikm@goldendict.org> /* This file is (c) 2008-2012 Konstantin Isakov <ikm@goldendict.org>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */ * Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#include <stdio.h> #include <stdio.h>
@ -385,31 +385,23 @@ int main( int argc, char ** argv )
if( !cfg.preferences.interfaceLanguage.isEmpty() && localeName != cfg.preferences.interfaceLanguage ) if( !cfg.preferences.interfaceLanguage.isEmpty() && localeName != cfg.preferences.interfaceLanguage )
{ {
localeName = cfg.preferences.interfaceLanguage; localeName = cfg.preferences.interfaceLanguage;
QLocale locale( localeName );
QLocale::setDefault( locale );
if( !qtTranslator.load( "qt_" + localeName, Config::getLocDir() ) )
{
qtTranslator.load( "qt_" + localeName, QLibraryInfo::location( QLibraryInfo::TranslationsPath ) );
app.installTranslator( &qtTranslator );
}
translator.load( Config::getLocDir() + "/" + localeName );
app.installTranslator( &translator );
} }
else
QLocale locale( localeName );
QLocale::setDefault( locale );
if( !qtTranslator.load( "qt_" + localeName, Config::getLocDir() ) )
{ {
QString localeName = QLocale::system().name(); qtTranslator.load( "qt_" + localeName, QLibraryInfo::location( QLibraryInfo::TranslationsPath ) );
app.installTranslator( &qtTranslator );
}
translator.load( Config::getLocDir() + "/" + localeName );
app.installTranslator( &translator );
if( !qtTranslator.load( "qt_" + localeName, Config::getLocDir() ) ) QTranslator webengineTs;
{ if( webengineTs.load( "qtwebengine_" + localeName, Config::getLocDir() ) )
qtTranslator.load( "qt_" + localeName, QLibraryInfo::location( QLibraryInfo::TranslationsPath ) ); {
app.installTranslator( &webengineTs );
app.installTranslator( &qtTranslator );
}
translator.load( Config::getLocDir() + "/" + localeName );
app.installTranslator( &translator );
} }
// Prevent app from quitting spontaneously when it works with scan popup // Prevent app from quitting spontaneously when it works with scan popup

7
thirdparty/qwebengine_ts/README.md vendored Normal file
View file

@ -0,0 +1,7 @@
qt webengine lacks the translation of chinese .
this file is a compilation of this qwebengine_zh_CN.ts
(https://codereview.qt-project.org/c/qt/qttranslations/+/399180) .
provided as a temporarily way to support zh_CN.

Binary file not shown.

View file

@ -0,0 +1,467 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="zh_CN">
<context>
<name>DownloadInterruptReason</name>
<message>
<source>Unknown reason or not interrupted</source>
<translation></translation>
</message>
<message>
<source>General file operation failure</source>
<translation></translation>
</message>
<message>
<source>The file cannot be written locally, due to access restrictions</source>
<translation>访</translation>
</message>
<message>
<source>Insufficient space on the target drive</source>
<translation></translation>
</message>
<message>
<source>The directory or file name is too long</source>
<translation></translation>
</message>
<message>
<source>The file size exceeds the file system limitation</source>
<translation></translation>
</message>
<message>
<source>The file is infected with a virus</source>
<translation></translation>
</message>
<message>
<source>Temporary problem (for example file in use, or too many open files)</source>
<translation>使</translation>
</message>
<message>
<source>The file was blocked due to local policy</source>
<translation></translation>
</message>
<message>
<source>Checking the safety of the download failed due to unexpected reasons</source>
<translation></translation>
</message>
<message>
<source>File seek past the end of a file (resuming previously interrupted download)</source>
<translation></translation>
</message>
<message>
<source>The partial file did not match the expected hash</source>
<translation></translation>
</message>
<message>
<source>General network failure</source>
<translation></translation>
</message>
<message>
<source>The network operation has timed out</source>
<translation></translation>
</message>
<message>
<source>The network connection has been terminated</source>
<translation></translation>
</message>
<message>
<source>The server has gone down</source>
<translation></translation>
</message>
<message>
<source>The network request was invalid (for example, the URL or scheme is invalid)</source>
<translation>URL或scheme无效</translation>
</message>
<message>
<source>General server failure</source>
<translation></translation>
</message>
<message>
<source>The server does not have the requested data</source>
<translation></translation>
</message>
<message>
<source>The server did not authorize access to the resource</source>
<translation>访</translation>
</message>
<message>
<source>A problem with the server certificate occurred</source>
<translation></translation>
</message>
<message>
<source>Access forbidden by the server</source>
<translation>访</translation>
</message>
<message>
<source>Unexpected server response</source>
<translation></translation>
</message>
<message>
<source>Download canceled by the user</source>
<translation></translation>
</message>
</context>
<context>
<name>QQuickPdfDocument</name>
<message>
<source>no error</source>
<translation></translation>
</message>
<message>
<source>data not yet available</source>
<translation></translation>
</message>
<message>
<source>file not found</source>
<translation></translation>
</message>
<message>
<source>invalid file format</source>
<translation></translation>
</message>
<message>
<source>incorrect password</source>
<translation></translation>
</message>
<message>
<source>unsupported security scheme</source>
<translation></translation>
</message>
<message>
<source>unknown error</source>
<translation></translation>
</message>
</context>
<context>
<name>QQuickWebEngineView</name>
<message>
<source>Stop</source>
<translation></translation>
</message>
<message>
<source>Reload and Bypass Cache</source>
<translation></translation>
</message>
<message>
<source>Open link in this window</source>
<translation></translation>
</message>
<message>
<source>Toggle Play/Pause</source>
<translation>/</translation>
</message>
<message>
<source>Toggle Mute</source>
<translation></translation>
</message>
<message>
<source>Close Page</source>
<translation></translation>
</message>
<message>
<source>Unselect</source>
<translation></translation>
</message>
<message>
<source>&amp;Bold</source>
<translation>&amp;B</translation>
</message>
<message>
<source>&amp;Italic</source>
<translation>&amp;I</translation>
</message>
<message>
<source>&amp;Underline</source>
<translation>线&amp;U</translation>
</message>
<message>
<source>&amp;Strikethrough</source>
<translation>线(&amp;S)</translation>
</message>
<message>
<source>Align &amp;Left</source>
<translation>&amp;L</translation>
</message>
<message>
<source>Align &amp;Center</source>
<translation>&amp;C</translation>
</message>
<message>
<source>Align &amp;Right</source>
<translation>&amp;R</translation>
</message>
<message>
<source>Align &amp;Justified</source>
<translation>&amp;J</translation>
</message>
<message>
<source>&amp;Indent</source>
<translation>&amp;I</translation>
</message>
<message>
<source>&amp;Outdent</source>
<translation>(&amp;O)</translation>
</message>
<message>
<source>Insert &amp;Ordered List</source>
<translation>&amp;O</translation>
</message>
<message>
<source>Insert &amp;Unordered List</source>
<translation>&amp;U</translation>
</message>
</context>
<context>
<name>QWebEnginePage</name>
<message>
<source>Stop</source>
<translation></translation>
</message>
<message>
<source>Reload and Bypass Cache</source>
<translation></translation>
</message>
<message>
<source>Toggle Play/Pause</source>
<translation>/</translation>
</message>
<message>
<source>Toggle Mute</source>
<translation></translation>
</message>
<message>
<source>Close Page</source>
<translation></translation>
</message>
<message>
<source>Unselect</source>
<translation></translation>
</message>
<message>
<source>Are you sure you want to leave this page? Changes that you made may not be saved.</source>
<translation> </translation>
</message>
<message>
<source>Open link in this window</source>
<translation></translation>
</message>
<message>
<source>Open link in new background tab</source>
<translation></translation>
</message>
<message>
<source>&amp;Bold</source>
<translation>&amp;B</translation>
</message>
<message>
<source>&amp;Italic</source>
<translation>&amp;I</translation>
</message>
<message>
<source>&amp;Underline</source>
<translation>线&amp;U</translation>
</message>
<message>
<source>&amp;Strikethrough</source>
<translation>线&amp;S</translation>
</message>
<message>
<source>Align &amp;Left</source>
<translation>&amp;L</translation>
</message>
<message>
<source>Align &amp;Center</source>
<translation>&amp;C</translation>
</message>
<message>
<source>Align &amp;Right</source>
<translation>&amp;R</translation>
</message>
<message>
<source>Align &amp;Justified</source>
<translation>&amp;J</translation>
</message>
<message>
<source>&amp;Indent</source>
<translation>&amp;I</translation>
</message>
<message>
<source>&amp;Outdent</source>
<translation>(&amp;O)</translation>
</message>
<message>
<source>Insert &amp;Ordered List</source>
<translation>&amp;O</translation>
</message>
<message>
<source>Insert &amp;Unordered List</source>
<translation>&amp;U</translation>
</message>
<message>
<source>Select folder to upload</source>
<translation></translation>
</message>
</context>
<context>
<name>QtWebEnginePlugin</name>
<message>
<source>Cannot create separate instance of WebEngineNewViewRequest</source>
<translation> WebEngineNewViewRequest </translation>
</message>
<message>
<source>Cannot create separate instance of %1</source>
<translation> %1 </translation>
</message>
</context>
<context>
<name>QtWebEngineTestSupportPlugin</name>
<message>
<source>Cannot create a separate instance of WebEngineErrorPage</source>
<translation> WebEngineErrorPage </translation>
</message>
<message>
<source>Cannot create a separate instance of WebEngineTestEvent</source>
<translation> WebEngineTestEvent </translation>
</message>
</context>
<context>
<name>RenderViewContextMenuQt</name>
<message>
<source>Back</source>
<translation>退</translation>
</message>
<message>
<source>Forward</source>
<translation></translation>
</message>
<message>
<source>Reload</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 new window</source>
<translation></translation>
</message>
<message>
<source>Open link in new tab</source>
<translation></translation>
</message>
<message>
<source>Copy link address</source>
<translation></translation>
</message>
<message>
<source>Save link</source>
<translation></translation>
</message>
<message>
<source>Copy image</source>
<translation></translation>
</message>
<message>
<source>Copy image address</source>
<translation></translation>
</message>
<message>
<source>Save image</source>
<translation></translation>
</message>
<message>
<source>Copy media address</source>
<translation></translation>
</message>
<message>
<source>Show controls</source>
<translation></translation>
</message>
<message>
<source>Loop</source>
<translation></translation>
</message>
<message>
<source>Save media</source>
<translation></translation>
</message>
<message>
<source>Inspect</source>
<translation></translation>
</message>
<message>
<source>Exit full screen</source>
<translation>退</translation>
</message>
<message>
<source>Save page</source>
<translation></translation>
</message>
<message>
<source>View page source</source>
<translation></translation>
</message>
</context>
<context>
<name>UIDelegatesManager</name>
<message>
<source>Javascript Alert - %1</source>
<translation>Javascript- - %1</translation>
</message>
<message>
<source>Javascript Confirm - %1</source>
<translation>Javascript- - %1</translation>
</message>
<message>
<source>Javascript Prompt - %1</source>
<translation>Javascript- - %1</translation>
</message>
<message>
<source>Are you sure you want to leave this page?</source>
<translation></translation>
</message>
<message>
<source>Changes that you made may not be saved.</source>
<translation></translation>
</message>
<message>
<source>Connect to proxy &quot;%1&quot; using:</source>
<translation>使%1</translation>
</message>
<message>
<source>Enter username and password for &quot;%1&quot; at %2://%3</source>
<translation> %2://%3 输入“%1”的用户名和密码</translation>
</message>
</context>
<context>
<name>WebContentsAdapter</name>
<message>
<source>HTTP-POST data can only be sent over HTTP(S) protocol</source>
<translation>HTTP-POST HTTP(S) </translation>
</message>
</context>
</TS>