Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Commit

Permalink
Make setEngineUrl method required for LibreTranslate and Lingva to work
Browse files Browse the repository at this point in the history
  • Loading branch information
VolkMilit authored Oct 12, 2021
1 parent 2712856 commit e2e22f8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
10 changes: 10 additions & 0 deletions src/qonlinetranslator.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -1890,6 +1890,11 @@ void QOnlineTranslator::buildLibreStateMachine()

void QOnlineTranslator::buildLibreDetectStateMachine()
{
Q_ASSERT_X(
!m_libreUrl.isEmpty(),
"buildLibreDetectStateMachine",
"The engine requires a URL, but it was not specified");

// States
auto *detectState = new QState(m_stateMachine);
auto *finalState = new QFinalState(m_stateMachine);
Expand Down Expand Up @@ -1918,6 +1923,11 @@ void QOnlineTranslator::buildLingvaStateMachine()

void QOnlineTranslator::buildLingvaDetectStateMachine()
{
Q_ASSERT_X(
!m_lingvaUrl.isEmpty(),
"buildLingvaDetectStateMachine",
"The engine requires a URL, but it was not specified");

// States
auto *detectState = new QState(m_stateMachine);
auto *finalState = new QFinalState(m_stateMachine);
Expand Down
11 changes: 5 additions & 6 deletions src/qonlinetranslator.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@ class QOnlineTranslator : public QObject
/**
* @brief Set the URL engine
*
* Affects only LibreTranslate and Lingva.
* Only affects LibreTranslate and Lingva because these engines have multiple instances.
* You need to call this function to specify the URL of an instance for them.
*
* @param engine engine
* @param url engine url
Expand Down Expand Up @@ -622,11 +623,9 @@ private slots:
QString m_errorString;

// Self-hosted engines settings
// LibreTranslate
QByteArray m_libreApiKey; // Doesn't require key for free instance
QString m_libreUrl = QStringLiteral("https://translate.argosopentech.com"); // One of the free instance
// Lingva
QString m_lingvaUrl = QStringLiteral("https://lingva.ml");
QByteArray m_libreApiKey; // Can be empty, since free instances ignores api_key param
QString m_libreUrl;
QString m_lingvaUrl;

QMap<QString, QVector<QOption>> m_translationOptions;
QMap<QString, QVector<QExample>> m_examples;
Expand Down

0 comments on commit e2e22f8

Please sign in to comment.