Search code examples
documentationdoxygenmultilingual

Multiple languages in doxygen docs (C++)


My client gave me unusual (and non-negotiable) requirement to provide them with dual-language (English and Polish) doxygen documentation from C++ code.

My first idea is to use conditional compilation for comments, like:

#if DOXYGEN_ENGLISH
/**
 * @brief Sample method
 */
#elif DOXYGEN_POLISH
/**
 * @brief Przykładowa metoda
 */
#endif
void foo();

Then run Doxygen twice with different base locale and predefined constant... and it actually works. But it's very cumbersome...

Have someone has an idea how can I improve this solution? Or solve it different way?


Solution

  • Doxygen has the build in command \~[langId] for handling different languages. The above presented example could be formulated as:

    /**
     * \~english @brief Sample method
     * \~polish @brief Przykladowa metoda
     */
    void foo();
    
    • no direct requirement using a preprocessor / pre-processor directives / settings
    • only one place in the doxygen configuration file to be changed (Doxyfile) when switching language.