Skip to content

feat(translator): add configurable DeepLX-like backend#729

Draft
RanderDouble wants to merge 3 commits into
noctalia-dev:mainfrom
RanderDouble:feat/translator-deeplx-like-backend
Draft

feat(translator): add configurable DeepLX-like backend#729
RanderDouble wants to merge 3 commits into
noctalia-dev:mainfrom
RanderDouble:feat/translator-deeplx-like-backend

Conversation

@RanderDouble
Copy link
Copy Markdown

Summary

This PR adds a minimal DeepLX-like API backend option to the Translator plugin.

Changes

  • add a new DeepLX-like API backend in plugin settings
  • add configurable API URL and optional API Key fields
  • send custom backend translation requests as POST JSON
  • attach Authorization: Bearer <token> when an API key is provided
  • support parsing either data or translations[0].text from the response
  • include backend and API URL in the cache key to avoid stale cached results
    after switching backends
  • document DeepLX-like configuration in the plugin README

Motivation

The current Google backend relies on an unofficial endpoint and may fail due to
rate limiting or anti-abuse checks.

This change adds support for self-hosted DeepLX-like endpoints while keeping the
implementation small and preserving the existing Google and DeepL backends.

Notes

  • existing google and deepl backends are unchanged
  • for DeepLX instances using query-token auth, the token can be included directly
    in the configured API URL

@github-actions
Copy link
Copy Markdown
Contributor

@Cleboost - this PR modifies your plugin. Please review when you have a chance.

@github-actions
Copy link
Copy Markdown
Contributor

Automatic Code Quality Review


File: translator/LauncherProvider.qml

  • (L) Line 145: When it comes to translations there is no need for fallback values. From: pluginApi?.tr("example") || "value". To: pluginApi?.tr("example")
+        return fallback || (pluginApi?.tr("messages.connectionError") || "Connection error");
  • (L) Line 276: When it comes to translations there is no need for fallback values. From: pluginApi?.tr("example") || "value". To: pluginApi?.tr("example")
+                            callback(null, pluginApi?.tr("messages.error") || "Translation error");
  • (L) Line 279: When it comes to translations there is no need for fallback values. From: pluginApi?.tr("example") || "value". To: pluginApi?.tr("example")
+                        callback(null, pluginApi?.tr("messages.error") || "Translation error");

File: translator/Settings.qml

  • (H) Line 57: Use translations instead of hardcoded text. Instead of: "Example Label". To: pluginApi?.tr("panel.example-label")
+        label: "API URL"
  • (L) Line 66: When it comes to translations there is no need for fallback values. From: pluginApi?.tr("example") || "value". To: pluginApi?.tr("example")
+        label: pluginApi?.tr("settings.apiKey-label") || "API Key"

@github-actions
Copy link
Copy Markdown
Contributor

Automatic Code Quality Review


File: translator/LauncherProvider.qml

  • (L) Line 235: When it comes to translations there is no need for fallback values. From: pluginApi?.tr("example") || "value". To: pluginApi?.tr("example")
+                    callback(null, pluginApi?.tr("messages.invalidApiKey") || "Invalid API Key");

@RanderDouble
Copy link
Copy Markdown
Author

Addressed the i18n review feedback.

Changes in this update:

  • removed the new hardcoded API URL label
  • removed the new translation fallbacks introduced in the DeepLX-like backend
    changes
  • kept the error handling scoped to the existing generic messages plus
    missingApiUrl
  • added localized strings for the new DeepLX-like settings fields and missing URL
    message

Copy link
Copy Markdown
Contributor

@Cleboost Cleboost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks <3

Copy link
Copy Markdown
Collaborator

@spiros132 spiros132 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor feedback otherwise it lgtm :)


function getErrorMessage(status, fallback) {
return fallback || pluginApi?.tr("messages.connectionError");
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused why this is needed.

@spiros132 spiros132 marked this pull request as draft April 25, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants