Bug 510221

Summary: Smart substitutions (quotes, dashes)
Product: [Applications] lokalize Reporter: Emir SARI <emir_sari>
Component: editorAssignee: Finley Watson <fin-w>
Status: REPORTED ---    
Severity: wishlist CC: aacid, sdepiets, shafff, tanishkrsh6061
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Other   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

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.
Comment 4 Tanish Kumar 2026-01-10 21:17:11 UTC
Hi @finely_watson @emir_sari,

I've spent some time looking into the ktextaddons integration we discussed. I still agree it's the cleaner long term path, but since it involves adding new dependencies and modifying the build system, it is going to take significant time to get right.

With the Season of KDE selection coming up in 10 days, I want to prioritize my preparation for Task 2 (Glossary) to ensure I'm fully ready if selected.

I'm going to pause this 'Smart Quotes' task for now. I'll keep my working manual prototype (from my previous comment) as a fallback, but I plan to circle back to the proper ktextaddons implementation later when i have more bandwidth.

Thanks for the guidance!