oxen-core/translations/translation_files.cpp.in
Jason Rhinelander da400f6d66 Rewrite translation file generation using cmake
This makes three big changes to how translation files are generated:

- use Qt5 cmake built-in commands to do the translations rather than
calling lrelease directly.  lrelease is often not in the path, while Qt5
cmake knows how to find and invoke it.

- Slam the resulting files into a C++ file using a cmake script rather
than needing to compile a .c file to generate C++ file.  This is
simpler, but more importantly avoids the mess needed when cross
compiling of having to import a cmake script from an external native
build.

- In the actual generated files, use an unordered_map rather than a
massive list of static variable pointers.
2020-06-15 12:49:33 -03:00

17 lines
387 B
C++

#include <string>
#include <unordered_map>
using namespace std::literals;
static std::unordered_map<std::string, std::string> _translation_files{
@TRANSLATION_FILES@
};
bool find_embedded_file(const std::string &name, std::string &data) {
auto it = _translation_files.find(name);
if (it != _translation_files.end()) {
data = it->second;
return true;
}
return false;
}