Validate selected vocabulary term as a valid language in AI Assistant - Translate

Created on 10 March 2025, about 2 months ago

Problem/Motivation

In the AI Assistant - Translate module, users can select a vocabulary in the admin configuration. However, while using the translation feature in CKEditor, the module attempts to translate text into the chosen term name (e.g., "Choose language"). Since the term may not always be a valid language name, this results in incorrect behavior.

Steps to reproduce

  1. Navigate to Configuration > AI Assistant - Translate settings.
  2. Choose a vocabulary that contains terms unrelated to language names.
  3. Open CKEditor and use the translate feature.
  4. The module tries to translate content using the term name, which may not be a valid language.

Proposed resolution

  • Implement validation to ensure the selected term corresponds to a valid language name before attempting translation.
  • Prevent translation if the term does not match an actual language.
  • Provide an error message if an invalid language is selected.

Remaining tasks

  • Add validation logic in the configuration form.
  • Validate the term before processing translations.
  • Display an error message when an invalid language is chosen.

User interface changes

A validation message should be displayed when an invalid language is selected.

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

AI CKEditor

Created by

🇮🇳India prashant.c Dharamshala

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @prashant.c
  • Pipeline finished with Failed
    about 1 month ago
    Total: 218s
    #446406
  • Pipeline finished with Success
    about 1 month ago
    Total: 238s
    #446434
  • 🇮🇳India annmarysruthy

    Added validation in CkEditor AI tools - Translate settings. When a vocabulary is selected for translate settings, validation checks if the terms in selected vocabulary are languages supported in drupal. Otherwise an error message with the invalid terms is displayed.

    Kindly review and test.

  • 🇬🇧United Kingdom MrDaleSmith

    Works as described, but if you select a vocabulary that has no terms in it, the validation passes. Might be worth having a check for if the vocabulary is empty.

  • Pipeline finished with Failed
    about 1 month ago
    Total: 236s
    #447147
  • Pipeline finished with Success
    about 1 month ago
    Total: 287s
    #447153
  • 🇮🇳India annmarysruthy

    Added a check for empty vocabulary as per review comment. Also validation will occur only when translate is enabled in CK Editor.

    Thanks for the input @mrdalesmith. Kindly review changes.

  • 🇩🇪Germany marcus_johansson

    LGTM, however I'm wondering how well this fits together with #3515743. One of the advantages of the taxonomy system is that you can really use descriptive language names like "Bureaucratic Swedish", "Informal Swabian German" or made up languages that some LLM handles like "Klingon" and these does not fit actual languages from the language list.

    I'll add this comment to discussion on Slack and see how people feel about merging it.

Production build 0.71.5 2024