From 5b3ea73dacd2ce6f57d1b748f023da383112e410 Mon Sep 17 00:00:00 2001 From: g_j_m Date: Wed, 3 Jan 2007 01:48:58 +0000 Subject: [PATCH] Merge r6387 from 0.8 branch to head git-svn-id: http://svn.osgeo.org/qgis/trunk@6388 c8812cc2-4d05-0410-92ff-de0c093fc19c --- tools/mapserver_export/ms_main.cpp | 53 +++++++++++++++++-- tools/mapserver_export/qgsmapserverexport.cpp | 13 ++--- 2 files changed, 57 insertions(+), 9 deletions(-) diff --git a/tools/mapserver_export/ms_main.cpp b/tools/mapserver_export/ms_main.cpp index ebc23fd3409..f52f1970b06 100644 --- a/tools/mapserver_export/ms_main.cpp +++ b/tools/mapserver_export/ms_main.cpp @@ -1,13 +1,60 @@ -#include +#include +#include +#include +#include + #include "qgsmapserverexport.h" +#include "src/core/qgsapplication.h" + +#include + int main( int argc, char **argv ) { - QApplication a( argc, argv ); - // Set up the QSettings environment must be done after qapp is created + // Using QgsApplication instead of QApplication gives access to the + // qgis translation files. + QgsApplication a( argc, argv , true); + + // Set up the QSettings environment must be done after a is created QCoreApplication::setOrganizationName("QuantumGIS"); QCoreApplication::setOrganizationDomain("qgis.org"); QCoreApplication::setApplicationName("qgis"); + // Install translations if available. Based on the code in the Qgis + // main.cpp file. + + // Let the user set the locale on the command line. If this program + // needs to parse any more arguments, it'll be worthwhile using + // something like getopt. + QString translationCode; + QStringList args = a.arguments(); + int i = args.lastIndexOf("-h"); + if (i != -1) + { + std::cout << "Usage: msexport [--lang language]\n" + "\t[--lang language]\tuse language for interface text (optional)\n"; + exit(0); + } + + i = args.lastIndexOf("--lang"); + if (i != -1) + { + if (args.count() > i+1) + translationCode = args[i+1]; + } + + if (translationCode.isEmpty()) + translationCode = QTextCodec::locale(); + + QString i18nPath = QgsApplication::i18nPath(); + + QTranslator qttor; + if (qttor.load("qt_" + translationCode, i18nPath)) + a.installTranslator(&qttor); + + QTranslator mstor; + if (mstor.load("qgis_" + translationCode, i18nPath)) + a.installTranslator(&mstor); + QgsMapserverExport *mse = new QgsMapserverExport(); mse->show(); return a.exec(); diff --git a/tools/mapserver_export/qgsmapserverexport.cpp b/tools/mapserver_export/qgsmapserverexport.cpp index cd2ccff54bd..0f7b11c62f1 100644 --- a/tools/mapserver_export/qgsmapserverexport.cpp +++ b/tools/mapserver_export/qgsmapserverexport.cpp @@ -67,16 +67,16 @@ QString QgsMapserverExport::baseName() // Choose the map file to create void QgsMapserverExport::on_btnChooseFile_clicked() { - mapFile = QFileDialog::getSaveFileName(this, "Name for the map file", - ".", "MapServer map files (*.map);;All files(*.*)"); + mapFile = QFileDialog::getSaveFileName(this, tr("Name for the map file"), + ".", tr("MapServer map files (*.map);;All files(*.*)","Filter list for selecting files from a dialog box")); txtMapFilePath->setText(mapFile); } // Chooose the project file to process void QgsMapserverExport::on_btnChooseProjectFile_clicked() { - qgisProjectFile = QFileDialog::getOpenFileName(this, "Choose the QGIS project file", - ".", "QGIS Project Files (*.qgs);;All files (*.*)"); + qgisProjectFile = QFileDialog::getOpenFileName(this, tr("Choose the QGIS project file"), + ".", tr("QGIS Project Files (*.qgs);;All files (*.*)", "Filter list for selecting files from a dialog box")); txtQgisFilePath->setText(qgisProjectFile); } @@ -187,8 +187,9 @@ bool QgsMapserverExport::write() // Check for file and prompt for overwrite if it exists if (QFile::exists(txtMapFilePath->text())) { - okToSave = QMessageBox::warning(0, "Overwrite File?", txtMapFilePath->text() + - " exists. \nDo you want to overwrite it?", "Yes", "No"); + okToSave = QMessageBox::warning(0, tr("Overwrite File?"), txtMapFilePath->text() + + tr(" exists. \nDo you want to overwrite it?", + "a filename is prepended to this text, and appears in a dialog box"), tr("Yes"), tr("No")); } if (okToSave == 0) {