Difference between revisions of "Slicer4:Internationalization of Slicer"

From Slicer Wiki
Jump to: navigation, search
(Moved to github)
Tags: 2017 source edit, Replaced
 
(15 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
[[Slicer4:Developers| Back to Slicer 4 Developers]]
 
[[Slicer4:Developers| Back to Slicer 4 Developers]]
  
=Introduction=
+
{{documentation/banner
 
+
| text  = [https://github.com/Slicer/Slicer/wiki/I18N This page has been moved to GitHub.]
This pages contains notes on source code additions and modifications of different modules within Slicer for the internationalization purpose.
+
| background-color = 8FBC8F }}
=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);
 
    }
 
 
 
=Scripted Module=
 
Some modules are implemented in Python. Endoscopy is one of the typical examples. In endoscopy.py, if we change the code in line#10
 
    parent.titel = “Endoscopy”
 
to
 
    parent.title = slicer.app.translate(self.__class__.__name__, "Endoscopy")
 
then "Endoscopy" can be shown in other languages.Similarily, other displayable strings can be handled in the same way.
 

Latest revision as of 12:53, 28 September 2021

Home < Slicer4:Internationalization of Slicer