Skip to content

Commit

Permalink
Added translation support to help viewer
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@7107 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Jul 27, 2007
1 parent c65d67f commit ac34ad2
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/helpviewer/CMakeLists.txt
Expand Up @@ -6,6 +6,8 @@ SET (HELP_SRCS
main.cpp
qgshelpserver.cpp
qgshelpviewer.cpp
../core/qgsapplication.cpp
../core/qgslogger.cpp
)

SET (HELP_UIS qgshelpviewerbase.ui)
Expand All @@ -30,13 +32,15 @@ QT4_WRAP_CPP (HELP_MOC_SRCS ${HELP_MOC_HDRS})
ADD_EXECUTABLE (qgis_help MACOSX_BUNDLE ${HELP_SRCS} ${HELP_MOC_SRCS} ${HELP_UIS_H})

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../core
${CMAKE_CURRENT_BINARY_DIR}
${SQLITE3_INCLUDE_DIR}
)

TARGET_LINK_LIBRARIES(qgis_help
${QT_LIBRARIES}
${SQLITE3_LIBRARY}
qgis_core
)


Expand Down
43 changes: 41 additions & 2 deletions src/helpviewer/main.cpp
@@ -1,17 +1,56 @@
#include <iostream>
#include <qapplication.h>
#include <qgsapplication.h>
#include <qstring.h>
#include <QTextCodec>
#include <QTranslator>
#include "qgshelpserver.h"
#include "qgshelpviewer.h"
#include "qgsapplication.h"

int main( int argc, char ** argv )
{
QApplication a( argc, argv );
QgsApplication a( argc, argv, true );
QString context = QString::null;
QString myTranslationCode="";

if(argc == 2)
{
context = argv[1];
}
#ifdef Q_OS_MACX
// If we're on Mac, we have the resource library way above us...
a.setPkgDataPath(QgsApplication::prefixPath()+"/../../../../share/qgis");
#endif

QString i18nPath = QgsApplication::i18nPath();
if (myTranslationCode.isEmpty())
{
myTranslationCode = QTextCodec::locale();
}
#ifdef QGISDEBUG
std::cout << "Setting translation to "
<< i18nPath.toLocal8Bit().data() << "/qgis_" << myTranslationCode.toLocal8Bit().data() << std::endl;
#endif

/* Translation file for Qt.
* The strings from the QMenuBar context section are used by Qt/Mac to shift
* the About, Preferences and Quit items to the Mac Application menu.
* These items must be translated identically in both qt_ and qgis_ files.
*/
QTranslator qttor(0);
if (qttor.load(QString("qt_") + myTranslationCode, i18nPath))
{
a.installTranslator(&qttor);
}

/* Translation file for QGIS.
*/
QTranslator qgistor(0);
if (qgistor.load(QString("qgis_") + myTranslationCode, i18nPath))
{
a.installTranslator(&qgistor);
}

QgsHelpViewer w(context);
w.show();

Expand Down

0 comments on commit ac34ad2

Please sign in to comment.