I was translating a widget library written in Qt when I got the following error.
[ 44%] Generating foo_fr.ts
Bar.cpp:40: Qualifying with unknown namespace/class ::Bar
Updating 'foo_fr.ts'...
Found 3 source text(s) (3 new and 0 already existing)
I could not find a lot of info about this error on the internet. Luckily, I ran across this post on StackOverflow that guided me toward a solution.
The problem came from the way the library was designed. Its public header files are not in the same directory as its implementation files.
Foo
|-- include
| '-- foo
| '-- Bar.hpp
+-- src
| |-- Bar.cpp
| +-- CMakeLists.txt
+-- CMakeLists.txt
This poses a problem because Qt's translation utilities expect the header
files to be in the same directory as their implementation files. In case they
are not, one must specify their directory when calling lupdate. Since
the library I was translating uses CMake as its build
tool, this is done using the qt5_create_translation macro and adding the
-I flag with the header files path to the OPTIONS parameter.
# Foo/src/CMakeLists.txt
qt5_create_translation(QM_FILES
Bar.cpp
foo_fr.ts
OPTIONS -I ${CMAKE_CURRENT_SOURCE_DIR}/../include
)