From d05e90e4956aaf26a40ba0c6203a1b8aa8668de2 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Fri, 18 Jan 2013 18:11:07 +0100 Subject: [PATCH] Improve translatability of the application Head towards a translatable application by loading translation files for the current locale and using tr() where ever it's needed. --- src/CreateIndexDialog.cpp | 6 +- src/EditDialog.cpp | 15 ++-- src/EditTableDialog.cpp | 2 +- src/ExportCsvDialog.cpp | 10 +-- src/FindDialog.cpp | 2 +- src/ImportCsvDialog.cpp | 6 +- src/MainWindow.cpp | 96 ++++++++++-------------- src/PreferencesDialog.cpp | 2 +- src/SQLLogDock.cpp | 2 +- src/main.cpp | 11 +++ src/sqlitedb.cpp | 77 +++++++++---------- src/translations/place_translations_here | 0 12 files changed, 108 insertions(+), 121 deletions(-) create mode 100644 src/translations/place_translations_here diff --git a/src/CreateIndexDialog.cpp b/src/CreateIndexDialog.cpp index dc534909..ee5babf3 100644 --- a/src/CreateIndexDialog.cpp +++ b/src/CreateIndexDialog.cpp @@ -89,9 +89,7 @@ void CreateIndexDialog::accept() sql.append(");"); if(pdb->executeSQL(sql)) - { QDialog::accept(); - } else { - QMessageBox::warning(this, QApplication::applicationName(), tr("Creating the index failed:\n").arg(pdb->lastErrorMessage)); - } + else + QMessageBox::warning(this, QApplication::applicationName(), tr("Creating the index failed:\n%1").arg(pdb->lastErrorMessage)); } diff --git a/src/EditDialog.cpp b/src/EditDialog.cpp index b0c9b491..5147297b 100644 --- a/src/EditDialog.cpp +++ b/src/EditDialog.cpp @@ -41,13 +41,12 @@ void EditDialog::setDataType(int type, int size) { case kSQLiteMediaType_String: ui->labelType->setText(tr("Type of data currently in cell: Text / Numeric")); - if(ui->editData->toPlainText().length() == 1) charstr = QString("char"); else charstr = QString("chars"); - ui->labelSize->setText(QString("%1 %2").arg(ui->editData->toPlainText().length()).arg(charstr)); + ui->labelSize->setText(tr("%n char(s)", "", ui->editData->toPlainText().length())); enableExport(true); break; case kSQLiteMediaType_Void: - ui->labelType->setText("Type of data currently in cell: Empty"); - ui->labelSize->setText(""); + ui->labelType->setText(tr("Type of data currently in cell: Empty")); + ui->labelSize->setText(tr("")); enableExport(false); break; } @@ -78,7 +77,7 @@ void EditDialog::importData() this, tr("Choose a file"), defaultlocation, - QString("Text files(*.txt);;All files(*)")); + tr("Text files(*.txt);;All files(*)")); if(QFile::exists(fileName)) { type = kSQLiteMediaType_String; @@ -99,7 +98,7 @@ void EditDialog::exportData() switch (dataType) { case kSQLiteMediaType_String: - filter = "Text files(*.txt)"; + filter = tr("Text files(*.txt)"); break; default: return; @@ -107,7 +106,7 @@ void EditDialog::exportData() QString fileName = QFileDialog::getSaveFileName( this, - "Choose a filename to export data", + tr("Choose a filename to export data"), defaultlocation, filter); @@ -144,7 +143,7 @@ void EditDialog::accept() emit updateRecordText(curRow, curCol, ui->editData->toPlainText()); if (dataType == kSQLiteMediaType_Void) - emit updateRecordText(curRow, curCol, QString("")); + emit updateRecordText(curRow, curCol, ""); emit goingAway(); } diff --git a/src/EditTableDialog.cpp b/src/EditTableDialog.cpp index 182dda16..d918c4a3 100644 --- a/src/EditTableDialog.cpp +++ b/src/EditTableDialog.cpp @@ -68,7 +68,7 @@ void EditTableDialog::accept() // Create table if(!pdb->createTable(ui->editTableName->text(), tbl_structure)) { - QMessageBox::warning(this, QApplication::applicationName(), QString("Error creating table. Message from database engine:\n%1").arg(pdb->lastErrorMessage)); + QMessageBox::warning(this, QApplication::applicationName(), tr("Error creating table. Message from database engine:\n%1").arg(pdb->lastErrorMessage)); return; } } else { diff --git a/src/ExportCsvDialog.cpp b/src/ExportCsvDialog.cpp index 77b5c215..c964fd1a 100644 --- a/src/ExportCsvDialog.cpp +++ b/src/ExportCsvDialog.cpp @@ -31,9 +31,9 @@ void ExportCsvDialog::accept() // Get filename QString fileName = QFileDialog::getSaveFileName( this, - "Choose a filename to export data", + tr("Choose a filename to export data"), defaultLocation, - "Text files(*.csv *.txt)"); + tr("Text files(*.csv *.txt)")); // Only if the user hasn't clicked the cancel button if(fileName.size() > 0) @@ -45,7 +45,7 @@ void ExportCsvDialog::accept() QString quoteChar = ui->comboQuoteCharacter->currentText(); QString quotequoteChar = quoteChar + quoteChar; QString sepChar = ui->comboFieldSeparator->currentText(); - if(sepChar == "Tab") sepChar = "\t"; + if(sepChar == tr("Tab")) sepChar = "\t"; QString newlineChar = "\n"; // Open file @@ -87,10 +87,10 @@ void ExportCsvDialog::accept() // Done writing the file file.close(); - QMessageBox::information(this, QApplication::applicationName(), "Export completed."); + QMessageBox::information(this, QApplication::applicationName(), tr("Export completed.")); QDialog::accept(); } else { - QMessageBox::warning(this, QApplication::applicationName(), "Could not open output file."); + QMessageBox::warning(this, QApplication::applicationName(), tr("Could not open output file.")); } } } diff --git a/src/FindDialog.cpp b/src/FindDialog.cpp index 897282b7..9c8582e8 100644 --- a/src/FindDialog.cpp +++ b/src/FindDialog.cpp @@ -43,7 +43,7 @@ void FindDialog::resetFields(QStringList fieldlist) ui->editSearchString->setText(""); ui->comboOperator->setCurrentIndex(0); ui->tableResults->clearContents(); - ui->labelNumberResults->setText("Found: 0"); + ui->labelNumberResults->setText(tr("Found: 0")); } void FindDialog::recordSelected(QTableWidgetItem* witem) diff --git a/src/ImportCsvDialog.cpp b/src/ImportCsvDialog.cpp index 6df5f633..79ab5f2f 100644 --- a/src/ImportCsvDialog.cpp +++ b/src/ImportCsvDialog.cpp @@ -63,7 +63,7 @@ void ImportCsvDialog::accept() } // Show progress dialog - QProgressDialog progress("Inserting data...", "Cancel", 0, curList.size()); + QProgressDialog progress(tr("Inserting data..."), tr("Cancel"), 0, curList.size()); progress.setWindowModality(Qt::ApplicationModal); // declare local variables we will need before the rollback jump @@ -118,7 +118,7 @@ void ImportCsvDialog::accept() rollback: progress.hide(); QApplication::restoreOverrideCursor(); // restore original cursor - QString error = QString("Error importing data. Message from database engine: %1").arg(pdb->lastErrorMessage); + QString error = tr("Error importing data. Message from database engine: %1").arg(pdb->lastErrorMessage); QMessageBox::warning(this, QApplication::applicationName(), error); pdb->executeSQL("ROLLBACK TO SAVEPOINT CSVIMPORT;", false); } @@ -187,5 +187,5 @@ char ImportCsvDialog::currentQuoteChar() char ImportCsvDialog::currentSeparatorChar() { - return ui->comboSeparator->currentText() == "Tab" ? '\t' : ui->comboSeparator->currentText().at(0).toAscii(); + return ui->comboSeparator->currentText() == tr("Tab") ? '\t' : ui->comboSeparator->currentText().at(0).toAscii(); } diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index a62e30e8..de7196ba 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -121,7 +121,7 @@ void MainWindow::fileOpen(const QString & fileName) { wFile = QFileDialog::getOpenFileName( this, - "Choose a database file", + tr("Choose a database file"), defaultlocation); } if(QFile::exists(wFile) ) @@ -131,8 +131,7 @@ void MainWindow::fileOpen(const QString & fileName) { setCurrentFile(wFile); } else { - QString err = "An error occurred: "; - err.append(db.lastErrorMessage); + QString err = tr("An error occurred: %1").arg(db.lastErrorMessage); QMessageBox::warning(this, QApplication::applicationName(), err); } populateStructure(); @@ -149,7 +148,7 @@ void MainWindow::fileOpen() void MainWindow::fileNew() { - QString fileName = QFileDialog::getSaveFileName(this, "Choose a filename to save under", defaultlocation); + QString fileName = QFileDialog::getSaveFileName(this, tr("Choose a filename to save under"), defaultlocation); if(!fileName.isEmpty()) { if(QFile::exists(fileName)) @@ -297,16 +296,11 @@ void MainWindow::fileExit() { if (db.getDirty()) { - QString msg = "Do you want to save the changes made to the database file "; - msg.append(db.curDBFilename); - msg.append("?"); - if (QMessageBox::question( this, QApplication::applicationName() ,msg, QMessageBox::Yes, QMessageBox::No)==QMessageBox::Yes) - { + QString msg = tr("Do you want to save the changes made to the database file %1?").arg(db.curDBFilename); + if(QMessageBox::question( this, QApplication::applicationName() ,msg, QMessageBox::Yes, QMessageBox::No)==QMessageBox::Yes) db.save(); - } else { - //not really necessary, I think... but will not hurt. - db.revert(); - } + else + db.revert(); //not really necessary, I think... but will not hurt. } db.close(); } @@ -330,10 +324,10 @@ void MainWindow::addRecord() updateTableView(db.getRecordCount()-1); }else{ QMessageBox::information( this, QApplication::applicationName(), - "Error adding record, make sure a table is selected.\n\n" + tr("Error adding record, make sure a table is selected.\n\n" "If the table contain fields declared as NOT NULL\n" "please select EDIT->PREFERENCES and adjust the\n" - "default value for new records to insert an empty string." ); + "default value for new records to insert an empty string.")); } } @@ -352,7 +346,7 @@ void MainWindow::deleteRecord() selectTableLine(nextselected); } } else { - QMessageBox::information( this, QApplication::applicationName(), "Please select a record first" ); + QMessageBox::information( this, QApplication::applicationName(), tr("Please select a record first")); } } @@ -473,7 +467,7 @@ void MainWindow::setRecordsetLabel() if(to == -2) to = total; - ui->labelRecordset->setText(QString("%1 - %2 of %3").arg(from).arg(to).arg(total)); + ui->labelRecordset->setText(tr("%1 - %2 of %3").arg(from).arg(to).arg(total)); } void MainWindow::browseFind(bool open) @@ -508,7 +502,7 @@ void MainWindow::browseRefresh() void MainWindow::lookfor( const QString & wfield, const QString & woperator, const QString & wsearchterm ) { if (!db.isOpen()){ - QMessageBox::information( this, QApplication::applicationName(), "There is no database opened. Please open or create a new database file." ); + QMessageBox::information( this, QApplication::applicationName(), tr("There is no database opened. Please open or create a new database file.")); return; } @@ -517,7 +511,8 @@ void MainWindow::lookfor( const QString & wfield, const QString & woperator, con QString finalsearchterm = wsearchterm; //special case for CONTAINS operator: use LIKE and surround the search word with % characters - if (woperator.compare("contains")==0){ + if(woperator.compare(tr("contains")) == 0) + { finaloperator = QString("LIKE"); QString newsearchterm = "%"; newsearchterm.append(wsearchterm); @@ -554,7 +549,7 @@ void MainWindow::lookfor( const QString & wfield, const QString & woperator, con void MainWindow::createTable() { if (!db.isOpen()){ - QMessageBox::information( this, QApplication::applicationName(), "There is no database opened. Please open or create a new database file." ); + QMessageBox::information( this, QApplication::applicationName(), tr("There is no database opened. Please open or create a new database file.")); return; } @@ -569,7 +564,7 @@ void MainWindow::createTable() void MainWindow::createIndex() { if (!db.isOpen()){ - QMessageBox::information( this, QApplication::applicationName(), "There is no database opened. Please open or create a new database file." ); + QMessageBox::information( this, QApplication::applicationName(), tr("There is no database opened. Please open or create a new database file.")); return; } CreateIndexDialog dialog(&db, this); @@ -584,13 +579,12 @@ void MainWindow::compact() { QApplication::setOverrideCursor( Qt::WaitCursor ); if (!db.compact()){ - QString error = "Error: could not compact the database file. Message from database engine: "; - error.append(db.lastErrorMessage); + QString error = tr("Error: could not compact the database file. Message from database engine: %1").arg(db.lastErrorMessage); QApplication::restoreOverrideCursor( ); QMessageBox::warning( this, QApplication::applicationName(), error ); } else { QApplication::restoreOverrideCursor( ); - QMessageBox::information(this, QApplication::applicationName(), "Database successfully compacted."); + QMessageBox::information(this, QApplication::applicationName(), tr("Database successfully compacted.")); } db.open(db.curDBFilename); populateStructure(); @@ -611,7 +605,7 @@ void MainWindow::deleteObject() QString statement = QString("DROP %1 `%2`;").arg(type.toUpper()).arg(table); if(!db.executeSQL( statement)) { - QString error = QString("Error: could not delete the %1. Message from database engine:\n%2").arg(type).arg(db.lastErrorMessage); + QString error = tr("Error: could not delete the %1. Message from database engine:\n%2").arg(type).arg(db.lastErrorMessage); QMessageBox::warning(this, QApplication::applicationName(), error); } else { populateStructure(); @@ -623,7 +617,7 @@ void MainWindow::deleteObject() void MainWindow::editTable() { if (!db.isOpen()){ - QMessageBox::information( this, QApplication::applicationName(), "There is no database opened." ); + QMessageBox::information( this, QApplication::applicationName(), tr("There is no database opened.")); return; } if(!ui->dbTreeWidget->selectionModel()->hasSelection()){ @@ -684,7 +678,7 @@ void MainWindow::helpAbout() void MainWindow::updateRecordText(int row, int col, QString newtext) { if (!db.updateRecord(row, col, newtext)){ - QMessageBox::information( this, QApplication::applicationName(), "Data could not be updated" ); + QMessageBox::information( this, QApplication::applicationName(), tr("Data could not be updated")); } rowList tab = db.browseRecs; @@ -740,7 +734,7 @@ void MainWindow::executeQuery() QString query = ui->sqlTextEdit->toPlainText().trimmed(); if (query.isEmpty()) { - QMessageBox::information( this, QApplication::applicationName(), "Query string is empty" ); + QMessageBox::information( this, QApplication::applicationName(), tr("Query string is empty")); return; } //log the query @@ -750,7 +744,7 @@ void MainWindow::executeQuery() const char *tail = utf8Query.data(); int ncol; int err=0; - QString lastErrorMessage = QString("No error"); + QString lastErrorMessage = tr("No error"); //Accept multi-line queries, by looping until the tail is empty do { @@ -819,9 +813,9 @@ void MainWindow::importTableFromCSV() { QString wFile = QFileDialog::getOpenFileName( this, - "Choose a text file", + tr("Choose a text file"), defaultlocation, - "Text files(*.csv *.txt);;All files(*)"); + tr("Text files(*.csv *.txt);;All files(*)")); if (QFile::exists(wFile) ) { @@ -830,7 +824,7 @@ void MainWindow::importTableFromCSV() { populateStructure(); resetBrowser(); - QMessageBox::information( this, QApplication::applicationName(), "Import completed" ); + QMessageBox::information(this, QApplication::applicationName(), tr("Import completed")); } } } @@ -849,16 +843,14 @@ void MainWindow::dbState( bool dirty ) void MainWindow::fileSave() { - if (db.isOpen()){ + if(db.isOpen()) db.save(); - //dbStatusBar->showMessage("Date written to file", 4000) - } } void MainWindow::fileRevert() { if (db.isOpen()){ - QString msg = QString("Are you sure you want to undo all changes made to the database file '%1' since the last save?").arg(db.curDBFilename); + QString msg = tr("Are you sure you want to undo all changes made to the database file '%1' since the last save?").arg(db.curDBFilename); if(QMessageBox::question(this, QApplication::applicationName(), msg, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape) == QMessageBox::Yes) { db.revert(); @@ -872,16 +864,16 @@ void MainWindow::exportDatabaseToSQL() { QString fileName = QFileDialog::getSaveFileName( this, - "Choose a filename to export", + tr("Choose a filename to export"), defaultlocation, - "Text files(*.sql *.txt)"); + tr("Text files(*.sql *.txt)")); if(fileName.size()) { if(!db.dump(fileName)) - QMessageBox::warning(this, QApplication::applicationName(), "Export cancelled or failed."); + QMessageBox::warning(this, QApplication::applicationName(), tr("Export cancelled or failed.")); else - QMessageBox::information(this, QApplication::applicationName(), "Export completed."); + QMessageBox::information(this, QApplication::applicationName(), tr("Export completed.")); } } @@ -889,41 +881,33 @@ void MainWindow::importDatabaseFromSQL() { QString fileName = QFileDialog::getOpenFileName( this, - "Choose a file to import", + tr("Choose a file to import"), defaultlocation, - "Text files(*.sql *.txt);;All files(*)"); + tr("Text files(*.sql *.txt);;All files(*)")); if (fileName.size() > 0) { - QString msg = "Do you want to create a new database file to hold the imported data?\nIf you answer NO we will attempt to import data in the .sql file to the current database."; + QString msg = tr("Do you want to create a new database file to hold the imported data?\nIf you answer NO we will attempt to import data in the .sql file to the current database."); if (QMessageBox::question( this, QApplication::applicationName() ,msg, QMessageBox::Yes, QMessageBox::No)==QMessageBox::Yes) { QString newDBfile = QFileDialog::getSaveFileName( this, - "Choose a filename to save under", + tr("Choose a filename to save under"), defaultlocation); if (QFile::exists(newDBfile) ) { - QString err = "File "; - err.append(newDBfile); - err.append(" already exists. Please choose a different name"); + QString err = tr("File %1 already exists. Please choose a different name.").arg(newDBfile); QMessageBox::information( this, QApplication::applicationName() ,err); return; } - if (!fileName.isNull()) - { + if(!fileName.isNull()) db.create(newDBfile); - } } int lineErr; if (!db.reload(fileName, &lineErr)) - { - QMessageBox::information( this, QApplication::applicationName(), QString("Error importing data at line %1").arg(lineErr) ); - } + QMessageBox::information(this, QApplication::applicationName(), tr("Error importing data at line %1").arg(lineErr) ); else - { - QMessageBox::information( this, QApplication::applicationName(), "Import completed" ); - } + QMessageBox::information(this, QApplication::applicationName(), tr("Import completed")); populateStructure(); resetBrowser(); } diff --git a/src/PreferencesDialog.cpp b/src/PreferencesDialog.cpp index 3d1e8a03..47d64dfb 100644 --- a/src/PreferencesDialog.cpp +++ b/src/PreferencesDialog.cpp @@ -63,7 +63,7 @@ void PreferencesDialog::chooseLocation() if(!s.isEmpty()) { defaultlocation = s; - ui->locationEdit->setText(defaultlocation); + ui->locationEdit->setText(defaultlocation); } } diff --git a/src/SQLLogDock.cpp b/src/SQLLogDock.cpp index 93b8b7a2..a597d1c6 100644 --- a/src/SQLLogDock.cpp +++ b/src/SQLLogDock.cpp @@ -11,7 +11,7 @@ * true to construct a modal dialog. */ SQLLogDock::SQLLogDock(QWidget* parent) - : QDockWidget("SQL Log", parent) + : QDockWidget(tr("SQL Log"), parent) { setupUi(); } diff --git a/src/main.cpp b/src/main.cpp index 6059e855..5d9ca018 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,9 @@ #include "MainWindow.h" #include #include +#include +#include +#include #if defined(Q_WS_MAC) #include @@ -79,6 +82,14 @@ int main( int argc, char ** argv ) QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); + // Enable translation + QTranslator translator; + translator.load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); + a.installTranslator(&translator); + QTranslator apptranslator; + apptranslator.load("translations/tr_" + QLocale::system().name()); + a.installTranslator(&apptranslator); + MainWindow w; #if defined(Q_WS_MAC) AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, diff --git a/src/sqlitedb.cpp b/src/sqlitedb.cpp index 38f17153..9aceb5c7 100644 --- a/src/sqlitedb.cpp +++ b/src/sqlitedb.cpp @@ -89,15 +89,15 @@ bool DBBrowserDB::open ( const QString & db) QString contents = QString(buffer); dbfile.close(); if (!contents.startsWith("SQLite format 3")) { - lastErrorMessage = QString("File is not a SQLite 3 database"); + lastErrorMessage = QObject::tr("File is not a SQLite 3 database"); return false; } } else { - lastErrorMessage = QString("File could not be read"); + lastErrorMessage = QObject::tr("File could not be read"); return false; } - lastErrorMessage = QString("no error"); + lastErrorMessage = QObject::tr("no error"); err = sqlite3_open_v2(db.toUtf8(), &_db, SQLITE_OPEN_READWRITE, NULL); if ( err ) { @@ -167,7 +167,7 @@ bool DBBrowserDB::create ( const QString & db) if (isOpen()) close(); - lastErrorMessage = QString("no error"); + lastErrorMessage = QObject::tr("no error"); if( sqlite3_open(db.toUtf8(), &_db) != SQLITE_OK ){ lastErrorMessage = sqlite3_errmsg(_db); @@ -198,16 +198,11 @@ void DBBrowserDB::close (){ { if (getDirty()) { - QString msg = "Do you want to save the changes made to the database file "; - msg.append(curDBFilename); - msg.append(" ?"); + QString msg = QObject::tr("Do you want to save the changes made to the database file %1?").arg(curDBFilename); if (QMessageBox::question( 0, QApplication::applicationName() ,msg, QMessageBox::Yes, QMessageBox::No)==QMessageBox::Yes) - { save(); - } else { - //not really necessary, I think... but will not hurt. - revert(); - } + else + revert(); //not really necessary, I think... but will not hurt. } sqlite3_close(_db); } @@ -271,7 +266,7 @@ bool DBBrowserDB::dump(const QString& filename) QList tables = objMap.values("table"); for(QList::ConstIterator it=tables.begin();it!=tables.end();++it) numRecordsTotal += getFindResults(QString("SELECT COUNT(*) FROM `%1`;").arg((*it).getname())).value(0).toInt(); - QProgressDialog progress("Exporting database to SQL file...", "Cancel", 0, numRecordsTotal); + QProgressDialog progress(QObject::tr("Exporting database to SQL file..."), QObject::tr("Cancel"), 0, numRecordsTotal); progress.setWindowModality(Qt::ApplicationModal); // Regular expression to check for numeric strings @@ -386,7 +381,7 @@ bool DBBrowserDB::addRecord ( ) if (i loglimit)&&(msgtype==kLogMsg_App)) { statement.truncate(32); - statement.append("... ..."); + statement.append(QObject::tr("... ...")); } logWin->log(statement, msgtype); } @@ -890,7 +885,7 @@ void DBBrowserDB::updateSchema( ) objMap.clear(); - lastErrorMessage = QString("no error"); + lastErrorMessage = QObject::tr("no error"); QString statement = "SELECT type, name, sql FROM sqlite_master;"; err=sqlite3_prepare(_db, (const char *) statement.toUtf8(),statement.length(), @@ -906,11 +901,11 @@ void DBBrowserDB::updateSchema( ) if(val1 == "table" || val1 == "index" || val1 == "view" || val1 == "trigger") objMap.insert(val1, DBBrowserObject(GetDecodedQString(val2), GetDecodedQString(val3), GetDecodedQString(val1))); else - qDebug("unknown object type %s", val1.toStdString().c_str()); + qDebug(QObject::tr("unknown object type %1").arg(val1).toStdString().c_str()); } sqlite3_finalize(vm); }else{ - qDebug ("could not get list of db objects: %d, %s",err,sqlite3_errmsg(_db)); + qDebug(QObject::tr("could not get list of db objects: %1, %2").arg(err).arg(sqlite3_errmsg(_db)).toStdString().c_str()); } //now get the field list for each table @@ -933,16 +928,16 @@ void DBBrowserDB::updateSchema( ) val1 = QString((const char *) sqlite3_column_text(vm, 1)); val2 = QString((const char *) sqlite3_column_text(vm, 2)); ispk = sqlite3_column_int(vm, 5); - if (ispk==1){ + if(ispk==1) val2.append(QString(" PRIMARY KEY")); - } + (*it).addField(e,GetDecodedQString(val1),GetDecodedQString(val2)); e++; } } sqlite3_finalize(vm); } else{ - lastErrorMessage = QString ("could not get types"); + lastErrorMessage = QObject::tr("could not get types"); } } } @@ -959,7 +954,7 @@ QStringList DBBrowserDB::decodeCSV(const QString & csvfilename, char sep, char q *numfields = 0; if ( file.open( QIODevice::ReadWrite ) ) { - QProgressDialog progress("Decoding CSV file...", "Cancel", 0, file.size()); + QProgressDialog progress(QObject::tr("Decoding CSV file..."), QObject::tr("Cancel"), 0, file.size()); progress.setWindowModality(Qt::ApplicationModal); char c=0; while(file.getChar(&c)) @@ -1050,10 +1045,10 @@ QString DBBrowserDB::getPragma(QString pragma) sqlite3_finalize(vm); } else { sqlite3_finalize(vm); - qDebug("didn't receive any output from pragma %s", pragma.toStdString().c_str()); + qDebug(QObject::tr("didn't receive any output from pragma %1").arg(pragma).toStdString().c_str()); } } else { - qDebug ("could not execute pragma command: %d, %s", err, sqlite3_errmsg(_db)); + qDebug(QObject::tr("could not execute pragma command: %1, %2").arg(err).arg(sqlite3_errmsg(_db)).toStdString().c_str()); } // Make changes to the value when needed @@ -1143,7 +1138,7 @@ bool DBBrowserDB::setPragma(QString pragma, QString value) QString sql = QString("PRAGMA %1 = %2;").arg(pragma).arg(value); if(!executeSQL(sql)) { - qDebug("Error setting pragma %s to %s: %s", pragma.toStdString().c_str(), value.toStdString().c_str(), lastErrorMessage.toStdString().c_str()); + qDebug(QObject::tr("Error setting pragma %1 to %2: %3").arg(pragma).arg(value).arg(lastErrorMessage).toStdString().c_str()); return false; } else { return true; diff --git a/src/translations/place_translations_here b/src/translations/place_translations_here new file mode 100644 index 00000000..e69de29b