-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
Qt Creator 17.0.0
-
None
When trying to add translations to cristianadam/llama.qtcreator: Local LLM-assisted text completion for Qt Creator. I noticed that I needed the path to my translations directory in order to tell QTranslator to load the translation.
I ended up having something like:
static FilePath scanForTranslation(const QString &translationFile) { const FilePaths &pluginPaths = ExtensionSystem::PluginManager::pluginPaths(); for (const FilePath &plugin : pluginPaths) { const FilePaths pluginFolders = plugin.dirEntries( FileFilter({}, QDir::Dirs | QDir::NoDotAndDotDot)); for (const FilePath &folder : pluginFolders) { FilePath translationDir = folder / (HostOsInfo::isMacHost() ? QString("Qt Creator.app/Contents/Resources") : QString("share/qtcreator")) / "translations"; if (!translationDir.dirEntries({{translationFile}, QDir::Files | QDir::NoDotAndDotDot}) .isEmpty()) return translationDir.pathAppended(translationFile); } } return FilePath(); }
I think it would be faster and easier if the plugin had the knowledge where it was installed.
The alternative would be to use a qrc file to have the translations inside the plugin binary itself...