Skip to content

Commit f5dfd0c

Browse files
author
g_j_m
committedJan 3, 2007
Fix for ticket #500 (enable i18n for the mapserver export tool)
git-svn-id: http://svn.osgeo.org/qgis/branches/Release-0_8_0@6387 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent b65c115 commit f5dfd0c

File tree

2 files changed

+57
-9
lines changed

2 files changed

+57
-9
lines changed
 

‎tools/mapserver_export/ms_main.cpp

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,60 @@
1-
#include <qapplication.h>
1+
#include <QApplication>
2+
#include <QTranslator>
3+
#include <QTextCodec>
4+
#include <QStringList>
5+
26
#include "qgsmapserverexport.h"
7+
#include "src/core/qgsapplication.h"
8+
9+
#include <iostream>
10+
311
int main( int argc, char **argv )
412
{
5-
QApplication a( argc, argv );
6-
// Set up the QSettings environment must be done after qapp is created
13+
// Using QgsApplication instead of QApplication gives access to the
14+
// qgis translation files.
15+
QgsApplication a( argc, argv , true);
16+
17+
// Set up the QSettings environment must be done after a is created
718
QCoreApplication::setOrganizationName("QuantumGIS");
819
QCoreApplication::setOrganizationDomain("qgis.org");
920
QCoreApplication::setApplicationName("qgis");
1021

22+
// Install translations if available. Based on the code in the Qgis
23+
// main.cpp file.
24+
25+
// Let the user set the locale on the command line. If this program
26+
// needs to parse any more arguments, it'll be worthwhile using
27+
// something like getopt.
28+
QString translationCode;
29+
QStringList args = a.arguments();
30+
int i = args.lastIndexOf("-h");
31+
if (i != -1)
32+
{
33+
std::cout << "Usage: msexport [--lang language]\n"
34+
"\t[--lang language]\tuse language for interface text (optional)\n";
35+
exit(0);
36+
}
37+
38+
i = args.lastIndexOf("--lang");
39+
if (i != -1)
40+
{
41+
if (args.count() > i+1)
42+
translationCode = args[i+1];
43+
}
44+
45+
if (translationCode.isEmpty())
46+
translationCode = QTextCodec::locale();
47+
48+
QString i18nPath = QgsApplication::i18nPath();
49+
50+
QTranslator qttor;
51+
if (qttor.load("qt_" + translationCode, i18nPath))
52+
a.installTranslator(&qttor);
53+
54+
QTranslator mstor;
55+
if (mstor.load("qgis_" + translationCode, i18nPath))
56+
a.installTranslator(&mstor);
57+
1158
QgsMapserverExport *mse = new QgsMapserverExport();
1259
mse->show();
1360
return a.exec();

‎tools/mapserver_export/qgsmapserverexport.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,16 @@ QString QgsMapserverExport::baseName()
6767
// Choose the map file to create
6868
void QgsMapserverExport::on_btnChooseFile_clicked()
6969
{
70-
mapFile = QFileDialog::getSaveFileName(this, "Name for the map file",
71-
".", "MapServer map files (*.map);;All files(*.*)");
70+
mapFile = QFileDialog::getSaveFileName(this, tr("Name for the map file"),
71+
".", tr("MapServer map files (*.map);;All files(*.*)","Filter list for selecting files from a dialog box"));
7272
txtMapFilePath->setText(mapFile);
7373

7474
}
7575
// Chooose the project file to process
7676
void QgsMapserverExport::on_btnChooseProjectFile_clicked()
7777
{
78-
qgisProjectFile = QFileDialog::getOpenFileName(this, "Choose the QGIS project file",
79-
".", "QGIS Project Files (*.qgs);;All files (*.*)");
78+
qgisProjectFile = QFileDialog::getOpenFileName(this, tr("Choose the QGIS project file"),
79+
".", tr("QGIS Project Files (*.qgs);;All files (*.*)", "Filter list for selecting files from a dialog box"));
8080
txtQgisFilePath->setText(qgisProjectFile);
8181

8282
}
@@ -187,8 +187,9 @@ bool QgsMapserverExport::write()
187187
// Check for file and prompt for overwrite if it exists
188188
if (QFile::exists(txtMapFilePath->text()))
189189
{
190-
okToSave = QMessageBox::warning(0, "Overwrite File?", txtMapFilePath->text() +
191-
" exists. \nDo you want to overwrite it?", "Yes", "No");
190+
okToSave = QMessageBox::warning(0, tr("Overwrite File?"), txtMapFilePath->text() +
191+
tr(" exists. \nDo you want to overwrite it?",
192+
"a filename is prepended to this text, and appears in a dialog box"), tr("Yes"), tr("No"));
192193
}
193194
if (okToSave == 0)
194195
{

0 commit comments

Comments
 (0)
Please sign in to comment.