OpenCOR is a multi-lingual application currently supporting both English and French. By default, OpenCOR will try to use the system language. If the system language is not supported, then English will be used instead. Alternatively, any of the languages supported by OpenCOR can be used.

OpenCOR

When it comes to OpenCOR itself, there are two sets of language files to consider:

  1. Qt-specific translation files: these files are originally located under [Qt]/[QtVersion]/[Compiler]/translations/qt_xx.qm with xx the language code (e.g. fr for French). So, for every language supported by OpenCOR (except for English which is natively supported by Qt), we need to add the corresponding file to [OpenCOR]/res. Then, an entry for that file must be added to [OpenCOR]/res/ui.qrc:
    <file alias="qt_xx">qt_xx.qm</file>
  2. OpenCOR-specific translation files: for each supported language (again, except for English), a file called [OpenCOR]/i18n/OpenCOR_xx.ts must be created. The best way to go about it is by starting from an existing language file (e.g. [OpenCOR]/i18n/OpenCOR_fr.ts). From there, locate the following line:
    <TS version="2.0" language="xx_XX" sourcelanguage="en_GB">
    and replace xx_XX accordingly. Otherwise, as for the Qt-specific file above, an entry for the OpenCOR-specific file must be added to [OpenCOR]/res/ui.qrc:
    <file alias="app_xx">../build/OpenCOR_xx.qm</file>
    OpenCOR_xx.qm gets automatically generated from OpenCOR_xx.ts when building OpenCOR. This does, however, require updating [OpenCOR]/cmake/common.cmake as follows:
    MACRO(UPDATE_LANGUAGE_FILES TARGET_NAME)
        ...
        SET(LANGUAGE_FILES
            ...
            ${TARGET_NAME}_xx
            ...
        )
        ...
    )

On the user interface (UI) side, both an action and a menu item exist for each supported language. The best way to add UI support for a new language is by mimicking what has been done for actionEnglish in [OpenCOR]/src/mainwindow.ui. Then, a similar mimicking work must be done in [OpenCOR]/src/mainwindow.cpp and [OpenCOR]/src/mainwindow.h by looking up both actionEnglish and EnglishLocale.

Plugins

A file called [Plugin]_xx.ts must be created for each plugin that requires internationalisation and it must be located in [Plugin]/i18n (e.g. [OpenCOR]/src/plugins/misc/Core/i18n/Core_fr.ts). A [Plugin].qrc file must also be created and placed in [Plugin]/res (e.g. [OpenCOR]/src/plugins/misc/Core/res/Core.qrc).