Skip to content

Commit d4d40cf

Browse files
committed
feat: release 1.2.2 — dark-mode readability fix for translated mail
Wrap translator output in a minimal HTML document with explicit color-scheme: light + white background before loading into the message view. Without this wrapper e_web_view_load_string() loads the content raw and WebKit applies its dark UA stylesheet on dark desktops (KDE Breeze Dark, GNOME dark preference) — making white mails flip to dark on translate, hurting readability. Cache stores the raw translation; the wrap is applied at load time, so it is idempotent across cache hits. Restore-original goes through Evolution's normal pipeline and is unaffected. Mails carrying their own inline body styling (e.g. dark-themed newsletters) keep their look — inline styles outrank the wrapper's CSS rule via specificity. Long-standing readability bug inherited from the upstream project (costantinoai/evolution-mail-translate); never fixed there.
1 parent 00ea86e commit d4d40cf

5 files changed

Lines changed: 69 additions & 10 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ if(NOT DEFINED VERSION)
2727
if(DEB_VERSION)
2828
set(VERSION "${DEB_VERSION}")
2929
else()
30-
set(VERSION "1.2.1")
30+
set(VERSION "1.2.2")
3131
endif()
3232
else()
33-
set(VERSION "1.2.1")
33+
set(VERSION "1.2.2")
3434
endif()
3535
endif()
3636

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[![License](https://img.shields.io/badge/license-LGPL--2.1%2B-green.svg)](#license)
99
[![Documentation](https://img.shields.io/badge/docs-complete-brightgreen.svg)](docs/USER_GUIDE.md)
1010

11-
> 🆕 **Latest: v1.2.1**Verified on **GNOME Evolution 3.60.1**, plus optional CPU quantization (`ARGOS_COMPUTE_TYPE=int8`) for 2–4× faster translation.
11+
> 🆕 **Latest: v1.2.2**Dark-mode readability fix: translated mails no longer flip to a dark background under dark GTK themes (KDE Breeze Dark, GNOME dark preference). Previous release (v1.2.1) verified the plugin on **GNOME Evolution 3.60.1** and added optional CPU quantization (`ARGOS_COMPUTE_TYPE=int8`).
1212
> See the [release notes](https://github.com/MoDD0/moddo-evolution-translator/releases/latest) or the full [CHANGELOG](docs/CHANGELOG.md).
1313
1414
> **Tested on Manjaro Linux with GNOME Evolution 3.58.3 and 3.60.1.**
@@ -40,7 +40,7 @@ This Evolution extension adds instant, privacy-preserving email translation dire
4040
> **No prebuilt packages yet.** All distros currently install via build-from-source.
4141
> Prebuilt `.deb` and an AUR package are on the roadmap (alongside our v1.5 release).
4242
> If you want a `.deb` locally, run `cd build && cpack -G DEB` after the build step
43-
> below — it'll produce `moddo-evolution-translator_1.2.1-1_<arch>.deb` you can
43+
> below — it'll produce `moddo-evolution-translator_1.2.2-1_<arch>.deb` you can
4444
> `apt install ./...`.
4545
4646
#### Ubuntu / Debian

debian/changelog

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
moddo-evolution-translator (1.2.2-1) unstable; urgency=medium
2+
3+
* Bug fixes:
4+
- Translated mail no longer flips to a dark background under dark
5+
desktop themes. The plugin now wraps the translator output in a
6+
minimal HTML document with an explicit `color-scheme: light` and
7+
a white background, so e_web_view_load_string() no longer falls
8+
back to WebKit's dark UA stylesheet. Mails with their own dark
9+
design (e.g. dark-themed newsletters) keep their inline styling.
10+
This was a long-standing readability issue inherited from the
11+
upstream project — never fixed there.
12+
13+
-- MoDD0 <139858927+MoDD0@users.noreply.github.com> Wed, 20 May 2026 00:00:00 +0000
14+
115
moddo-evolution-translator (1.2.1-1) unstable; urgency=medium
216

317
* Compatibility:

docs/CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Changelog
22

3+
## 1.2.2 — Translated mail readable under dark desktop themes
4+
- **Dark-mode readability fix**: On systems running a dark GTK theme
5+
(KDE Breeze Dark, GNOME's dark preference, etc.), translated mails used
6+
to switch to a dark background while the original mail stayed light —
7+
hurting readability. The translator output is now wrapped in a minimal
8+
HTML document with an explicit `color-scheme: light` and a white
9+
background before being loaded into the message view, so the rendered
10+
translation no longer falls through to WebKit's dark user-agent
11+
stylesheet. Mails whose own design carries explicit styling
12+
(e.g. dark-themed newsletters) keep their look — only mails with no
13+
color hints of their own are affected. This was a long-standing
14+
readability issue inherited from the upstream project; it was never
15+
fixed there.
16+
317
## 1.2.1 — Evolution 3.60 verified, optional CPU quantization
418
- **Evolution 3.60.1 verified**: builds and runs unchanged against the
519
3.60 series on Manjaro. No EUI / EUIManager API changes were needed

src/translate-dom.c

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,33 @@ get_current_uid (EMailDisplay *display)
9999
* INTERNAL HELPER FUNCTIONS
100100
* ============================================================================ */
101101

102+
/* Wraps translator output in a minimal HTML document with explicit
103+
* color-scheme so the rendered translation stays readable. Without this,
104+
* e_web_view_load_string() loads the content raw and WebKit applies its
105+
* user-agent stylesheet — which under a dark desktop theme picks a dark
106+
* background, turning white emails black after translation. Evolution's
107+
* regular formatter pipeline applies webview.css separately; load_string
108+
* bypasses it. */
109+
static gchar *
110+
wrap_translated_for_webview (const gchar *html)
111+
{
112+
return g_strdup_printf (
113+
"<!DOCTYPE html>\n"
114+
"<html>\n"
115+
"<head>\n"
116+
"<meta charset=\"utf-8\">\n"
117+
"<meta name=\"color-scheme\" content=\"light\">\n"
118+
"<style>\n"
119+
":root { color-scheme: light; }\n"
120+
"html, body { background: #ffffff; color: #000000; }\n"
121+
"body { padding: 8px; }\n"
122+
"</style>\n"
123+
"</head>\n"
124+
"<body>%s</body>\n"
125+
"</html>",
126+
html ? html : "");
127+
}
128+
102129
/**
103130
* apply_translation_internal:
104131
*
@@ -151,10 +178,13 @@ apply_translation_internal (EMailDisplay *display,
151178
}
152179
}
153180

154-
/* Load translated HTML into the web view FIRST — translated_html may
155-
* point into s_translation_cache, and the insert below frees the old
156-
* value. e_web_view_load_string copies the string internally. */
157-
e_web_view_load_string (E_WEB_VIEW (display), translated_html ? translated_html : "");
181+
/* Wrap the raw translation in a minimal HTML document with explicit
182+
* color-scheme: light so a dark desktop theme doesn't repaint the
183+
* mail dark via WebKit's UA stylesheet (see wrap_translated_for_webview).
184+
* Cache stores the unwrapped translation; wrap is idempotent across
185+
* cache hits. */
186+
g_autofree gchar *wrapped = wrap_translated_for_webview (translated_html);
187+
e_web_view_load_string (E_WEB_VIEW (display), wrapped);
158188

159189
/* Cache the translation by message UID */
160190
if (current_uid) {
@@ -164,8 +194,9 @@ apply_translation_internal (EMailDisplay *display,
164194
}
165195

166196
if (verbose_logging) {
167-
g_message ("[translate] Applied translated content (%zu bytes) to preview",
168-
translated_html ? strlen (translated_html) : 0UL);
197+
g_message ("[translate] Applied translated content (%zu bytes raw, %zu bytes wrapped) to preview",
198+
translated_html ? strlen (translated_html) : 0UL,
199+
wrapped ? strlen (wrapped) : 0UL);
169200
}
170201
}
171202

0 commit comments

Comments
 (0)