From b29cd7d0e6245e308d63db2fa0d7d5b9dd3563eb Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Thu, 20 Dec 2012 13:41:57 +0100 Subject: [PATCH] * Make EchonestControl more translatable. --- .../dynamic/echonest/EchonestControl.cpp | 71 +++++++++++++------ 1 file changed, 50 insertions(+), 21 deletions(-) diff --git a/src/libtomahawk/playlist/dynamic/echonest/EchonestControl.cpp b/src/libtomahawk/playlist/dynamic/echonest/EchonestControl.cpp index db6921394..2320c4dfe 100644 --- a/src/libtomahawk/playlist/dynamic/echonest/EchonestControl.cpp +++ b/src/libtomahawk/playlist/dynamic/echonest/EchonestControl.cpp @@ -740,15 +740,20 @@ Tomahawk::EchonestControl::calculateSummary() { // turns the current control into an english phrase suitable for embedding into a sentence summary QString summary; - if( selectedType() == "Artist" ) { + if ( selectedType() == "Artist" ) + { // magic char is used by EchonestGenerator to split the prefix from the artist name - if( static_cast< Echonest::DynamicPlaylist::ArtistTypeEnum >( m_matchData.toInt() ) == Echonest::DynamicPlaylist::ArtistType ) + if ( static_cast< Echonest::DynamicPlaylist::ArtistTypeEnum >( m_matchData.toInt() ) == Echonest::DynamicPlaylist::ArtistType ) summary = tr( "only by ~%1" ).arg( m_data.second.toString() ); - else if( static_cast< Echonest::DynamicPlaylist::ArtistTypeEnum >( m_matchData.toInt() ) == Echonest::DynamicPlaylist::ArtistRadioType ) + else if ( static_cast< Echonest::DynamicPlaylist::ArtistTypeEnum >( m_matchData.toInt() ) == Echonest::DynamicPlaylist::ArtistRadioType ) summary = tr( "similar to ~%1" ).arg( m_data.second.toString() ); - } else if( selectedType() == "Artist Description" ) { + } + else if( selectedType() == "Artist Description" ) + { summary = tr( "with genre ~%1" ).arg( m_data.second.toString() ); - } else if( selectedType() == "User Radio" ) { + } + else if( selectedType() == "User Radio" ) + { QComboBox* b = qobject_cast< QComboBox* >( m_input.data() ); if ( b ) { @@ -765,11 +770,16 @@ Tomahawk::EchonestControl::calculateSummary() } else summary = tr( "from no one" ); - } else if( selectedType() == "Artist Description" || selectedType() == "Song" ) { - summary = QString( "similar to ~%1" ).arg( m_data.second.toString() ); - } else if( selectedType() == "Variety" || selectedType() == "Danceability" || selectedType() == "Artist Hotttnesss" || - selectedType() == "Energy" || selectedType() == "Artist Familiarity" || selectedType() == "Song Hotttnesss" || - selectedType() == "Adventurousness" ) { + } + else if ( selectedType() == "Artist Description" || selectedType() == "Song" ) + { + summary = tr( "similar to ~%1" ).arg( m_data.second.toString() ); + } + else if ( selectedType() == QT_TR_NOOP( "Variety" ) || selectedType() == QT_TR_NOOP( "Danceability" ) || + selectedType() == QT_TR_NOOP( "Artist Hotttnesss" ) || selectedType() == QT_TR_NOOP( "Energy" ) || + selectedType() == QT_TR_NOOP( "Artist Familiarity" ) || selectedType() == QT_TR_NOOP( "Song Hotttnesss" ) || + selectedType() == QT_TR_NOOP( "Adventurousness" ) ) + { QString modifier; qreal sliderVal = m_data.second.toReal(); // divide into avpproximate chunks @@ -783,26 +793,40 @@ Tomahawk::EchonestControl::calculateSummary() modifier = tr( "high" ); else if( 0.8 <= sliderVal && sliderVal <= 1 ) modifier = tr( "very high" ); - summary = tr( "with %1 %2" ).arg( modifier ).arg( selectedType().toLower() ); - } else if( selectedType() == "Tempo" ) { + summary = tr( "with %1 %2" ).arg( modifier ).arg( tr( selectedType().toStdString().c_str() ) ); + } + else if ( selectedType() == "Tempo" ) + { summary = tr( "about %1 BPM" ).arg( m_data.second.toString() ); - } else if( selectedType() == "Duration" ) { + } + else if ( selectedType() == "Duration" ) + { summary = tr( "about %n minute(s) long", "", m_data.second.toInt() / 60 ); - } else if( selectedType() == "Loudness" ) { + } + else if ( selectedType() == "Loudness" ) + { summary = tr( "about %1 dB" ).arg( m_data.second.toString() ); - } else if( selectedType() == "Latitude" || selectedType() == "Longitude" ) { - summary = tr( "at around %1%2 %3" ).arg( m_data.second.toString() ).arg( QString( QChar( 0x00B0 ) ) ).arg( selectedType().toLower() ); - } else if( selectedType() == "Key" ) { + } + else if ( selectedType() == "Latitude" || selectedType() == "Longitude" ) + { + summary = tr( "at around %1%2 %3" ).arg( m_data.second.toString() ).arg( QString( QChar( 0x00B0 ) ) ).arg( tr( selectedType().toStdString().c_str() ) ); + } + else if ( selectedType() == "Key" ) + { Q_ASSERT( !m_input.isNull() ); Q_ASSERT( qobject_cast< QComboBox* >( m_input.data() ) ); QString keyName = qobject_cast< QComboBox* >( m_input.data() )->currentText().toLower(); summary = tr( "in %1" ).arg( keyName ); - } else if( selectedType() == "Mode" ) { + } + else if ( selectedType() == "Mode" ) + { Q_ASSERT( !m_input.isNull() ); Q_ASSERT( qobject_cast< QComboBox* >( m_input.data() ) ); QString modeName = qobject_cast< QComboBox* >( m_input.data() )->currentText().toLower(); summary = tr( "in a %1 key" ).arg( modeName ); - } else if( selectedType() == "Sorting" ) { + } + else if ( selectedType() == "Sorting" ) + { Q_ASSERT( !m_input.isNull() ); Q_ASSERT( qobject_cast< QComboBox* >( m_input.data() ) ); QString sortType = qobject_cast< QComboBox* >( m_input.data() )->currentText().toLower(); @@ -812,17 +836,22 @@ Tomahawk::EchonestControl::calculateSummary() QString ascdesc = qobject_cast< QComboBox* >( m_match.data() )->currentText().toLower(); summary = tr( "sorted in %1 %2 order" ).arg( ascdesc ).arg( sortType ); - } else if( selectedType() == "Mood" ) { + } + else if ( selectedType() == "Mood" ) + { Q_ASSERT( !m_input.isNull() ); Q_ASSERT( qobject_cast< QComboBox* >( m_input.data() ) ); QString text = qobject_cast< QComboBox* >( m_input.data() )->currentText().toLower(); summary = tr( "with a %1 mood" ).arg( text ); - } else if( selectedType() == "Style" ) { + } + else if ( selectedType() == "Style" ) + { Q_ASSERT( !m_input.isNull() ); Q_ASSERT( qobject_cast< QComboBox* >( m_input.data() ) ); QString text = qobject_cast< QComboBox* >( m_input.data() )->currentText().toLower(); summary = tr( "in a %1 style" ).arg( text ); } + m_summary = summary; }