From 51ecf09c1db0c38b9c9ac9c1e3cbf827d7e8ed03 Mon Sep 17 00:00:00 2001 From: shenleban tongying Date: Wed, 19 Jun 2024 02:17:02 -0400 Subject: [PATCH] clean: rename code to code2 in langcoder --- src/langcoder.cc | 10 +++++----- src/langcoder.hh | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/langcoder.cc b/src/langcoder.cc index 2b6c04a5..bae7449b 100644 --- a/src/langcoder.cc +++ b/src/langcoder.cc @@ -219,7 +219,7 @@ QIcon LangCoder::icon( quint32 _code ) { if ( auto code = intToCode2( _code ); code2Exists( code ) ) { const GDLangCode & lc = LANG_CODE_MAP[ code ]; - return QIcon( ":/flags/" + QString( lc.code ) + ".png" ); + return QIcon( ":/flags/" + QString( lc.code2 ) + ".png" ); } return {}; @@ -243,7 +243,7 @@ quint32 LangCoder::findIdForLanguage( gd::wstring const & lang ) for ( auto const & lc : LANG_CODE_MAP ) { if ( strcasecmp( langFolded.c_str(), lc.lang.c_str() ) == 0 ) { - return code2toInt( lc.code.toStdString().c_str() ); + return code2toInt( lc.code2.toStdString().c_str() ); } } @@ -254,7 +254,7 @@ quint32 LangCoder::findIdForLanguageCode3( std::string const & code ) { for ( auto const & lc : LANG_CODE_MAP ) { if ( code == lc.code3 ) { - return code2toInt( lc.code ); + return code2toInt( lc.code2 ); } } @@ -273,7 +273,7 @@ quint32 LangCoder::guessId( const QString & lang ) if ( lstr.size() >= 3 ) { for ( auto const & lc : LANG_CODE_MAP ) { if ( lstr == ( lstr.size() == 3 ? QString::fromStdString( lc.code3 ) : QString::fromStdString( lc.lang ) ) ) { - return code2toInt( lc.code ); + return code2toInt( lc.code2 ); } } } @@ -311,7 +311,7 @@ bool LangCoder::isLanguageRTL( quint32 _code ) if ( auto code = intToCode2( _code ); code2Exists( code ) ) { GDLangCode lc = LANG_CODE_MAP[ code ]; if ( lc.isRTL < 0 ) { - lc.isRTL = static_cast< int >( QLocale( lc.code ).textDirection() == Qt::RightToLeft ); + lc.isRTL = static_cast< int >( QLocale( lc.code2 ).textDirection() == Qt::RightToLeft ); } return lc.isRTL != 0; } diff --git a/src/langcoder.hh b/src/langcoder.hh index 56084034..8ba14361 100644 --- a/src/langcoder.hh +++ b/src/langcoder.hh @@ -7,7 +7,7 @@ struct GDLangCode { - QString code; // ISO 639-1 + QString code2; // ISO 639-1 -> always 2 letters thus code2 std::string code3; // ISO 639-2B ( http://www.loc.gov/standards/iso639-2/ ) int isRTL; // Right-to-left writing; 0 - no, 1 - yes, -1 - let Qt define std::string lang; // Language name in English