Fix hook_install and set chat_translation default provider if available

Summary

The install hook in ai_translate.install is declared as:

/**




 * Implements hook_install().
 */
function ai_translate_hook_install($is_syncing) {
  _ai_translate_check_default_provider_and_model();
}

The function name should be ai_translate_install(). With _hook_ in the name Drupal never calls it, so the check for a default translate_text provider does not run on install.

So nothing tells the site builder that the "Chat proxy to LLM" provider still has to be selected for the Translate text operation in the AI settings. The status report flags it later on, but there is no message right after enabling the module. From what I can tell the hook was copied over unchanged from the AI module when ai_translate became a standalone project, so this has probably been broken since the start.

Suggested fix: rename the function to ai_translate_install().

This could also be the place to set chat_translation as the default translate_text provider when the slot is empty and a default chat provider exists, the same way ai_translate_update_10002() does for existing sites. Right now new installs always need that manual step.

Steps to reproduce

  1. Install the AI module with a chat provider set up, but without a default translate_text provider.
  2. Enable ai_translate.

Expected result

An error message asking to set a default provider and model for text translation, with a link to the AI settings form.

Actual result

No message. The status report at /admin/reports/status does show the requirement error, since hook_requirements() is named correctly.

Environment

  • Drupal version: 11.x
  • Module version: 2.0.x-dev (also 1.3.x and 1.4.x, the function is identical there)
  • PHP version: 8.4
  • Provider: not relevant
  • Last known working version: none, probably broken since the split from the AI module

AI Usage

  • AI Assisted Issue — This issue was generated with AI assistance, but was reviewed and refined by the creator.
Edited by Sven Decabooter