"Translate with AI" Button Not Appearing Due to Route Alteration Conflict with Other Modules

Created on 15 October 2024, 10 months ago

Problem/Motivation

I am encountering an issue where the "Translate with AI" button provided by the ai_translate module is not appearing on the content translation overview page. After investigating the issue, it seems to be caused by a route alteration conflict with other contrib modules that are also altering the content translation overview route (e.g., language_access).

Both modules are trying to alter the same route (entity.{entity_type}.content_translation_overview), and since ai_translate relies on altering the controller to inject the AI translation button, the changes from other contrib modules (like language_access) may override or prevent the AI functionality from being displayed.

Steps to reproduce

- Enable the ai_translate module and another contrib module that alters the same route (e.g., language_access).
- Go to the content translation overview page of any translatable entity.
- Observe that the "Translate with AI" button does not appear.

πŸ› Bug report
Status

Active

Version

1.0

Component

Other Submodules

Created by

πŸ‡§πŸ‡ͺBelgium arwillame Belgium πŸ‡§πŸ‡ͺ

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

Merge Requests

Comments & Activities

  • Issue created by @arwillame
  • πŸ‡§πŸ‡ͺBelgium arwillame Belgium πŸ‡§πŸ‡ͺ
  • πŸ‡§πŸ‡ͺBelgium arwillame Belgium πŸ‡§πŸ‡ͺ
  • Pipeline finished with Success
    10 months ago
    Total: 598s
    #313843
  • Pipeline finished with Canceled
    8 months ago
    Total: 83s
    #372678
  • Pipeline finished with Failed
    8 months ago
    Total: 167s
    #372679
  • πŸ‡§πŸ‡ͺBelgium arwillame Belgium πŸ‡§πŸ‡ͺ

    Handle the "allowed_languages" module as well in the last commit of the MR.
    I would prefer to use a more global method to fiw this but i dont for now.
    If anyone has a better approach?

  • First commit to issue fork.
  • Pipeline finished with Failed
    8 months ago
    Total: 229s
    #385081
  • Pipeline finished with Failed
    8 months ago
    Total: 171s
    #385092
  • πŸ‡¬πŸ‡§United Kingdom MrDaleSmith

    @arwillame I've tried an alternate approach in the new branch - what this *should* do is use whatever controller exists at that route to build the original template and then add the AI Translate info to it: that way, we don't need to hardcode module names and risk missing one.

    It's available at https://git.drupalcode.org/project/ai/-/merge_requests/378. We could do with some people using modules tat already override that translate route to test and see if it works as expected.

  • Pipeline finished with Failed
    8 months ago
    Total: 166s
    #385097
  • Pipeline finished with Success
    8 months ago
    Total: 165s
    #385103
  • Pipeline finished with Failed
    7 months ago
    Total: 170s
    #390918
  • πŸ‡§πŸ‡ͺBelgium arwillame Belgium πŸ‡§πŸ‡ͺ

    I, Thanks for the the idea, it seems nice indeed.

    I made a quick check with one project where language_access module is used.
    First it just did not seemed to work, so i updated the weight .
    Then i had a php error when testing it :

    TypeError: array_splice(): Argument #1 ($array) must be of type array, null given in array_splice() (regel 177 van /var/www/html/web/modules/contrib/ai/modules/ai_translate/src/Form/AiTranslateForm.php).

    So i would say it would need a bit more of testing/work.

  • First commit to issue fork.
  • πŸ‡¬πŸ‡§United Kingdom seogow

    I have tested the '3480861-translate-with-ai-retake' branch with the following setup:

    • Drupal 11.1.1
    • drupal/language_access:^2.0
    • drupal/ai:dev-3480861-translate-with-ai-retake as 1.0.x-dev (corresponds to commit 7fd2b16335c78caba729ade3454f04cd963460ab, above ai:1.0.2)
    • Modules enabled: content_translation, ai, ai_provider_openai, ai_translate, key, language_access

    Result:

    • No Watchdog issues.
    • Language access prevents access to language versions user has no access to.
    • AI translations column contains translation link at '/node/{nid}/translations'.
    • A translation is made when link is clicked.

    @arwillame can you provide description how to replicate the error you observed?

  • πŸ‡¬πŸ‡§United Kingdom MrDaleSmith

    Yeah line 177 for me in the 3480861-translate-with-ai-retake branch is the start of a comment - it looks like you may be using a version of the code that doesn't have the

      if (isset($option['data'])) {
    

    line? This section of the form isn't actually edited in the MR just moved inside an additional if. I also don't need to adjust the weight of the routing change - allowed_languages is set to -220 and the MR to -230. All works for me.

  • Pipeline finished with Failed
    6 months ago
    Total: 515s
    #425677
  • Pipeline finished with Success
    6 months ago
    Total: 246s
    #425698
  • πŸ‡§πŸ‡ͺBelgium arwillame Belgium πŸ‡§πŸ‡ͺ

    Hi, merged the last version of the code and tested it again and it seem to be working fine for me now !
    Thanks for your contribution on this issue !

  • πŸ‡§πŸ‡ͺBelgium arwillame Belgium πŸ‡§πŸ‡ͺ

    Side node, i still need to change the weight as it is in MR.
    I believe it's because otherwhise "language_access" module take the lead on the route and dont take this one into account.

  • Status changed to RTBC 6 months ago
  • πŸ‡¬πŸ‡§United Kingdom MrDaleSmith

    I suspect that will be different on every installation so I'm not sure there's a lot can be done about it, unless we have a maxikmum weight we can use?

  • πŸ‡©πŸ‡ͺGermany marcus_johansson

    Thanks all, getting merged.

  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Status changed to Fixed 3 months ago
  • πŸ‡ΊπŸ‡ΈUnited States Kristen Pol Santa Cruz, CA, USA

    We are doing some issue management housekeeping and adding/removing components.

    We are removing the "Other Submodules" component and want people to categorize issues with the best module/submodule component.

    Moving this issue to "AI Translate".

    See πŸ“Œ Update AI module project components Active for more details.

Production build 0.71.5 2024