Skip to content

Commit

Permalink
added translation support and handle plurals in header
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabhsood91 committed Mar 3, 2013
1 parent f1614c0 commit 75edc94
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
8 changes: 8 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@
#include <QStringList>
#include <QUuid>
#include <QFileInfo>
#include <QTranslator>
#include <QLibraryInfo>
#include "mainwindow.h"

int main( int argc, char *argv[] )
{
QApplication app( argc, argv );

bool fakeRequested = false;
if( argc == 1) {
qDebug() << "No Valid File Passed";
Expand All @@ -46,5 +49,10 @@ int main( int argc, char *argv[] )
qDebug() << fileName;
MainWindow *win = new MainWindow( QString( argv[1] ), fileName, fakeRequested );
win->show();

QTranslator translator;
translator.load( "qt_" + QLocale::system().name(), QLibraryInfo::location( QLibraryInfo::TranslationsPath ) );
app.installTranslator( &translator );

return app.exec();
}
23 changes: 12 additions & 11 deletions src/mainheader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,18 @@ void MainHeader::changeStatusLabel( int repoCount, int packageCount )
m_packageCount = packageCount;
m_repoCount = repoCount;

QString statusText = QString( "This installer will download and install %1" ).arg( m_packageCount );

if( m_packageCount > 1 )
statusText.append( " packages" );
else
statusText.append( " package" );

if( m_repoCount > 1 )
statusText.append( QString( " from %1 sources" ).append( m_repoCount ) );
else
statusText.append( " from 1 source");
QString statusText = QString( tr( "This installer will download and install %n package(s) ", "", m_packageCount ) );
statusText.append( QString( tr( "from %n source(s)", "", m_repoCount ) ) );

// if( m_packageCount > 1 )
// statusText.append( " packages" );
// else
// statusText.append( " package" );

// if( m_repoCount > 1 )
// statusText.append( QString( " from %1 sources" ).append( m_repoCount ) );
// else
// statusText.append( " from 1 source");
m_statusLabel->setText( statusText );
}

Expand Down

0 comments on commit 75edc94

Please sign in to comment.