Bug 510221 - Smart substitutions (quotes, dashes)
Summary: Smart substitutions (quotes, dashes)
Status: REPORTED
Alias: None
Product: lokalize
Classification: Applications
Component: editor (other bugs)
Version First Reported In: unspecified
Platform: Other Other
: NOR wishlist
Target Milestone: ---
Assignee: Finley Watson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-10-04 11:38 UTC by Emir SARI
Modified: 2026-01-07 20:01 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Emir SARI 2025-10-04 11:38:14 UTC
This would save me so much trouble while translating.

It would be great to have automatic quotes and dashes substitutions, instead of always having plain dashes and quotes. I believe ktextaddons have this already implemented. It would be even better if KXMLGUI had this built-in like macOS, but Lokalize having it would suffice for now.

For instance:

- "%1" should auto-substitute to “%1” (or locale-specific other qutoes)
- It's should auto-substitute to It’s
- I am not sure how ktextaddons does this but for instance, having -- to en dash, and --- to em dash would be splendid.

HIG suggests using these fancy characters, and having this built-into Lokalize would help a lot for sanitising the strings with these characters.
Comment 1 Tanish Kumar 2026-01-07 19:11:21 UTC
I have successfully reproduced this behavior.
I checked the source and saw that XliffTextEdit inherits from KTextEdit, which doesn't seem to support smart substitutions .
I would like to attempt implementing this feature (likely by intercepting keyPressEvent or using a textChanged signal to swap the characters). Is it okay if I assign this to myself?
Comment 2 Emir SARI 2026-01-07 19:18:31 UTC
Or you can just implement ktextaddons’ smart substitution behaviour, just like KMail does. Then we can decide whether it’s a good idea to have it enabled by default.

Even more, implementing this in kxmlgui as a standard feature would allow most applications have this behaviour for free.
Comment 3 Tanish Kumar 2026-01-07 20:01:21 UTC
(In reply to Emir SARI from comment #2)
> Or you can just implement ktextaddons’ smart substitution behaviour, just
> like KMail does. Then we can decide whether it’s a good idea to have it
> enabled by default.
> 
> Even more, implementing this in kxmlgui as a standard feature would allow
> most applications have this behaviour for free.

Thanks for the suggestion!

I actually just finished a local prototype by intercepting keyPressEvent in TranslationUnitTextEdit, and it works well for both smart quotes and em-dashes.

However, I agree that reusing ktextaddons (like KMail) is the cleaner long term solution. I will investigate how difficult it would be to integrate ktextaddons into Lokalize.

For now, I can clean up my local implementation as a fallback in case adding a new dependency is too much for this task.