Generating and loading localization files

Provides the step-by-step instructions to generate the localization files and load them to the applications.


The following steps will guide you to generate the localization files and load them to the applications.


Localization using the Vanilla Qt and Qt product (QtP) differs to some extent. So you must determine the Qt version being used to build your application before localizing.

The following table lists the differences between Vanilla Qt v4.8 and QtP:

Vanilla Qt v4.8 QtP
lupdate.exe generates the translation files for each locale. The files are named as, <application name>_<locale>.ts. For example, the translation files for chatapp supporting English and French locales will be named as chatapp_en.ts and chatapp_fr.ts. The translation files are available by default and are named randomly.
Qmake parses the translation files and generates an ID for each language supported, based on an internal mapping table. Qmake loads the symbian_i18n.prf and generates an ID for each supported language, based on modified internal mapping table. More languages are added to the table from system_languages.ini.
The language IDs are added to the .mmp file using the LANG keyword. The LANGUAGE_IDS variable is used to include the language IDs in the resource file section of the .mmp file.

Note: The

LANGUAGE_IDS variable is defined in the bldpublic.hrh.
Qmake parses the short and long captions in the translation files for all supported languages and generates a localization file (.loc), <appname>.loc. For example, if the application name is chatapp, the localization file name would be chatapp.loc. Qmake parses the short and long captions in the translation files for all the supported languages and generates a random.loc file, which includes the localization file for each language.
The resource file (.rss) includes the localization file containing the short and long captions for all the supported languages. The resource file (.rss) includes the random.loc file, which contains the localization file for each supported language.
Qmake extra compiler can be used to convert the translation files (.ts) to qmake files (.qm). The ts2qm.flm config file can be used with SBS to convert the translation files (.ts) to qmake files (.qm).


  1. Export all the translation files for the supported languages to /epoc32/include/platform/qt/translations

    You can export the translation files by adding their source and destination locations in the MMP file under the PRJ_EXPORTS section.

  2. List the translation files in the .pro file using the SYMBIANTRANSLATIONSFILES keyword within the symbian block.

    Note: You can reset the translation files if your language sets are different from the ones provided by the platform.

    For example, the .pro file for the chatapp would look like:
    symbian: {
  3. Add the load(loc) keyword right after the SYMBIANTRANSLATIONSFILES keyword in the .pro file.

  4. Load the localization files to the Qt/QML application using QTranslator.

    Use one QTranslator class instance for each localization file.


    QApplication app(argc, argv);
    QTranslator translator;
    QChar driveLetter = app.applicationFilePath().at(0);
    QString path_to_translations = QString(driveLetter) + ":/resource/qt/translations";
    translator.load("tsfilename_" + QLocale::system().name(), path_to_translations);

    You can get path_to_translations (= \resource\qt\translations) by calling QLibraryInfo::location(QLibraryInfo::TranslationsPath), or hard coding it.

    translator.load("tsfilename_" + QLocale::system().name(), "z:/resource/qt/translations");

    But there is a small problem with drive letter. Qt is requiring it to path definition and QLibraryInfo does not return it. And actually it might not be good idea to hard code letter from IAD point of view. But luckily there is a way to circumvent this by using applicationFilePath information and getting drive letter from it. Like this:

    QChar driveLetter = app.applicationFilePath().at(0);
    QString path = QString(driveLetter) + ":/resource/qt/translations";

    If application has multiple localization files, those must be loaded to multiple QTranslator s respectively.

    QTranslator translator;
    translator.load("appname_" + QLocale::system().name(), "Z:/resource/qt/translations");
    QTranslator translator2;
    translator2.load("another_" + QLocale::system().name(), "Z:/resource/qt/translations");

    Note that in case you don't have any application instance but you need localization in DLL, you should create QTranslator with new so that it's available during the whole lifetime of process.

    QTranslator *translator = new QTranslator();

    For more information, see Qt translation loading.


The loaded localized resources enable the application to display the appropriate captions as and when the device language changes.