Slicer4:Internationalization of Slicer

From Slicer Wiki
Revision as of 15:24, 8 August 2011 by Lpfang (talk | contribs)
Jump to: navigation, search
Home < Slicer4:Internationalization of Slicer

Back to Slicer 4 Developers

Introduction

This pages contains notes on source code additions and modifications of different modules within Slicer for the internationalization purpose.

QT-based Internationalization

Internationalization is well supported in QT. A lot of modules of Slicer are developed on QT. This has set a good ground for the internationalization of Slicer. The following codes are needed:

In file \Slicer4\Base\QTCore\qSlicerCoreApplication.h, add the following line:

   #include <QTranslator>

In file \Slicer4\Applications\SlicerQT\main.cxx (around line#230), add the following lines:

   static QTranslator* translator;
   if (translator != NULL)
   {
       qApp->removeTranslator(translator);
       delete translator;
       translator = NULL;
   }
   QString langCode= argv[1];
   translator = new QTranslator;
   QString qmFilename = "lang_" + langCode; 
   if (translator->load(qmFilename))
   {
       qApp->installTranslator(translator);
   }