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 |
|---|---|
![]() |
![]() |
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.
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


