Localizations for xiaoning's diary

At the moment Xiaoning's Diary is translated to 3 languages Translating program for other languages should be quite simple task and only text editor of some sort is needed for this. The next chapters will tell some more about this.

Localization for user interface

Localization of UI is done with sort of language-pack files that can be found from languagepacks-folder. These files are just usual text files that define what to write in different components in user interface. Since the language packs are just usual text files, anyone should be able to translate the program to a new language without any special software. Only text editor is needed.


By default xiaoning's diary comes with translations to Chinese, English and Finnish so I will use them as an example here. If you check the languagepacks-folder you can find following files from there

Each line of the file defines one translation/property. The basic structure of the line is [name of property] = [value]. There can be also freely written comments after the property.


#copying files dialog strings
COPYING_SELECTED_FILES_STOP_BUTTON_TEXT = "Stop" #text for stop button
COPYING_SELECTED_FILES_HIDE_BUTTON_TEXT = "Hide" #text for hide button

Here the first line is a comment. In second line COPYING_SELECTED_FILES_DIALOG_TITLE_TEXT is the name of property and Copying selected files... is the value. On third and fourth line we also have a comment at the end.

For most part translation is done simply translating the texts (value) of each property. There is one exception and it is the APP_LOCALE property. This number affects on the locale used in calendar so if the calendar seems wrong, it means this number is set wrong. The numbers that can be used can be found from http://doc.trolltech.com/4.5/qlocale.html#Language-enum. You need to choose the one that is best match for your language. Also unlike all other lines, there's no ""-marks around this value (Something related to my implementation of the parser. This is an integer, not a string and therefore treated differently).

Getting it listed in language change dialog

The first line in the file defines the name for the language. If you check the language-pack files for Chinese, English, and Finnish these lines are as listed below.

LANG_NAME = "中文" #Will be used when constructing list of available languages from which to choose from.


LANG_NAME = "English" #Will be used when constructing list of available languages from which to choose from.


LANG_NAME = "Suomi" #Will be used when constructing list of available languages from which to choose from.

The LANG_NAME-property is used when listing the available languages in language change dialog

The locale strings listed in the dialog come from the name of the language-pack file. For example Chinese language-pack is called M_DIARY_LANG_PCK_zh_CN.DLN → zh_CN is cut from the name of the file. One thing that should be noted when creating a new language-pack is that the file must be named like this: M_DIARY_LANG_PCK_[locale].DLN. This is because Xiaoning's diary will use the filenames of the files it finds from languagepacks-folder to determine whether they are language-packs or not.

After the file is named correctly and placed in languagepacks-folder, it will be listed in language change dialog. English will be used if there is some problems with loading the selected language. This will work even if there's no language-pack for English available because the English translation is hard-coded in to the program, the English language-pack is provided only for an example to make the translation for other languages little easier.

Localization for help and about

To translate the help and about for Xiaoningn's Diary you need to translate the HTML files that are in help- and about-folders. By default there is translation only for English and this can be found from sub folder called en_GB. The name of the sub folder is used to determine to what locale the translation belongs to. The name of the sub folder must be the same as the locale taken from the language-pack file (M_DIARY_LANG_PCK_[locale].DLN so for example sub folder called en_GB holds the help/about file that belongs to M_DIARY_LANG_PCK_en_GB.DLN, if I were to create one for Finnish, it would go to sub folder called fi_FI etc. ). English is used if there is no file specific for currently used language and if English is missing a lot of complains will be shown.

The HTML-files placed in the sub folders must be named just as HELP.html and ABOUT.html.