iachat/app
Sivin Varghese 72509f9e38
chore: Improve translation service with HTML and plain text support (#11305)
# Pull Request Template

## Description

This PR changes to translation to properly handle different content
types during translation.

### Changes

1. **Email translation with HTML support**
   - Properly detects and preserves HTML content from emails
   - Sets `mime_type` to 'text/html' when HTML content is present

2. **Email translation with plain text support**
   - Falls back to email text content when HTML is not available
- Sets `mime_type` to 'text/plain' when HTML is not available and
content type includes 'text/plain'

3. **Plain message with plain text support (Non email channels)**
   - Sets `mime_type` to 'text/plain' for non-email channels
- Fixes an issue where Markdown formatting was being lost due to
incorrect `mime_type`
   
**Note**: Translation for very long emails is not currently supported.

Fixes
https://linear.app/chatwoot/issue/CW-4244/translate-button-doesnt-work-in-email-channels

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)

## How Has This Been Tested?

**Loom video**

https://www.loom.com/share/8f8428ed2cfe415ea5cb6c547c070f00?sid=eab9fa11-05f8-4838-9181-334bee1023c4


## Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [x] I have commented on my code, particularly in hard-to-understand
areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream
modules
2025-04-16 17:59:06 +05:30
..
actions chore: Avoid contact inboxes getting deleted (#10612) 2024-12-26 16:17:38 +05:30
assets chore: Update styles in settings pages (#11070) 2025-03-18 14:40:02 -07:00
builders fix: Handle Instagram echo events (#11275) 2025-04-10 12:58:38 +05:30
channels fix: Move contact events to account stream rather than individual user stream (#11082) 2025-03-13 17:46:48 -07:00
controllers fix: use stricter validation to restrict gmail signups (#11285) 2025-04-12 10:52:49 +05:30
dashboards feat: Ability to delete account for administrators (#1874) 2025-04-03 10:41:39 +05:30
dispatchers feat(ee): Add Captain features (#10665) 2025-01-14 16:15:47 -08:00
drops feat: Add the support for custom attributes in message variables (#8511) 2023-12-08 14:13:35 -08:00
fields feat: setup captain limits (#10713) 2025-01-23 01:23:18 +05:30
finders chore(refactor): Improve conversation permission filtering (#11166) 2025-03-31 19:30:02 -07:00
helpers feat: Added the ability to create Instagram channel (#11182) 2025-04-03 13:57:14 +05:30
javascript chore: Improve translation service with HTML and plain text support (#11305) 2025-04-16 17:59:06 +05:30
jobs feat: Handle instagram test service (#11244) 2025-04-11 19:11:29 +05:30
listeners chore: Ignore notification when assignee is nil (#11105) 2025-03-18 20:14:19 -07:00
mailboxes fix: Process non-image inline attachments as regular attachments (#10998) 2025-02-28 13:33:48 -08:00
mailers chore: Increase the timeout to support slow SMTP servers (#10318) 2025-04-16 12:15:49 +05:30
models chore: Centralize outgoing message reply restrictions for all the channels (#11279) 2025-04-12 08:52:12 +05:30
policies chore: Clean up report & knowledge base policies (#11234) 2025-04-03 16:00:32 -07:00
presenters chore: Update the precision of the updated_at timestamp in conversation model (#10875) 2025-02-10 20:22:11 -08:00
services chore: Centralize outgoing message reply restrictions for all the channels (#11279) 2025-04-12 08:52:12 +05:30
views feat: Add warnings for existing instagram messenger channels (#11303) 2025-04-16 12:54:41 +05:30
workers fix: Capture delivery errors to avoid false positives (#8790) 2024-01-26 14:22:18 +04:00