Merge branch 'staged' into dev

This commit is contained in:
YiFang Xiao 2023-08-31 08:03:53 +08:00
commit 44fd38a4b3
6 changed files with 64 additions and 53 deletions

View file

@ -373,7 +373,7 @@ between classic and school orthography in cyrillic)</source>
<name>CustomTranslit</name>
<message>
<source>custom transliteration</source>
<translation>карыстацкая транслітарацыя</translation>
<translation>адвольная транслітарацыя</translation>
</message>
</context>
<context>
@ -644,11 +644,11 @@ between classic and school orthography in cyrillic)</source>
</message>
<message>
<source>Full-text search enabled</source>
<translation>Поўнатэкставы пошук уключаны</translation>
<translation>Паўнатэкставы пошук уключаны</translation>
</message>
<message>
<source>Full-text search disabled</source>
<translation>Поўнатэкставы пошук адключаны</translation>
<translation>Паўнатэкставы пошук адключаны</translation>
</message>
<message>
<source>Edit the dictionary via command:
@ -657,11 +657,11 @@ between classic and school orthography in cyrillic)</source>
</message>
<message>
<source>Index filename:</source>
<translation>Імя індэкснага файла:</translation>
<translation>Назва індэкснага файла:</translation>
</message>
<message>
<source>Open index folder</source>
<translation>Адкрыць індэксную тэчку</translation>
<translation>Адкрыць індэксны каталог</translation>
</message>
</context>
<context>
@ -837,7 +837,7 @@ between classic and school orthography in cyrillic)</source>
</message>
<message>
<source>Default</source>
<translation>Па змаўчанні</translation>
<translation>Прадвызначана</translation>
</message>
<message>
<source>Articles found: </source>
@ -1064,15 +1064,15 @@ between classic and school orthography in cyrillic)</source>
</message>
<message>
<source>Create folder-based groups.</source>
<translation>Стварэнне груп на аснове тэчак.</translation>
<translation>Стварыыць групы на аснове каталогаў.</translation>
</message>
<message>
<source>Group by Folders</source>
<translation>Група па тэчках</translation>
<translation>Групаванне па каталогах</translation>
</message>
<message>
<source>Group by Metadata</source>
<translation>Групаванне па метададзеных</translation>
<translation>Групаванне па метаданых</translation>
</message>
<message>
<source>Drag&amp;drop dictionaries to and from the groups, move them inside the groups, reorder the groups using your mouse.</source>
@ -1172,7 +1172,7 @@ between classic and school orthography in cyrillic)</source>
<name>Initializing</name>
<message>
<source>Indexing: </source>
<translation>Індэксацыя: </translation>
<translation>Індэксаванне: </translation>
</message>
<message>
<source>Dictionary Name</source>
@ -1188,7 +1188,7 @@ between classic and school orthography in cyrillic)</source>
</message>
<message>
<source>Indexing...</source>
<translation>Ідзе індэксацыя...</translation>
<translation>Індэксаванне...</translation>
</message>
<message>
<source>Loading...</source>
@ -2455,7 +2455,7 @@ between classic and school orthography in cyrillic)</source>
</message>
<message>
<source>WARNING: %1</source>
<translation>ПАПЯРЭДЖАННЕ: %1</translation>
<translation>УВАГА: %1</translation>
</message>
<message>
<source>String to search in dictionaries. The wildcards &apos;*&apos;, &apos;?&apos; and sets of symbols &apos;[...]&apos; are allowed.
@ -3279,11 +3279,11 @@ however, the article from the topmost dictionary is shown.</source>
</message>
<message>
<source>Delay time</source>
<translation>Час затрымкі</translation>
<translation>Час затрымлівання</translation>
</message>
<message>
<source> ms</source>
<translation> ms</translation>
<translation> мс</translation>
</message>
<message>
<source>System proxy</source>
@ -3557,15 +3557,15 @@ from Stardict, Babylon and GLS dictionaries</source>
</message>
<message>
<source>Restart needed</source>
<translation>Неабходны перазапуск</translation>
<translation>Патрабуецца перазапуск</translation>
</message>
<message>
<source>Restart to apply the interface style change.</source>
<translation>Перазапусціце, каб прымяніць змяненне стылю інтэрфейсу.</translation>
<translation>Перазапусціце, каб ужыць змену стылю інтэрфейсу.</translation>
</message>
<message>
<source>Positional information is required to use Xapian&apos;s phrase searching and NEAR operator, but the database size will be much bigger. Applies only to new incoming dictionaries.</source>
<translation>Для выкарыстання фразавага пошуку Xapian і аператара NEAR патрабуецца пазіцыйная інфармацыя, але памер базы дадзеных будзе значна большым. Прымяняецца толькі да новых уваходных слоўнікаў.</translation>
<translation>Для выкарыстання фразавага пошуку Xapian і аператара NEAR патрабуецца пазіцыйная інфармацыя, але памер базы даных будзе значна большым. Ужыааецца толькі да новых уваходных слоўнікаў.</translation>
</message>
<message>
<source>Enable index with positional information</source>
@ -3589,11 +3589,11 @@ from Stardict, Babylon and GLS dictionaries</source>
</message>
<message>
<source>Appearance</source>
<translation>Знешні выгляд</translation>
<translation>Выгляд</translation>
</message>
<message>
<source>These fonts will be applied when the fonts specified by a dictionary are not found.</source>
<translation>Гэтыя шрыфты будуць прымяняцца, калі шрыфты, указаныя ў слоўніку, не знойдзены.</translation>
<translation>Гэтыя шрыфты будуць ужывацца, калі не ўдасца знайсці шрыфты, пазначаныя ў слоўніку.</translation>
</message>
<message>
<source>Fallback Fonts</source>
@ -3605,15 +3605,15 @@ from Stardict, Babylon and GLS dictionaries</source>
</message>
<message>
<source>Create fulltext index with parallel threads </source>
<translation>Стварыць паўнатэкставы індэкс з паралельнымі патокамі </translation>
<translation>Стварыць паўнатэкставы індэкс з паралельнымі плынямі </translation>
</message>
<message>
<source>When using clipboard, strip everything after newline</source>
<translation>Пры выкарыстанні буфера абмену выдаляйце ўсё пасля новага радка</translation>
<translation>Пры выкарыстанні буфера абмену выдаляць усё пасля новага радка</translation>
</message>
<message>
<source>Remove invalid index on exit</source>
<translation>Выдаліць няправільны індэкс пры выхадзе</translation>
<translation>Выдаляць хібны індэкс пры выхадзе</translation>
</message>
<message>
<source>Miscellaneous</source>
@ -3621,11 +3621,11 @@ from Stardict, Babylon and GLS dictionaries</source>
</message>
<message>
<source>When debugging with dictionary css/js, disable certain cache to make it easier.</source>
<translation>Пры адладцы са слоўнікам css/js адключыце пэўны кэш, каб зрабіць гэта прасцей.</translation>
<translation>Пры адладжванні css/js слоўніка з адключаць кэш, каб зрабіць гэта прасцей.</translation>
</message>
<message>
<source>Dictionary debug</source>
<translation>Адладка слоўніка</translation>
<translation>Адладжванне слоўніка</translation>
</message>
</context>
<context>
@ -3761,7 +3761,7 @@ from Stardict, Babylon and GLS dictionaries</source>
</message>
<message>
<source>Print version and diagnosis info.</source>
<translation>Версія для друку і інфармацыя пра дыягназ.</translation>
<translation>Вывад версіі і звестак дыягностыкі.</translation>
</message>
</context>
<context>
@ -3865,7 +3865,7 @@ could be resized or managed in other ways.</source>
</message>
<message>
<source>WARNING: %1</source>
<translation>ПАПЯРЭДЖАННЕ: %1</translation>
<translation>УВАГА: %1</translation>
</message>
</context>
<context>
@ -4014,11 +4014,11 @@ based on English phonology</source>
</message>
<message>
<source>Custom transliteration</source>
<translation>Карыстальніцкая транслітарацыя</translation>
<translation>Адвольная транслітарацыя</translation>
</message>
<message>
<source>This only applied in search phrase, with each line represent a transliteration,semicolon seperated. For example, ae;æ,users can input ae to represent æ in the target word.</source>
<translation>Гэта прымяняецца толькі ў пошукавай фразе, дзе кожны радок уяўляе сабой транслітарацыю, падзеленую кропкай з коскай. Напрыклад, ae;æ, карыстальнікі могуць увесці ae, каб прадставіць æ у мэтавым слове.</translation>
<translation>Гэта ўжываецца толькі ў фразе пошуку, дзе кожны радок уяўляе сабой транслітарацыю, падзеленую кропкай з коскай. Напрыклад, ae;æ, карыстальнікі могуць увесці ae, каб паказаць æ у мэтавым слове.</translation>
</message>
<message>
<source>ae;æ #this is an example</source>

View file

@ -387,9 +387,10 @@ sptr< Dictionary::DataRequest > ArticleMaker::makeDefinitionFor( QString const &
unmutedDicts.reserve( activeDicts.size() );
for ( unsigned x = 0; x < activeDicts.size(); ++x )
for ( unsigned x = 0; x < activeDicts.size(); ++x ) {
if ( !mutedDicts.contains( QString::fromStdString( activeDicts[ x ]->getId() ) ) )
unmutedDicts.push_back( activeDicts[ x ] );
}
return std::make_shared< ArticleRequest >(
word,
@ -436,7 +437,7 @@ sptr< Dictionary::DataRequest > ArticleMaker::makeEmptyPage() const
sptr< Dictionary::DataRequest > ArticleMaker::makePicturePage( string const & url ) const
{
string result = makeHtmlHeader( tr( "(picture)" ), QString(), true )
+ "<a href=\"javascript: if(history.length>2) history.go(-1)\">" + "<img src=\"" + url + "\" /></a>"
+ R"lit(<a href="javascript: if(history.length>2) history.go(-1)">)lit" + R"(<img src=")" + url + R"(" /></a>)"
+ "</body></html>";
sptr< Dictionary::DataRequestInstant > r = std::make_shared< Dictionary::DataRequestInstant >( true );
@ -489,9 +490,8 @@ ArticleRequest::ArticleRequest( QString const & word,
emit GlobalBroadcaster::instance()->dictionaryClear( ActiveDictIds{ group.id, word } );
// Accumulate main forms
for ( unsigned x = 0; x < activeDicts.size(); ++x ) {
sptr< Dictionary::WordSearchRequest > s =
activeDicts[ x ]->findHeadwordsForSynonym( gd::removeTrailingZero( word ) );
for ( const auto & activeDict : activeDicts ) {
auto const s = activeDict->findHeadwordsForSynonym( gd::removeTrailingZero( word ) );
connect( s.get(), &Dictionary::Request::finished, this, &ArticleRequest::altSearchFinished, Qt::QueuedConnection );
@ -507,7 +507,7 @@ void ArticleRequest::altSearchFinished()
return;
// Check every request for finishing
for ( list< sptr< Dictionary::WordSearchRequest > >::iterator i = altSearches.begin(); i != altSearches.end(); ) {
for ( auto i = altSearches.begin(); i != altSearches.end(); ) {
if ( ( *i )->isFinished() ) {
// This one's finished
for ( size_t count = ( *i )->matchesCount(), x = 0; x < count; ++x )
@ -531,8 +531,8 @@ void ArticleRequest::altSearchFinished()
vector< wstring > altsVector( alts.begin(), alts.end() );
#ifdef QT_DEBUG
for ( unsigned x = 0; x < altsVector.size(); ++x ) {
qDebug() << "Alt:" << QString::fromStdU32String( altsVector[ x ] );
for ( const auto & x : altsVector ) {
qDebug() << "Alt:" << QString::fromStdU32String( x );
}
#endif
@ -541,12 +541,12 @@ void ArticleRequest::altSearchFinished()
if ( activeDicts.size() <= 1 )
articleSizeLimit = -1; // Don't collapse article if only one dictionary presented
for ( unsigned x = 0; x < activeDicts.size(); ++x ) {
for ( const auto & activeDict : activeDicts ) {
try {
sptr< Dictionary::DataRequest > r = activeDicts[ x ]->getArticle(
sptr< Dictionary::DataRequest > r = activeDict->getArticle(
wordStd,
altsVector,
gd::removeTrailingZero( contexts.value( QString::fromStdString( activeDicts[ x ]->getId() ) ) ),
gd::removeTrailingZero( contexts.value( QString::fromStdString( activeDict->getId() ) ) ),
ignoreDiacritics );
connect( r.get(), &Dictionary::Request::finished, this, &ArticleRequest::bodyFinished, Qt::QueuedConnection );
@ -554,7 +554,7 @@ void ArticleRequest::altSearchFinished()
bodyRequests.push_back( r );
}
catch ( std::exception & e ) {
gdWarning( "getArticle request error (%s) in \"%s\"\n", e.what(), activeDicts[ x ]->getName().c_str() );
gdWarning( "getArticle request error (%s) in \"%s\"\n", e.what(), activeDict->getName().c_str() );
}
}
@ -777,14 +777,12 @@ void ArticleRequest::bodyFinished()
}
else {
footer += R"(<div class="empty-space"></div>)";
footer += "</body></html>";
}
appendString( footer );
}
if ( stemmedWordFinder.get() ) {
update();
qDebug() << "send dicts(stemmed):" << hittedWord;

View file

@ -3,13 +3,23 @@
#include <QPalette>
#include <QStyle>
#include <QMessageBox>
#include <string>
#ifdef _MSC_VER
#include <stub_msvc.h>
#endif
using std::string;
namespace Utils {
//some str has \0 in the middle of the string. return the string before the \0
std::string c_string( const QString & str )
{
return std::string( str.toUtf8().constData() );
}
bool endsWithIgnoreCase( const string & str1, string str2 )
{
return ( str1.size() >= (unsigned)str2.size() )
&& ( strcasecmp( str1.c_str() + ( str1.size() - str2.size() ), str2.data() ) == 0 );
}
} // namespace Utils
QString Utils::Path::combine( const QString & path1, const QString & path2 )

View file

@ -13,6 +13,8 @@
#include <QUrlQuery>
#include <QWidget>
#include "filetype.hh"
#include <string>
using std::string;
namespace Utils {
inline bool isCJKChar( ushort ch )
@ -37,7 +39,7 @@ inline QString rstrip( const QString & str )
}
std::string c_string( const QString & str );
bool endsWithIgnoreCase( const string & str1, string str2 );
/**
* remove punctuation , space, symbol
*

View file

@ -303,16 +303,17 @@ void EpwingDictionary::loadArticle(
articleHeadword = string( headword.toUtf8().data() );
articleText = string( text.toUtf8().data() );
string prefix( "<div class=\"epwing_text\">" );
const string prefix( "<div class=\"epwing_text\">" );
articleText = prefix + articleText + "</div>";
}
string Epwing::EpwingDictionary::epwing_previous_button( const int & articlePage, const int & articleOffset )
{
QString previousButton = QString( "p%1At%2" ).arg( articlePage ).arg( articleOffset );
string previousLink = R"(<p><a class="epwing_previous_page" href="gdlookup://localhost/)"
+ previousButton.toStdString() + "\">" + tr( "Previous Page" ).toStdString() + "</a></p>";
const QString previousButton = QString( "p%1At%2" ).arg( articlePage ).arg( articleOffset );
string previousLink = R"(<p><a class="epwing_previous_page" href="gdlookup://localhost/)"
+ previousButton.toStdString() + "?dictionaries=" + getId() + "\">" + tr( "Previous Page" ).toStdString()
+ "</a></p>";
return previousLink;
}
@ -348,8 +349,8 @@ void EpwingDictionary::loadArticleNextPage( string & articleHeadword,
string Epwing::EpwingDictionary::epwing_next_button( const int & articlePage, const int & articleOffset )
{
QString refLink = QString( "r%1At%2" ).arg( articlePage ).arg( articleOffset );
string nextLink = R"(<p><a class="epwing_next_page" href="gdlookup://localhost/)" + refLink.toStdString() + "\">"
+ tr( "Next Page" ).toStdString() + "</a></p>";
string nextLink = R"(<p><a class="epwing_next_page" href="gdlookup://localhost/)" + refLink.toStdString()
+ "?dictionaries=" + getId() + "\">" + tr( "Next Page" ).toStdString() + "</a></p>";
return nextLink;
}
@ -1144,8 +1145,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
for ( const auto & fileName : fileNames ) {
// Skip files other than "catalogs" to speed up the scanning
if ( fileName.size() < (unsigned)catName.size()
|| strcasecmp( fileName.c_str() + ( fileName.size() - catName.size() ), catName.data() ) != 0 )
if ( !Utils::endsWithIgnoreCase( fileName, catName.data() ) )
continue;
int ndir = fileName.size() - catName.size();

View file

@ -1,5 +1,5 @@
#include <string>
#ifdef _MSC_VER
#if !defined(strcasecmp)
# define strcasecmp _strcmpi
#endif
@ -11,4 +11,5 @@
#define _SSIZE_T
#define ssize_t long
#endif
#endif