fix: properly load qt and webengine translations, delete GD's custom ones

This commit is contained in:
shenleban tongying 2024-11-06 16:51:53 -05:00
parent 70d21d7eca
commit a61bcb1629
6 changed files with 23 additions and 20554 deletions

View file

@ -1,3 +0,0 @@
qtwebengine_zh_CN.ts is used to fixed some right context menu on webengine.
The previous qt_* rename to qt_extra_* to distinguish between the locale language.These qt_extra*.ts are also used to fix GUI translation issues as qt has not provided an update version about these language.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,467 +0,0 @@
<?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>

View file

@ -564,18 +564,35 @@ int main( int argc, char ** argv )
QLocale::setDefault( locale ); QLocale::setDefault( locale );
QApplication::setLayoutDirection( locale.textDirection() ); QApplication::setLayoutDirection( locale.textDirection() );
if ( !qtTranslator.load( "qt_extra_" + localeName, Config::getLocDir() ) ) { // Load Qt translators
qtTranslator.load( "qt_extra_" + localeName, QLibraryInfo::location( QLibraryInfo::TranslationsPath ) ); // For Windows, windeployqt will combine multiple qt modules translations into `qt_*`
// Thus, after deployment, loading `qtwebengine_*` is guaranteed to fail on Windows.
if ( qtTranslator.load( locale, "qt", "_", QLibraryInfo::path( QLibraryInfo::TranslationsPath ) ) ) {
app.installTranslator( &qtTranslator ); app.installTranslator( &qtTranslator );
qDebug() << "qt translator loaded: " << qtTranslator.filePath();
}
else {
qDebug() << "qt translator didn't load anything.";
} }
translator.load( Config::getLocDir() + "/" + localeName );
app.installTranslator( &translator );
QTranslator webengineTs; QTranslator webengineTs;
if ( webengineTs.load( "qtwebengine_" + localeName, Config::getLocDir() ) ) { if ( webengineTs.load( locale, "qtwebengine", "_", QLibraryInfo::path( QLibraryInfo::TranslationsPath ) ) ) {
app.installTranslator( &webengineTs ); app.installTranslator( &webengineTs );
qDebug() << "qt webengine translator loaded: " << webengineTs.filePath();
} }
else {
qDebug() << "qt webengine translator may or may not be loaded.";
}
// Load GD's translations, note GD has local names beyond what's supported by QLocal
if ( translator.load( localeName, Config::getLocDir() ) ) {
app.installTranslator( &translator );
qDebug() << "gd translator loaded: " << translator.filePath();
}
else {
qDebug() << "gd translator didn't load anything";
}
// Prevent app from quitting spontaneously when it works with popup // Prevent app from quitting spontaneously when it works with popup
// and with the main window closed. // and with the main window closed.