fix: #3634662 Transliterate the description for the generated file name

Closes https://www.drupal.org/project/ai_media/issues/3634662

The generated file's slug kept only a-z and 0-9 after strtolower(), so an Arabic (or Cyrillic, Greek, Chinese) description gave an empty slug and every such file saved as ai-media.<extension>, and accented letters were dropped ("été" became "t"). The description now goes through core's @transliteration service for the current language before lower-casing and slugging, with media kept as the last fallback. AiMediaGeneration::slug() holds the rule.

The final name then goes through FileUploadSanitizeNameEvent, so the site's File system settings and any listening module apply on top, with the site's replacement character between words.

Kernel test: FileNameTest covers English only, French only, Arabic only and multilingual (en, fr, ar, current language switched) sites, the site's sanitization settings and a listening module.

Before (1.0.x) After
Before, Horizon Aid, Default Admin: "Un café à Zürich, croquis à l'encre" saves as ai-un-caf-z-rich-croquis-l-encre.png After, Horizon Aid, Default Admin: the same description saves as ai-un-cafe-a-zurich-croquis-a-l-encre.png

After, Varbase Starter, Gin: "Château médiéval près d'un lac, été ensoleillé" saves as ai-chateau-medieval-pres-d-un-lac-ete-ensoleille.png.

After, Varbase Starter, Gin: a French description saves as ai-chateau-medieval-pres-d-un-lac-ete-ensoleille.png

Tested in the browser with real OpenAI generations on Varbase Starter (Gin) and Horizon Aid (Default Admin), en and ar interfaces, including the Media Library dialog.

AI-Generated: Yes

Checkpoints:

  • File an issue
  • Addition/Change/Update/Fix
  • Testing to ensure no regression
  • Automated unit testing coverage
  • Automated functional testing coverage
  • UX/UI designer responsibilities
  • Readability
  • Accessibility
  • Performance
  • Security
  • Developer Documentation
  • User Guide Documentation
  • Reviewed by human
  • Code review by maintainers
  • Full testing and approval
  • Credit contributors
  • Review with the product owner
  • Release notes snippet
  • Release

🤖 Generated with Claude Code

Edited by Rajab Natshah

Merge request reports

Loading
Loading