[office/crow-translate] src: Localize user-facing OCR merge strings and expose accessible names

Mauritius Clemens <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit b0290b82b40691cf64fe820aa384efa28403708d by Mauritius Clemens.
Committed on 17/08/2026 at 21:45.
Pushed by pillowtrucker into branch 'master'.

Localize user-facing OCR merge strings and expose accessible names

M  +0    -11   src/mainwindow.cpp
M  +51   -0    src/mainwindow.ui
M  +3    -3    src/ocr/llmocr.cpp
M  +27   -0    src/popupwindow.ui
M  +1    -1    src/settings/appsettings.cpp
M  +8    -2    src/settings/settingsdialog.cpp

https://invent.kde.org/office/crow-translate/-/commit/b0290b82b40691cf64fe820aa384efa28403708d

diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 2f87b005..e6a06cb5 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -92,17 +92,6 @@ MainWindow::MainWindow(QWidget *parent)
         m_engineItemsIcons.append(ui->engineComboBox->itemIcon(i));
     }
 
-    // Accessible names for assistive technology and automated UI testing (AT-SPI/UIA/AX
-    // report the widget's text content or nothing at all without these, since Qt doesn't
-    // default an accessible name from objectName())
-    ui->sourceEdit->setAccessibleName(QStringLiteral("sourceEdit"));
-    ui->translationEdit->setAccessibleName(QStringLiteral("translationEdit"));
-    ui->translateButton->setAccessibleName(QStringLiteral("translateButton"));
-    ui->abortButton->setAccessibleName(QStringLiteral("abortButton"));
-    ui->sourcePlayPauseButton->setAccessibleName(QStringLiteral("sourcePlayPauseButton"));
-    ui->translationPlayPauseButton->setAccessibleName(QStringLiteral("translationPlayPauseButton"));
-    ui->openImageButton->setAccessibleName(QStringLiteral("openImageButton"));
-
     // Screen orientation
     connect(m_orientationWatcher, &ScreenWatcher::screenOrientationChanged, this, &MainWindow::setOrientation);
 
diff --git a/src/mainwindow.ui b/src/mainwindow.ui
index 22443f37..46e5afa6 100644
--- a/src/mainwindow.ui
+++ b/src/mainwindow.ui
@@ -25,6 +25,9 @@
           <verstretch>0</verstretch>
          </sizepolicy>
         </property>
+        <property name="accessibleName">
+         <string>Translate</string>
+        </property>
         <property name="toolTip">
          <string>Translate</string>
         </property>
@@ -35,6 +38,9 @@
       </item>
       <item row="1" column="1">
        <widget class="QToolButton" name="swapButton">
+        <property name="accessibleName">
+         <string>Swap languages</string>
+        </property>
         <property name="toolTip">
          <string>Swap languages</string>
         </property>
@@ -48,6 +54,9 @@
         <property name="tabChangesFocus">
          <bool>true</bool>
         </property>
+        <property name="accessibleName">
+         <string>Source</string>
+        </property>
         <property name="placeholderText">
          <string>Source</string>
         </property>
@@ -68,6 +77,9 @@
         <property name="enabled">
          <bool>false</bool>
         </property>
+        <property name="accessibleName">
+         <string>Cancel</string>
+        </property>
         <property name="toolTip">
          <string>Cancel</string>
         </property>
@@ -80,6 +92,9 @@
        <layout class="QHBoxLayout" name="sourceButtonsLayout">
         <item>
          <widget class="QToolButton" name="sourcePlayPauseButton">
+          <property name="accessibleName">
+           <string>Start/pause saying the source text aloud</string>
+          </property>
           <property name="toolTip">
            <string>Start/pause saying the source text aloud</string>
           </property>
@@ -128,6 +143,9 @@
         </item>
         <item>
          <widget class="QToolButton" name="sourceStopButton">
+          <property name="accessibleName">
+           <string>Stop saying the source text aloud</string>
+          </property>
           <property name="toolTip">
            <string>Stop saying the source text aloud</string>
           </property>
@@ -138,6 +156,9 @@
         </item>
         <item>
          <widget class="QToolButton" name="copySourceButton">
+          <property name="accessibleName">
+           <string>Copy source text to the clipboard</string>
+          </property>
           <property name="toolTip">
            <string>Copy source text to the clipboard</string>
           </property>
@@ -148,6 +169,9 @@
         </item>
         <item>
          <widget class="QToolButton" name="openImageButton">
+          <property name="accessibleName">
+           <string>Recognize text in an image file</string>
+          </property>
           <property name="toolTip">
            <string>Recognize text in an image file</string>
           </property>
@@ -158,6 +182,9 @@
         </item>
         <item>
          <widget class="QToolButton" name="delayedRecognizeScreenAreaButton">
+          <property name="accessibleName">
+           <string>Recognize screen area with delay</string>
+          </property>
           <property name="toolTip">
            <string>Recognize screen area with delay</string>
           </property>
@@ -183,6 +210,9 @@
       </item>
       <item row="2" column="1">
        <widget class="QToolButton" name="clearButton">
+        <property name="accessibleName">
+         <string>Clear</string>
+        </property>
         <property name="toolTip">
          <string>Clear</string>
         </property>
@@ -207,6 +237,9 @@
         <property name="styleSheet">
          <string notr="true"/>
         </property>
+        <property name="accessibleName">
+         <string>Translation</string>
+        </property>
         <property name="readOnly">
          <bool>true</bool>
         </property>
@@ -219,6 +252,9 @@
        <layout class="QHBoxLayout" name="translationButtonsLayout">
         <item>
          <widget class="QToolButton" name="translationPlayPauseButton">
+          <property name="accessibleName">
+           <string>Start/pause saying the translated text aloud</string>
+          </property>
           <property name="toolTip">
            <string>Start/pause saying the translated text aloud</string>
           </property>
@@ -267,6 +303,9 @@
         </item>
         <item>
          <widget class="QToolButton" name="translationStopButton">
+          <property name="accessibleName">
+           <string>Stop saying the translated text aloud</string>
+          </property>
           <property name="toolTip">
            <string>Stop saying the translated text aloud</string>
           </property>
@@ -357,6 +396,9 @@
         </item>
         <item>
          <widget class="QToolButton" name="copyTranslationButton">
+          <property name="accessibleName">
+           <string>Copy translation to the clipboard</string>
+          </property>
           <property name="toolTip">
            <string>Copy translation to the clipboard</string>
           </property>
@@ -367,6 +409,9 @@
         </item>
         <item>
          <widget class="QToolButton" name="copyAllTranslationButton">
+          <property name="accessibleName">
+           <string>Copy all translation data to the clipboard</string>
+          </property>
           <property name="toolTip">
            <string>Copy all translation data to the clipboard</string>
           </property>
@@ -377,6 +422,9 @@
         </item>
         <item>
          <widget class="QToolButton" name="delayedTranslateScreenAreaButton">
+          <property name="accessibleName">
+           <string>Translate screen area with delay</string>
+          </property>
           <property name="toolTip">
            <string>Translate screen area with delay</string>
           </property>
@@ -387,6 +435,9 @@
         </item>
         <item>
          <widget class="QToolButton" name="settingsButton">
+          <property name="accessibleName">
+           <string>Application settings</string>
+          </property>
           <property name="toolTip">
            <string>Application settings</string>
           </property>
diff --git a/src/ocr/llmocr.cpp b/src/ocr/llmocr.cpp
index 099e63ae..33e83479 100644
--- a/src/ocr/llmocr.cpp
+++ b/src/ocr/llmocr.cpp
@@ -261,19 +261,19 @@ void LlmOcr::onFinished()
         if (m_userCanceled) {
             emit canceled();
         } else {
-            emit failed(QStringLiteral("LLM OCR request timed out"));
+            emit failed(tr("LLM OCR request timed out"));
         }
         return;
     }
 
     if (reply->error() != QNetworkReply::NoError) {
-        emit failed(QStringLiteral("LLM OCR error: ") + reply->errorString());
+        emit failed(tr("LLM OCR error: %1").arg(reply->errorString()));
         return;
     }
 
     const QString text = OpenAiEndpoint::extractContent(reply->readAll(), m_isAnthropic);
     if (text.isEmpty()) {
-        emit failed(QStringLiteral("LLM OCR returned an empty response"));
+        emit failed(tr("LLM OCR returned an empty response"));
         return;
     }
 
diff --git a/src/popupwindow.ui b/src/popupwindow.ui
index 5229981c..3e514c46 100644
--- a/src/popupwindow.ui
+++ b/src/popupwindow.ui
@@ -28,6 +28,9 @@
      </item>
      <item>
       <widget class="QToolButton" name="swapButton">
+       <property name="accessibleName">
+        <string>Swap languages</string>
+       </property>
        <property name="toolTip">
         <string>Swap languages</string>
        </property>
@@ -62,6 +65,9 @@
          <verstretch>0</verstretch>
         </sizepolicy>
        </property>
+       <property name="accessibleName">
+        <string>Translate</string>
+       </property>
        <property name="toolTip">
         <string>Translate</string>
        </property>
@@ -76,6 +82,9 @@
     <layout class="QHBoxLayout" name="buttomLayout">
      <item>
       <widget class="QToolButton" name="sourcePlayPauseButton">
+       <property name="accessibleName">
+        <string>Start/pause saying the source text aloud</string>
+       </property>
        <property name="toolTip">
         <string>Start/pause saying the source text aloud</string>
        </property>
@@ -121,6 +130,9 @@
      </item>
      <item>
       <widget class="QToolButton" name="sourceStopButton">
+       <property name="accessibleName">
+        <string>Stop saying the source text aloud</string>
+       </property>
        <property name="toolTip">
         <string>Stop saying the source text aloud</string>
        </property>
@@ -128,6 +140,9 @@
      </item>
      <item>
       <widget class="QToolButton" name="copySourceButton">
+       <property name="accessibleName">
+        <string>Copy source text to the clipboard</string>
+       </property>
        <property name="toolTip">
         <string>Copy source text to the clipboard</string>
        </property>
@@ -218,6 +233,9 @@
      </item>
      <item>
       <widget class="QToolButton" name="translationPlayPauseButton">
+       <property name="accessibleName">
+        <string>Start/pause saying the translated text aloud</string>
+       </property>
        <property name="toolTip">
         <string>Start/pause saying the translated text aloud</string>
        </property>
@@ -263,6 +281,9 @@
      </item>
      <item>
       <widget class="QToolButton" name="translationStopButton">
+       <property name="accessibleName">
+        <string>Stop saying the translated text aloud</string>
+       </property>
        <property name="toolTip">
         <string>Stop saying the translated text aloud</string>
        </property>
@@ -270,6 +291,9 @@
      </item>
      <item>
       <widget class="QToolButton" name="copyAllTranslationButton">
+       <property name="accessibleName">
+        <string>Copy all translation data to the clipboard</string>
+       </property>
        <property name="toolTip">
         <string>Copy all translation data to the clipboard</string>
        </property>
@@ -280,6 +304,9 @@
      </item>
       <item>
        <widget class="QToolButton" name="copyTranslationButton">
+        <property name="accessibleName">
+         <string>Copy translation to the clipboard</string>
+        </property>
         <property name="toolTip">
          <string>Copy translation to the clipboard</string>
         </property>
diff --git a/src/settings/appsettings.cpp b/src/settings/appsettings.cpp
index f5738e8e..bf7e8f77 100644
--- a/src/settings/appsettings.cpp
+++ b/src/settings/appsettings.cpp
@@ -697,7 +697,7 @@ QString AppSettings::localProviderDisplayName(const QString &id)
         return QStringLiteral("LM Studio");
     }
     if (id == QLatin1String("openai_custom")) {
-        return QStringLiteral("OpenAI-compatible (custom)");
+        return tr("OpenAI-compatible (custom)");
     }
     if (id == QLatin1String("anthropic")) {
         return QStringLiteral("Anthropic");
diff --git a/src/settings/settingsdialog.cpp b/src/settings/settingsdialog.cpp
index 8ff2562e..d125f966 100644
--- a/src/settings/settingsdialog.cpp
+++ b/src/settings/settingsdialog.cpp
@@ -387,7 +387,7 @@ void SettingsDialog::buildLocalAiTabs()
             t.text.timeout = new QSpinBox(t.text.page);
             t.text.timeout->setRange(60, 3600);
             t.text.timeout->setSingleStep(30);
-            t.text.timeout->setSuffix(QStringLiteral(" s"));
+            t.text.timeout->setSuffix(tr(" s"));
             t.text.timeout->setToolTip(tr("Maximum time to wait for a translation or detection response."));
             modelRow->addWidget(textTimeoutLabel);
             modelRow->addWidget(t.text.timeout);
@@ -467,6 +467,7 @@ void SettingsDialog::buildOcrEngineUi()
 
     auto *engineLabel = new QLabel(tr("OCR engine:"), engineRow);
     m_ocrEngineCombo = new QComboBox(engineRow);
+    engineLabel->setBuddy(m_ocrEngineCombo);
     m_ocrEngineCombo->setObjectName(QStringLiteral("ocrEngineCombo"));
     m_ocrEngineCombo->addItem(tr("Tesseract"), static_cast<int>(AppSettings::OcrEngine::Tesseract));
     m_ocrEngineCombo->addItem(tr("Vision model (LLM)"), static_cast<int>(AppSettings::OcrEngine::Llm));
@@ -492,6 +493,7 @@ void SettingsDialog::buildOcrEngineUi()
     auto *providerRow = new QHBoxLayout();
     auto *providerLabel = new QLabel(tr("Provider:"), llmPage);
     m_ocrLlmProviderCombo = new QComboBox(llmPage);
+    providerLabel->setBuddy(m_ocrLlmProviderCombo);
     m_ocrLlmProviderCombo->setObjectName(QStringLiteral("ocrLlmProviderCombo"));
     for (const QString &id : AppSettings::localProviderIds()) {
         m_ocrLlmProviderCombo->addItem(AppSettings::localProviderDisplayName(id), id);
@@ -501,9 +503,10 @@ void SettingsDialog::buildOcrEngineUi()
     providerRow->addSpacing(12);
     auto *timeoutLabel = new QLabel(tr("Timeout:"), llmPage);
     m_ocrLlmTimeoutSpin = new QSpinBox(llmPage);
+    timeoutLabel->setBuddy(m_ocrLlmTimeoutSpin);
     m_ocrLlmTimeoutSpin->setRange(60, 3600);
     m_ocrLlmTimeoutSpin->setSingleStep(30);
-    m_ocrLlmTimeoutSpin->setSuffix(QStringLiteral(" s"));
+    m_ocrLlmTimeoutSpin->setSuffix(tr(" s"));
     m_ocrLlmTimeoutSpin->setToolTip(tr("Maximum time to wait for a transcription response."));
     providerRow->addWidget(timeoutLabel);
     providerRow->addWidget(m_ocrLlmTimeoutSpin);
@@ -517,9 +520,11 @@ void SettingsDialog::buildOcrEngineUi()
     auto *urlRow = new QHBoxLayout();
     auto *urlLabel = new QLabel(tr("URL:"), llmPage);
     m_ocrLlmUrlEdit = new QLineEdit(llmPage);
+    urlLabel->setBuddy(m_ocrLlmUrlEdit);
     m_ocrLlmUrlEdit->setObjectName(QStringLiteral("ocrLlmUrlEdit"));
     auto *apiKeyLabel = new QLabel(tr("Key:"), llmPage);
     m_ocrLlmApiKeyEdit = new QLineEdit(llmPage);
+    apiKeyLabel->setBuddy(m_ocrLlmApiKeyEdit);
     m_ocrLlmApiKeyEdit->setObjectName(QStringLiteral("ocrLlmApiKeyEdit"));
     m_ocrLlmApiKeyEdit->setEchoMode(QLineEdit::Password);
     m_ocrLlmApiKeyEdit->setPlaceholderText(tr("optional, e.g. for a cloud endpoint"));
@@ -535,6 +540,7 @@ void SettingsDialog::buildOcrEngineUi()
     auto *modelRow = new QHBoxLayout();
     auto *modelLabel = new QLabel(tr("Model:"), llmPage);
     m_ocrLlmModelCombo = new QComboBox(llmPage);
+    modelLabel->setBuddy(m_ocrLlmModelCombo);
     m_ocrLlmModelCombo->setObjectName(QStringLiteral("ocrLlmModelCombo"));
     m_ocrLlmModelCombo->setEditable(true);
     m_ocrLlmModelCombo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.