New user registration is currently disabled due to spam abuse / Регистрация новых пользователей в настоящее время приостановлена из-за злоупотреблений спаммерами

hebrew bug fix

Report bugs here

hebrew bug fix

Postby gnudles » Fri Mar 11, 2011 11:10 am

under the file bgl.cc
under class
BglArticleRequest
I added a method:
Code: Select all
void fixHebString(string & hebStr);

and implemented
Code: Select all
void BglArticleRequest::fixHebString(string & hebStr)
{
    wstring hebWStr=Utf8::decode(hebStr);
    for (unsigned int i=0; i<hebWStr.size();i++)
    {
        if (hebWStr[i]>=224 && hebWStr[i]<=250)
            hebWStr[i]+=1488-224;
    }
    hebStr=Utf8::encode(hebWStr);
}

under the method:
Code: Select all
void BglArticleRequest::run()

I moved the line:
Code: Select all
static Language::Id hebrew = LangCoder::code2toInt( "he" );

to the begining of the method (before the next loop) and in this loop:
Code: Select all
for( unsigned x = 0; x < chain.size(); ++x )

after the line:
Code: Select all
wstring headwordStripped =
      Folding::applySimpleCaseOnly( Utf8::decode( removePostfix( headword ) ) );

I added:
Code: Select all
displayedHeadword= displayedHeadword.size() ? displayedHeadword : headword;
    if (dict.idxHeader.langFrom == hebrew)
    {
        fixHebString(articleText);
        fixHebString(displayedHeadword);
    }

and few lines after, I changed the insertation into:
Code: Select all
mapToUse.insert( pair< wstring, pair< string, string > >(
      Folding::applySimpleCaseOnly( Utf8::decode( headword ) ),
      pair< string, string >( displayedHeadword,
        articleText ) ) );

in the same method I changed the code in the loops of "mainArticles" and "alternateArticles". instead of
Code: Select all
      result += "<h3>";
      result += postfixToSuperscript( i->second.first );
      result += "</h3>";

I did:
Code: Select all
      if (dict.idxHeader.langFrom == hebrew)
          result += "<h3 style=\"text-align:right;direction:rtl\">";
      else
          result += "<h3>";
      result += postfixToSuperscript( i->second.first );
      result += "</h3>";

in both of the loops... and this should fix most of the problems in hebrew :D
note that the rtl fix should be applied to all rtl languages, and not only hebrew
gnudles
 
Posts: 6
Joined: Tue Nov 10, 2009 11:22 am

Re: hebrew bug fix

Postby gnudles » Sat Mar 12, 2011 6:46 pm

to fix the problem with the last capital letter in the definition I added another method to the class:
Code: Select all
void fixHebArticle(string & hebArticle);

and implemented it like that:
Code: Select all
void BglArticleRequest::fixHebArticle(string & hebArticle)
{
    int nulls=hebArticle.size()-1;
    while ((hebArticle[nulls]<=32 && hebArticle[nulls]>=0) || (hebArticle[nulls]>=65 && hebArticle[nulls]<=90))//special chars and A-Z
    {
        nulls--;
    }
    hebArticle.erase (hebArticle.begin()+nulls+1, hebArticle.end());
}

the call to the method comes right after the call to
Code: Select all
fixHebString(articleText);

so we actually have this code:
Code: Select all
if (dict.idxHeader.langFrom == hebrew)
    {
        fixHebString(articleText);
        fixHebArticle(articleText);
        fixHebString(displayedHeadword);
    }

instead of
Code: Select all
if (dict.idxHeader.langFrom == hebrew)
    {
        fixHebString(articleText);
        fixHebString(displayedHeadword);
    }

in the last fix...............
gnudles
 
Posts: 6
Joined: Tue Nov 10, 2009 11:22 am

Re: hebrew bug fix

Postby ikm » Sat Mar 12, 2011 11:21 pm

Please make proper patches (use the "diff" tool to generate them).

Could you explain what exactly is going on here:
gnudles wrote: if (hebWStr[i]>=224 && hebWStr[i]<=250)
hebWStr[i]+=1488-224;
ikm
Автор GoldenDict
 
Posts: 1595
Joined: Wed Feb 04, 2009 10:40 am

Re: hebrew bug fix

Postby gnudles » Sun Mar 13, 2011 5:30 pm

the unicode characters between:
224 -250
are not hebrew characters.
they are the values of hebrew characters in other encodings like windows-1255 or ISO-8859-8.
the value of the first letter in hebrew is 1488 (the letter alef) and the value of the letter alef in windows-1255 or ISO-8859-8 is 224.
the last letter in hebrew is tav and is represented by 250 or 1504 in unicode.

btw,
I'll make a patch....
gnudles
 
Posts: 6
Joined: Tue Nov 10, 2009 11:22 am

Re: hebrew bug fix

Postby gnudles » Mon Mar 14, 2011 5:17 pm

there it is...
Attachments
bgl.diff.tar.bz2
(1.31 KiB) Downloaded 801 times
gnudles
 
Posts: 6
Joined: Tue Nov 10, 2009 11:22 am

Re: hebrew bug fix

Postby nit_ar » Wed May 25, 2011 5:22 am

Thanks for the fix.

Is this fix/patch will be formally applied to GD ?

I would like to try and test it, but I have never tried to build a binary by myself.
nit_ar
 
Posts: 17
Joined: Sat Apr 25, 2009 3:30 pm

Re: hebrew bug fix

Postby mehdishahini » Wed Jun 15, 2011 12:33 pm

How to use this patch in dictionary
mehdishahini
 
Posts: 8
Joined: Sat Jan 01, 2011 10:54 am

Re: hebrew bug fix

Postby nit_ar » Thu Jun 16, 2011 8:08 am

This patch has been already applied to the master trunk of the source code by Goldendict author.

You can either:
wait for a new binary release
or:
pull/download recent master tree of the source code + compilation tools and compile the binary by yourself.
nit_ar
 
Posts: 17
Joined: Sat Apr 25, 2009 3:30 pm

Re: hebrew bug fix

Postby Tvangeste » Thu Jun 16, 2011 11:31 am

nit_ar wrote:You can either:
wait for a new binary release
or:
pull/download recent master tree of the source code + compilation tools and compile the binary by yourself.

Or, alternatively, you could get an early-access version, compiled for Windows, from here:
https://github.com/goldendict/goldendic ... or-Windows
Tvangeste
 
Posts: 893
Joined: Thu Jun 02, 2011 11:42 am


Return to Bugs

Who is online

Users browsing this forum: No registered users and 35 guests