mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
Zim, Aard: Fix language recognition from three-letter codes
This commit is contained in:
parent
1640fb2ff4
commit
6d46fd1529
4
aard.cc
4
aard.cc
|
@ -1061,12 +1061,12 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
idxHeader.wordCount = wordCount;
|
||||
|
||||
if( langFrom.size() == 3)
|
||||
idxHeader.langFrom = LangCoder::code3toInt( langFrom.c_str() );
|
||||
idxHeader.langFrom = LangCoder::findIdForLanguageCode3( langFrom.c_str() );
|
||||
else if( langFrom.size() == 2 )
|
||||
idxHeader.langFrom = LangCoder::code2toInt( langFrom.c_str() );
|
||||
|
||||
if( langTo.size() == 3)
|
||||
idxHeader.langTo = LangCoder::code3toInt( langTo.c_str() );
|
||||
idxHeader.langTo = LangCoder::findIdForLanguageCode3( langTo.c_str() );
|
||||
else if( langTo.size() == 2 )
|
||||
idxHeader.langTo = LangCoder::code2toInt( langTo.c_str() );
|
||||
|
||||
|
|
12
langcoder.cc
12
langcoder.cc
|
@ -266,18 +266,6 @@ QString LangCoder::intToCode2( quint32 val )
|
|||
return QString::fromLatin1( code, 2 );
|
||||
}
|
||||
|
||||
quint32 LangCoder::code3toInt(const std::string& code3)
|
||||
{
|
||||
if (code3.length() < 2)
|
||||
return 0;
|
||||
|
||||
// this is temporary
|
||||
char code1 = tolower( code3.at(1) );
|
||||
char code0 = tolower( code3.at(0) );
|
||||
|
||||
return ( ((quint32)code1) << 8 ) + (quint32)code0;
|
||||
}
|
||||
|
||||
quint32 LangCoder::findIdForLanguage( gd::wstring const & lang )
|
||||
{
|
||||
gd::wstring langFolded = Folding::apply( lang );
|
||||
|
|
|
@ -35,8 +35,6 @@ public:
|
|||
|
||||
static QString intToCode2( quint32 );
|
||||
|
||||
static quint32 code3toInt(const std::string& code3);
|
||||
|
||||
/// Finds the id for the given language name, written in english. The search
|
||||
/// is case- and punctuation insensitive.
|
||||
static quint32 findIdForLanguage( gd::wstring const & );
|
||||
|
|
2
zim.cc
2
zim.cc
|
@ -1674,7 +1674,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
idxHeader.langFrom = LangCoder::code2toInt( lang.c_str() );
|
||||
else
|
||||
if( lang.size() == 3 )
|
||||
idxHeader.langFrom = LangCoder::code3toInt( lang.c_str() );
|
||||
idxHeader.langFrom = LangCoder::findIdForLanguageCode3( lang.c_str() );
|
||||
idxHeader.langTo = idxHeader.langFrom;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue