From 492c2acf18422176bb1cf668cb2cc30f02fb8305 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Wed, 30 Mar 2011 19:07:05 +0200 Subject: [PATCH] i18n: tr() and avoid string puzzle --- src/libtomahawk/network/servent.cpp | 12 +++---- src/sip/jabber/jabber.cpp | 2 +- src/sip/twitter/twitter.cpp | 2 +- src/sip/twitter/twitterconfigwidget.cpp | 46 ++++++++++++------------- src/xmppbot/xmppbot.cpp | 10 +++--- 5 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/libtomahawk/network/servent.cpp b/src/libtomahawk/network/servent.cpp index 182c8a2f4..1d54d0897 100644 --- a/src/libtomahawk/network/servent.cpp +++ b/src/libtomahawk/network/servent.cpp @@ -676,12 +676,12 @@ Servent::checkACL( const Connection* conn, const QString &nodeid, bool showDialo qDebug() << "ACL for this node not found"; QMessageBox msgBox; msgBox.setIcon( QMessageBox::Question ); - msgBox.setText( "Incoming Connection Attempt" ); - msgBox.setInformativeText( QString( "Another Tomahawk instance is attempting to connect to you. Select whether to allow or deny this connection.\n\nPeer name: %1\nPeer ID: %2\n\nRemember: Only allow peers to connect if you have the legal right for them to stream music from you.").arg( conn->name(), nodeid ) ); - QPushButton *denyButton = msgBox.addButton( "Deny", QMessageBox::HelpRole ); - QPushButton *alwaysDenyButton = msgBox.addButton( "Always Deny", QMessageBox::YesRole ); - QPushButton *allowButton = msgBox.addButton( "Allow", QMessageBox::NoRole ); - QPushButton *alwaysAllowButton = msgBox.addButton( "Always Allow", QMessageBox::ActionRole ); + msgBox.setText( tr( "Incoming Connection Attempt" ) ); + msgBox.setInformativeText( tr( "Another Tomahawk instance is attempting to connect to you. Select whether to allow or deny this connection.\n\nPeer name: %1\nPeer ID: %2\n\nRemember: Only allow peers to connect if you have the legal right for them to stream music from you.").arg( conn->name(), nodeid ) ); + QPushButton *denyButton = msgBox.addButton( tr( "Deny" ), QMessageBox::HelpRole ); + QPushButton *alwaysDenyButton = msgBox.addButton( tr( "Always Deny" ), QMessageBox::YesRole ); + QPushButton *allowButton = msgBox.addButton( tr( "Allow" ), QMessageBox::NoRole ); + QPushButton *alwaysAllowButton = msgBox.addButton( tr( "Always Allow" ), QMessageBox::ActionRole ); msgBox.setDefaultButton( denyButton ); msgBox.setEscapeButton( denyButton ); diff --git a/src/sip/jabber/jabber.cpp b/src/sip/jabber/jabber.cpp index ce62909c4..dab22ac5b 100644 --- a/src/sip/jabber/jabber.cpp +++ b/src/sip/jabber/jabber.cpp @@ -120,7 +120,7 @@ JabberPlugin::onConnected() { if ( !m_menu ) { - m_menu = new QMenu( QString( "Jabber (" ).append( accountName() ).append( ")" ) ); + m_menu = new QMenu( tr( "Jabber (%1)" ).arg( accountName() ) ); m_addFriendAction = m_menu->addAction( tr( "Add Friend..." ) ); connect( m_addFriendAction, SIGNAL( triggered() ), SLOT( showAddFriendDialog() ) ) ; diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index 655dd832b..772c9abdb 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -87,7 +87,7 @@ TwitterPlugin::name() const QString TwitterPlugin::friendlyName() { - return QString("Twitter"); + return tr("Twitter"); } const QString diff --git a/src/sip/twitter/twitterconfigwidget.cpp b/src/sip/twitter/twitterconfigwidget.cpp index 85660318a..8211f97dc 100644 --- a/src/sip/twitter/twitterconfigwidget.cpp +++ b/src/sip/twitter/twitterconfigwidget.cpp @@ -51,8 +51,8 @@ TwitterConfigWidget::TwitterConfigWidget( SipPlugin* plugin, QWidget *parent ) : TomahawkSettings* s = TomahawkSettings::instance(); if ( s->twitterOAuthToken().isEmpty() || s->twitterOAuthTokenSecret().isEmpty() || s->twitterScreenName().isEmpty() ) { - ui->twitterStatusLabel->setText("Status: No saved credentials"); - ui->twitterAuthenticateButton->setText( "Authenticate" ); + ui->twitterStatusLabel->setText( tr( "Status: No saved credentials" ) ); + ui->twitterAuthenticateButton->setText( tr( "Authenticate" ) ); ui->twitterInstructionsInfoLabel->setVisible( false ); ui->twitterGlobalTweetLabel->setVisible( false ); ui->twitterTweetGotTomahawkButton->setVisible( false ); @@ -63,8 +63,8 @@ TwitterConfigWidget::TwitterConfigWidget( SipPlugin* plugin, QWidget *parent ) : } else { - ui->twitterStatusLabel->setText("Status: Credentials saved for " + s->twitterScreenName() ); - ui->twitterAuthenticateButton->setText( "De-authenticate" ); + ui->twitterStatusLabel->setText( tr( "Status: Credentials saved for %1" ).arg( s->twitterScreenName() ) ); + ui->twitterAuthenticateButton->setText( tr( "De-authenticate" ) ); ui->twitterInstructionsInfoLabel->setVisible( true ); ui->twitterGlobalTweetLabel->setVisible( true ); ui->twitterTweetGotTomahawkButton->setVisible( true ); @@ -84,7 +84,7 @@ TwitterConfigWidget::~TwitterConfigWidget() void TwitterConfigWidget::authDeauthTwitter() { - if ( ui->twitterAuthenticateButton->text() == "Authenticate" ) + if ( ui->twitterAuthenticateButton->text() == tr( "Authenticate" ) ) //FIXME: don't rely on UI strings here! authenticateTwitter(); else deauthenticateTwitter(); @@ -114,7 +114,7 @@ TwitterConfigWidget::authenticateVerifyReply( const QTweetUser &user ) qDebug() << Q_FUNC_INFO; if ( user.id() == 0 ) { - QMessageBox::critical( 0, QString("Tweetin' Error"), QString("The credentials could not be verified.\nYou may wish to try re-authenticating.") ); + QMessageBox::critical( 0, tr("Tweetin' Error"), tr("The credentials could not be verified.\nYou may wish to try re-authenticating.") ); emit twitterAuthed( false ); return; } @@ -124,8 +124,8 @@ TwitterConfigWidget::authenticateVerifyReply( const QTweetUser &user ) s->setTwitterCachedFriendsSinceId( 0 ); s->setTwitterCachedMentionsSinceId( 0 ); - ui->twitterStatusLabel->setText("Status: Credentials saved for " + s->twitterScreenName() ); - ui->twitterAuthenticateButton->setText( "De-authenticate" ); + ui->twitterStatusLabel->setText( tr( "Status: Credentials saved for %1" ).arg( s->twitterScreenName() ) ); + ui->twitterAuthenticateButton->setText( tr( "De-authenticate" ) ); ui->twitterInstructionsInfoLabel->setVisible( true ); ui->twitterGlobalTweetLabel->setVisible( true ); ui->twitterTweetGotTomahawkButton->setVisible( true ); @@ -142,7 +142,7 @@ TwitterConfigWidget::authenticateVerifyError( QTweetNetBase::ErrorCode code, con { qDebug() << Q_FUNC_INFO; qDebug() << "Error validating credentials, error code is " << code << ", error message is " << errorMsg; - ui->twitterStatusLabel->setText("Status: Error validating credentials"); + ui->twitterStatusLabel->setText(tr("Status: Error validating credentials")); emit twitterAuthed( false ); return; } @@ -156,8 +156,8 @@ TwitterConfigWidget::deauthenticateTwitter() s->setTwitterOAuthTokenSecret( QString() ); s->setTwitterScreenName( QString() ); - ui->twitterStatusLabel->setText("Status: No saved credentials"); - ui->twitterAuthenticateButton->setText( "Authenticate" ); + ui->twitterStatusLabel->setText(tr("Status: No saved credentials")); + ui->twitterAuthenticateButton->setText( tr( "Authenticate" ) ); ui->twitterInstructionsInfoLabel->setVisible( false ); ui->twitterGlobalTweetLabel->setVisible( false ); ui->twitterTweetGotTomahawkButton->setVisible( false ); @@ -170,7 +170,7 @@ TwitterConfigWidget::deauthenticateTwitter() void TwitterConfigWidget::tweetComboBoxIndexChanged( int index ) { - if( ui->twitterTweetComboBox->currentText() == "Global Tweet" ) + if( ui->twitterTweetComboBox->currentText() == tr( "Global Tweet" ) ) //FIXME: use data! { ui->twitterUserTweetLineEdit->setReadOnly( true ); ui->twitterUserTweetLineEdit->setEnabled( false ); @@ -181,10 +181,10 @@ TwitterConfigWidget::tweetComboBoxIndexChanged( int index ) ui->twitterUserTweetLineEdit->setEnabled( true ); } - if( ui->twitterTweetComboBox->currentText() == "Direct Message" ) - ui->twitterTweetGotTomahawkButton->setText( "Send Message!" ); + if( ui->twitterTweetComboBox->currentText() == tr( "Direct Message" ) ) //FIXME: use data! + ui->twitterTweetGotTomahawkButton->setText( tr( "Send Message!" ) ); else - ui->twitterTweetGotTomahawkButton->setText( "Tweet!" ); + ui->twitterTweetGotTomahawkButton->setText( tr( "Tweet!" ) ); } void @@ -194,7 +194,7 @@ TwitterConfigWidget::startPostGotTomahawkStatus() if ( m_postGTtype != "Global Tweet" && ( ui->twitterUserTweetLineEdit->text().isEmpty() || ui->twitterUserTweetLineEdit->text() == "@" ) ) { - QMessageBox::critical( 0, QString("Tweetin' Error"), QString("You must enter a user name for this type of tweet.") ); + QMessageBox::critical( 0, tr("Tweetin' Error"), tr("You must enter a user name for this type of tweet.") ); return; } @@ -202,7 +202,7 @@ TwitterConfigWidget::startPostGotTomahawkStatus() TomahawkSettings* s = TomahawkSettings::instance(); if ( s->twitterOAuthToken().isEmpty() || s->twitterOAuthTokenSecret().isEmpty() || s->twitterScreenName().isEmpty() ) { - QMessageBox::critical( 0, QString("Tweetin' Error"), QString("Your saved credentials could not be loaded.\nYou may wish to try re-authenticating.") ); + QMessageBox::critical( this, tr("Tweetin' Error"), tr("Your saved credentials could not be loaded.\nYou may wish to try re-authenticating.") ); emit twitterAuthed( false ); return; } @@ -220,7 +220,7 @@ TwitterConfigWidget::postGotTomahawkStatusAuthVerifyReply( const QTweetUser &use { if ( user.id() == 0 ) { - QMessageBox::critical( 0, QString("Tweetin' Error"), QString("Your saved credentials could not be verified.\nYou may wish to try re-authenticating.") ); + QMessageBox::critical( 0, tr("Tweetin' Error"), tr("Your saved credentials could not be verified.\nYou may wish to try re-authenticating.") ); emit twitterAuthed( false ); return; } @@ -264,18 +264,18 @@ void TwitterConfigWidget::postGotTomahawkStatusUpdateReply( const QTweetStatus& status ) { if ( status.id() == 0 ) - QMessageBox::critical( 0, QString("Tweetin' Error"), QString("There was an error posting your status -- sorry!") ); + QMessageBox::critical( 0, tr("Tweetin' Error"), tr("There was an error posting your status -- sorry!") ); else - QMessageBox::information( 0, QString("Tweeted!"), QString("Your tweet has been posted!") ); + QMessageBox::information( 0, tr("Tweeted!"), tr("Your tweet has been posted!") ); } void TwitterConfigWidget::postGotTomahawkDirectMessageReply( const QTweetDMStatus& status ) { if ( status.id() == 0 ) - QMessageBox::critical( 0, QString("Tweetin' Error"), QString("There was an error posting your direct message -- sorry!") ); + QMessageBox::critical( 0, tr("Tweetin' Error"), tr("There was an error posting your direct message -- sorry!") ); else - QMessageBox::information( 0, QString("Tweeted!"), QString("Your message has been posted!") ); + QMessageBox::information( 0, tr("Tweeted!"), tr("Your message has been posted!") ); } void @@ -283,5 +283,5 @@ TwitterConfigWidget::postGotTomahawkStatusUpdateError( QTweetNetBase::ErrorCode { qDebug() << Q_FUNC_INFO; qDebug() << "Error posting Got Tomahawk message, error code is " << code << ", error message is " << errorMsg; - QMessageBox::critical( 0, QString("Tweetin' Error"), QString("There was an error posting your status -- sorry!") ); + QMessageBox::critical( 0, tr("Tweetin' Error"), tr("There was an error posting your status -- sorry!") ); } diff --git a/src/xmppbot/xmppbot.cpp b/src/xmppbot/xmppbot.cpp index e6be8a57c..d7d267f9d 100644 --- a/src/xmppbot/xmppbot.cpp +++ b/src/xmppbot/xmppbot.cpp @@ -306,9 +306,9 @@ void XMPPBot::infoReturnedSlot(QString caller, Tomahawk::InfoSystem::InfoType ty } InfoGenericMap tmap = output.value(); QString artist = input.toString(); - m_currReturnMessage += QString("\nTerms for %1:\n").arg(artist); + m_currReturnMessage += tr("\nTerms for %1:\n").arg(artist); if (tmap.isEmpty()) - m_currReturnMessage += QString("No terms found, sorry."); + m_currReturnMessage += tr("No terms found, sorry."); else { bool first = true; @@ -341,7 +341,7 @@ void XMPPBot::infoReturnedSlot(QString caller, Tomahawk::InfoSystem::InfoType ty QString artist = input.toString(); qreal retVal = output.toReal(); QString retValString = (retVal == 0.0 ? "(none)" : QString::number(retVal)); - m_currReturnMessage += QString("\nHotttness for %1: %2\n").arg(artist).arg(retValString); + m_currReturnMessage += tr("\nHotttness for %1: %2\n").arg(artist, retValString); break; } case InfoArtistFamiliarity: @@ -357,7 +357,7 @@ void XMPPBot::infoReturnedSlot(QString caller, Tomahawk::InfoSystem::InfoType ty QString artist = input.toString(); qreal retVal = output.toReal(); QString retValString = (retVal == 0.0 ? "(none)" : QString::number(retVal)); - m_currReturnMessage += QString("\nFamiliartiy for %1: %2\n").arg(artist).arg(retValString); + m_currReturnMessage += tr("\nFamiliarity for %1: %2\n").arg(artist, retValString); break; } case InfoTrackLyrics: @@ -375,7 +375,7 @@ void XMPPBot::infoReturnedSlot(QString caller, Tomahawk::InfoSystem::InfoType ty QString track = inHash["trackName"].toString(); QString lyrics = output.toString(); qDebug() << "lyrics = " << lyrics; - m_currReturnMessage += QString("\nLyrics for \"%1\" by %2:\n\n%3\n").arg(track).arg(artist).arg(lyrics); + m_currReturnMessage += tr("\nLyrics for \"%1\" by %2:\n\n%3\n").arg(track, artist, lyrics); break; } default: