This document provides detailed instructions on how to manage multi-language support in the Doxywizard application.
Overview
Doxywizard uses Qt's internationalization (i18n) framework, implementing multi-language support through the QCoreApplication::translate() function and Qt Linguist tools. Translation files use XML format .ts files, which are compiled into .qm files and embedded in the application resources.
Translation File Structure
Translation files are located in the translations/ directory:
addon/doxywizard/translations/
doxywizard_zh_CN.ts # Main UI translation (Simplified Chinese)
doxywizard_zh_TW.ts # Main UI translation (Traditional Chinese)
doxywizard_de.ts # Main UI translation (German)
doxywizard_fr.ts # Main UI translation (French)
doxywizard_ja.ts # Main UI translation (Japanese)
doxywizard_ko.ts # Main UI translation (Korean)
doxywizard_es.ts # Main UI translation (Spanish)
doxywizard_ru.ts # Main UI translation (Russian)
Translation Contexts
There are several sections in the translation files, here is an overview of the purpose of each section.
| Context | File Location | Purpose |
| MainWindow | doxywizard.cpp | Main wizard interface text |
| Expert | expert.cpp | Expert mode interface and dynamic content |
| Messages | doxywizard.cpp | Topic names and format labels |
| Wizard | wizard.cpp | Wizard step labels |
| Step1 | wizard.cpp | Step1 dialog labels |
| Step2 | wizard.cpp | Step2 dialog labels |
| Step3 | wizard.cpp | Step3 dialog labels |
| Step4 | wizard.cpp | Step4 dialog labels |
| TuneColorDialog | wizard.cpp | Color tuning dialog labels |
| InputString | inputstring.cpp | String input control |
| InputStrList | inputstrlist.cpp | String list input control |
| HelpLabel | helplabel.h | Label with context menu |
Configuration Option Translations
Configuration option are translated via a language specific version of config.xml
src/
config.xml # Original English configuration
src/translations/
config_zh_CN.xml # Simplified Chinese configuration
config_zh_TW.xml # Traditional Chinese configuration
config_de.xml # German configuration
...
These config files are directly included by Doxywizard and used to show the translated documentation for each option.
Note that obsolete options and documentation in config.xml that is meant for the manual or Doxyfile are not included in the config_xx.xml translation files.
Syncing Localized Config Files
When the original config.xml is updated (options added or removed), you need to sync the localized config files. The configgen.py with option -sync provides two modes:
Report Mode (default): Only reports differences without modifying files:
cd src
python3 configgen.py -sync config.xml translations
Auto-Sync Mode: Automatically adds missing options and removes extra options:
cd src
python3 configgen.py -sync config.xml translations --auto
The -sync command will:
- Read all option IDs from the original config.xml
- Compare with each localized translatos/config_xx.xml file
- Report missing options (exist in original but not in localized)
- Report extra options (exist in localized but not in original)
- In auto-sync mode: automatically add missing options and remove extra options
- Note
- In auto-sync mode, a backup file (.bak) is created before modification
- Added options use the original English documentation; you need to translate them manually
- Existing synchronized options are not modified
Translation File Format
Dynamic content uses the Expert context with %1 placeholders:
<context>
<name>Expert</name>
<message>
<source>Possible values are:</source>
<translation>Mögliche Werte sind:</translation>
</message>
<message>
<source>and</source>
<translation>und</translation>
</message>
<message>
<source>Minimum value: %1, maximum value: %2, default value: %3.</source>
<translation>Mindestwert: %1, Höchstwert: %2, Standardwert: %3.</translation>
</message>
<message>
<source>The default value is: <code>%1</code>.</source>
<translation>Der Standardwert ist: <code>%1</code>.</translation>
</message>
</context>
- Note
- In XML files, <code> tags need to be escaped as <code> and </code>.
Adding New Language Support
Required Files
Adding a new language requires creating or modifying the following files:
| File | Description |
| addon/doxywizard/translationmanager.cpp | Register the new language in languageTable |
| addon/doxywizard/translations/doxywizard_xx.ts | Translation source file for user interface |
| src/translations/config_xx.xml | Localized configuration option documentation |
Detailed Steps
Step 1: Create Translation Source File
- Copy existing translation file as template:
cp translations/doxywizard_zh_CN.ts translations/doxywizard_xx.ts
Where xx is the language code (e.g., pt for Portuguese, it for Italian)
- Modify the language attribute in the file header:
<TS version="2.1" language="xx">
- Translate all text within the <translation> tags
Step 2: Register New Language
Add the new language in translationmanager.cpp:
static const std::array languageTable = {
{ "en", "English", "English" },
{ "xx", "Native Name", "English Name" }
};
Step 3: Create Localized Config File
If you want to use localized config files:
- Copy an existing config file:
cp src/translations/config_de.xml src/translations/config_xx.xml
- Translate the documentation strings within <docs> elements
Language Code Standards
Use ISO 639-1 language codes, and ISO 3166-1 country codes for regional variants.
Authoritative References:
| Code | Language |
| zh_CN | Simplified Chinese |
| zh_TW | Traditional Chinese |
| de | German |
| fr | French |
| ja | Japanese |
| ko | Korean |
| es | Spanish |
| ru | Russian |
Modifying Individual String Translations
Translation File Structure
Translation files (.ts) use XML format:
<context>
<name>ClassName</name>
<message>
<source>Original English Text</source>
<translation>Translated Text</translation>
</message>
</context>
Direct Edit of .ts File
- Open the corresponding doxywizard_xx.ts file
- Find the <message> entry to modify
- Modify the text within the <translation> tag
- Save the file
Important Notes
- Preserve Placeholders: If the original text contains %1, %2, etc. placeholders, they must be preserved in the translation
<source>Language changed to: %1</source>
<translation>Language changed to: %1</translation>
- Escape Special Characters: XML special characters need to be escaped
| Character | Escape Sequence |
| < | < |
| > | > |
| & | & |
| ' | ' |
| " | " |
- HTML Tag Escaping: In .ts files, HTML tags must be escaped:
| Original | Escaped |
| <code> | <code> |
| </code> | </code> |
| <br/> | <br/> |
- Maintain Consistency: The same term should use the same translation in different places
- Translation Status: Ensure there is no type="unfinished" attribute after translation
Adding New Strings in Doxywizard
Adding UI Strings
Step 1: Use tr() in Code
Use the tr() function for strings that need translation:
QLabel *label = new QLabel("Some Text");
QLabel *label = new QLabel(tr("Some Text"));
Step 2: Update Translation Files
The CMake build system automatically extracts translatable strings during the build process. After adding new tr() calls, rebuild the project to update the .ts files.
Step 3: Translate New Strings
Translate the newly added strings in each language's .ts file.
Common Issues and Solutions
Translations Not Displaying
Problem: After switching languages, some text still shows in English
Causes:
- retranslateUi() not called
- String not wrapped with tr() function
- Translation missing in .ts file
Solutions:
- Ensure strings are wrapped with tr()
- Check if the translation exists in the .ts file
- Ensure retranslateUi() is called when switching languages
Dynamic Content Not Displaying
Problem: Minimum value, maximum value, default value not showing in non-English languages
Causes:
- Missing Expert context translations in main translation file
- HTML tags not properly escaped in translation strings
Solutions:
- Ensure Expert context exists in doxywizard_xx.ts
- Escape HTML tags: use <code> instead of <code>
- Use %1 placeholders for dynamic values
Go to the next section or return to the
index.