Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
translationutils.h
Go to the documentation of this file.
1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef TRANSLATIONUTILS_H
5#define TRANSLATIONUTILS_H
6
7#include <QtCore/qhash.h>
8#include <QtCore/qjsonvalue.h>
9#include <QtCore/qstring.h>
10
12
13// Extracts key-value pairs from a JSON structure by finding an array with the given key.
14// Recursively searches the JSON value for the array, then extracts all string key-value
15// pairs from objects in that array. Handles both formats:
16// 1. Array of single-key objects: [{"k1":"v1"},{"k2":"v2"}]
17// 2. Array with multi-key object: [{"k1":"v1","k2":"v2"}]
18QHash<QString, QString> extractKeyValuePairs(const QJsonValue &jval, const QString &arrayKey);
19
20// Extracts key to string-list pairs from a JSON structure for plural translations.
21// Expects format: [{"source1":["form1","form2"]},{"source2":["form1","form2"]}]
22QHash<QString, QStringList> extractPluralTranslations(const QJsonValue &jval,
23 const QString &arrayKey);
24
25// Returns the system prompt used for translation requests.
27
28// Returns the system prompt used for plural translation requests.
30
31QT_END_NAMESPACE
32
33#endif // TRANSLATIONUTILS_H
[0]
Definition lalr.h:84
const TranslatorMessage * msg
QList< Batch > makeBatches(const Messages &messages, const QString &userContext) const override
Definition ollama.cpp:30
QUrl translationEndpoint() const override
Definition ollama.cpp:174
void onRequestRejected() override
Definition ollama.cpp:184
QUrl discoveryEndpoint() const override
Definition ollama.cpp:179
QStringList extractModels(const QByteArray &data) const override
Definition ollama.cpp:110
QByteArray payload(const Batch &b) const override
Definition ollama.cpp:124
~Ollama() override
std::optional< QByteArray > stageModel(const QString &modelName) override
Definition ollama.cpp:149
void setUrl(const QString &url) override
Definition ollama.cpp:169
QHash< QString, QStringList > extractTranslations(const QByteArray &response, bool plural) override
Definition ollama.cpp:77
Combined button and popup list for selecting options.
QHash< QString, QStringList > extractPluralTranslations(const QJsonValue &jval, const QString &arrayKey)
QString translationSystemPrompt()
QString pluralTranslationSystemPrompt()