Skip to content

Commit

Permalink
optimize: add qtwebengine zh_CN support
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyifang committed Mar 6, 2022
1 parent edf8c8d commit df7fb33
Show file tree
Hide file tree
Showing 5 changed files with 493 additions and 23 deletions.
6 changes: 5 additions & 1 deletion .github/scripts/windows-publish.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ function Main() {
Copy-Item $sdkDll $archiveName\
Copy-Item winlibs\lib\msvc\*.dll $archiveName\
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..."
# 打包zip
Compress-Archive -Path $archiveName -DestinationPath $archiveName'.zip'
Expand Down
36 changes: 14 additions & 22 deletions main.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* This file is (c) 2008-2012 Konstantin Isakov <[email protected]>
/* This file is (c) 2008-2012 Konstantin Isakov <[email protected]>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */

#include <stdio.h>
Expand Down Expand Up @@ -385,31 +385,23 @@ int main( int argc, char ** argv )
if( !cfg.preferences.interfaceLanguage.isEmpty() && 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
{
QString localeName = QLocale::system().name();


if( !qtTranslator.load( "qt_" + localeName, Config::getLocDir() ) )
{
qtTranslator.load( "qt_" + localeName, QLibraryInfo::location( QLibraryInfo::TranslationsPath ) );
QLocale locale( localeName );
QLocale::setDefault( locale );
if( !qtTranslator.load( "qt_" + localeName, Config::getLocDir() ) )
{
qtTranslator.load( "qt_" + localeName, QLibraryInfo::location( QLibraryInfo::TranslationsPath ) );
app.installTranslator( &qtTranslator );
}

app.installTranslator( &qtTranslator );
}
translator.load( Config::getLocDir() + "/" + localeName );
app.installTranslator( &translator );

translator.load( Config::getLocDir() + "/" + localeName );
app.installTranslator( &translator );
QTranslator webengineTs;
if( webengineTs.load( "qtwebengine_" + localeName, Config::getLocDir() ) )
{
app.installTranslator( &webengineTs );
}

// Prevent app from quitting spontaneously when it works with scan popup
Expand Down
7 changes: 7 additions & 0 deletions thirdparty/qwebengine_ts/README.md
Original file line number Diff line number Diff line change
@@ -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 added thirdparty/qwebengine_ts/qtwebengine_zh_CN.qm
Binary file not shown.
Loading

0 comments on commit df7fb33

Please sign in to comment.