vslavik / poedit

Translations editor for Mac, Windows and Unix
https://poedit.net
MIT License
1.71k stars 274 forks source link

XLIFF: superfluous " within text is replaced with " on save #836

Closed sbaeumlisberger closed 4 months ago

sbaeumlisberger commented 4 months ago

xliff Translation files generated with Angular are using " to escape double-quotes ". Poedit should keep them escaped when saving the file.

Here an example git diff after saving the file in Poedit:

- <source>The file path must end with &quot;.p12&quot; or &quot;.pfx&quot;</source>  
- <target>Der Dateipfad muss mit &quot;.p12&quot; oder &quot;.pfx&quot; enden.</target>  
+ <source>The file path must end with ".p12" or ".pfx"</source>  
+ <target>Der Dateipfad muss mit ".p12" oder ".pfx" enden.</target> 
vslavik commented 4 months ago

Poedit should keep them escaped when saving the file.

Why? I mean, besides the presumed "editing should minimize diff" argument? This can be seen as normalization of weirdly expressed XML file and arguably something that should be fixed on Angular side...

Anyway, this is implementable, but at the cost of significantly more complicated parsing in Poedit, with the associated risk of bugs — IOW it is not clear if it's worth doing. The implementation would need to disable parse_escapes, all text (attribute values, text nodes) would need to be parsed for entities and all output would need to be encoded. Currently that is all done by pugixml transparently. This is the sort of thing where it's really easy to inadvertently forget to encode something or encode unnecessarily — precisely what happened in Angular's code...

Here an example git diff after saving the file in Poedit:

Can you please attach actual file, i.e. reproduction test case?

sbaeumlisberger commented 4 months ago

Thank's for the fast response. I understand that it would complicate the implementation. The problem is that when the file is updated by angular the process get's inverted which results in big diffs whenever we are adding a translation. But I think the behavior of PoEdit is right as the escaping is indeed completely unnecessary. I will open an issue in the angular repository. Thank's for your time and great tool!