Bug 419071 - Lokalize changes ' to apostrophe character in source strings of TS files
Summary: Lokalize changes ' to apostrophe character in source strings of TS files
Status: RESOLVED FIXED
Alias: None
Product: lokalize
Classification: Applications
Component: editor (other bugs)
Version First Reported In: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Simon Depiets
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-21 12:05 UTC by wojnilowicz
Modified: 2020-04-19 08:38 UTC (History)
1 user (show)

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


Attachments
Original and Lokalized TS File comparison (57.12 KB, image/png)
2020-03-21 12:05 UTC, wojnilowicz
Details
sqlb_pl-original.ts (338 bytes, video/mpeg)
2020-03-21 12:05 UTC, wojnilowicz
Details
sqlb_pl-lokalized.ts (318 bytes, video/mpeg)
2020-03-21 12:06 UTC, wojnilowicz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description wojnilowicz 2020-03-21 12:05:20 UTC
Created attachment 126924 [details]
Original and Lokalized TS File comparison

SUMMARY
Lokalize changes ' to apostrophe character in source strings of TS files.

STEPS TO REPRODUCE
1. open sqlb_pl-original.ts in Lokalize
2. translate one string
3. save as sqlb_pl-lokalized.ts

OBSERVED RESULT
8th line of sqlb_pl-lokalized.ts is:
<source>Version '%1'</source>

EXPECTED RESULT
8th line of sqlb_pl-lokalized.ts should be:
<source>Version &apos;%1&apos;</source>
just like in sqlb_pl-original.ts


ADDITIONAL INFORMATION
That halted pull request with translated file here
https://github.com/sqlitebrowser/sqlitebrowser/pull/2127
Comment 1 wojnilowicz 2020-03-21 12:05:49 UTC
Created attachment 126925 [details]
sqlb_pl-original.ts
Comment 2 wojnilowicz 2020-03-21 12:06:10 UTC
Created attachment 126926 [details]
sqlb_pl-lokalized.ts
Comment 3 wojnilowicz 2020-03-21 12:10:32 UTC
Please notice that 1st line of sqlb_pl-original.ts
<?xml version="1.0" encoding="utf-8"?>
got changed to
<?xml version='1.0' encoding='utf-8'?>

so Lokalize replaced double with single quotation marks as well. That's marked in first attachment as well.
Comment 4 Simon Depiets 2020-04-17 05:08:09 UTC
We could technically argue that it is still correct as ' is not a reserved character in XML in that specific location (only & and < are), but I won't do that.

It's actually the behavior of the Qt xml parser, I found a workaround by using CDATA, I will push it this week-end (and it will be optionnal).
Comment 5 Simon Depiets 2020-04-18 16:03:19 UTC
Git commit 9e80b8358e401888f4bf179b1a8bd818624e796b by Simon Depiets.
Committed on 18/04/2020 at 15:58.
Pushed by sdepiets into branch 'master'.

TS storage shall not un-escape XML special chars

By default the QXmlSimpleReader transforms escaped XML chars into the actual chars (except < and &)
Now lokalize will re-escape them back and store them in a CData to prevent Qt from amending the string internally
On saving, the XML file is first exported to a string and the CData overhead is replaced.
This behavior can be disabled in Editor Settings

M  +83   -32   src/catalog/ts/tsstorage.cpp
M  +1    -1    src/catalog/ts/tsstorage.h
M  +3    -0    src/prefs/lokalize.kcfg
M  +27   -20   src/prefs/prefs_editor.ui

https://commits.kde.org/lokalize/9e80b8358e401888f4bf179b1a8bd818624e796b
Comment 6 wojnilowicz 2020-04-19 08:38:44 UTC
Thank you for the fix.