help_viewer_i18n.diff

Adjusted levels up to find translations. - Magnus Homann, 2007-02-25 02:00 PM

Download (2.4 KB)

View differences:

../src/helpviewer/main.cpp (arbetskopia)
1 1
#include <iostream>
2 2
#include <qapplication.h>
3 3
#include <qstring.h>
4
#include <QTextCodec>
5
#include <QTranslator>
4 6
#include "qgshelpserver.h"
5 7
#include "qgshelpviewer.h"
8
#include "qgsapplication.h"
6 9

  
7 10
int main( int argc, char ** argv )
8 11
{
9
  QApplication a( argc, argv );
12
  QgsApplication a( argc, argv, true );
10 13
  QString context = QString::null;
14
  QString myTranslationCode="";
15

  
11 16
  if(argc == 2)
12 17
  {
13 18
    context = argv[1];
14 19
  }
20
#ifdef Q_OS_MACX
21
  // If we're on Mac, we have the resource library way above us...
22
  QgsApplication::setPkgDataPath(QgsApplication::prefixPath()+"/../../../../share/qgis");
23
#endif
24

  
25
  QString i18nPath = QgsApplication::i18nPath();
26
  if (myTranslationCode.isEmpty())
27
  {
28
    myTranslationCode = QTextCodec::locale();
29
  }
30
#ifdef QGISDEBUG
31
  std::cout << "Setting translation to "
32
    << i18nPath.toLocal8Bit().data() << "/qgis_" << myTranslationCode.toLocal8Bit().data() << std::endl;
33
#endif
34

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

  
46
  /* Translation file for QGIS.
47
   */
48
  QTranslator qgistor(0);
49
  if (qgistor.load(QString("qgis_") + myTranslationCode, i18nPath))
50
  {
51
    a.installTranslator(&qgistor);
52
  }
53

  
15 54
  QgsHelpViewer w(context);
16 55
  w.show();
17 56

  
../src/helpviewer/CMakeLists.txt (arbetskopia)
6 6
     main.cpp
7 7
     qgshelpserver.cpp
8 8
     qgshelpviewer.cpp
9
     ../core/qgsapplication.cpp
10
     ../core/qgslogger.cpp
9 11
)
10 12

  
11 13
SET (HELP_UIS qgshelpviewerbase.ui)
......
30 32
ADD_EXECUTABLE (qgis_help MACOSX_BUNDLE ${HELP_SRCS} ${HELP_MOC_SRCS} ${HELP_UIS_H})
31 33

  
32 34
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
35
     ${CMAKE_CURRENT_SOURCE_DIR}/../core
33 36
     ${CMAKE_CURRENT_BINARY_DIR}
34 37
     ${SQLITE3_INCLUDE_DIR}
35 38
)