Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix indent in XLIFF output #3424

Closed
mathjazz opened this issue Apr 8, 2016 · 1 comment

Comments

Projects
None yet
3 participants
@mathjazz
Copy link

commented Apr 8, 2016

XLIFF (and maybe other LISA files) aren't indented properly on output.

They look like this:

<trans-unit id="ID" approved="yes">
  <source>Source Text</source>
  <target state="translated">Translation</target> <note>Note</note>
</trans-unit>

Instead of this:

<trans-unit id="ID" approved="yes">
  <source>Source Text</source>
  <target state="translated">Translation</target>
  <note>Note</note>
</trans-unit>

Fix should be pretty simple, but with my level of translate-toolkit experience, I'm afraid of submitting a pull request: mathjazz@29afa0d.

Got the idea for the fix from @flodolo:
https://github.com/mozilla/firefox-ios-build-tools/blob/master/scripts/update-xliff.py#L26

@claudep

This comment has been minimized.

Copy link
Member

commented Jun 14, 2016

Is that from the latest beta version?
I am not able to reproduce. By applying this diff:

diff --git a/translate/storage/test_xliff.py b/translate/storage/test_xliff.py
index b2d7150..9d4364d 100644
--- a/translate/storage/test_xliff.py
+++ b/translate/storage/test_xliff.py
@@ -198,6 +198,7 @@ class TestXLIFFfile(test_base.TestTranslationStore):
     def test_notes(self):
         xlifffile = xliff.xlifffile()
         unit = xlifffile.addsourceunit("Concept")
+        unit.target = "tpecnoC"
         # We don't want to add unnecessary notes
         assert "note" not in bytes(xlifffile).decode('utf-8')
         unit.addnote(None)
@@ -209,6 +210,7 @@ class TestXLIFFfile(test_base.TestTranslationStore):
         assert unit.getnotes() == "Please buy bread"
         notenodes = unit.xmlelement.findall(".//%s" % unit.namespaced("note"))
         assert len(notenodes) == 1
+        assert bytes(xlifffile).decode('utf-8') == '?'

         unit.addnote("Please buy milk", origin="Mom")
         notenodes = unit.xmlelement.findall(".//%s" % unit.namespaced("note"))

I'm getting the following while running tests:

>       assert bytes(xlifffile).decode('utf-8') == '?'
E       assert '<?xml versio...le>\n</xliff>\n' == '?'
E         + ?
E         - <?xml version='1.0' encoding='UTF-8'?>
E         - <xliff xmlns="urn:oasis:names:tc:xliff:document:1.1" version="1.1">
E         -   <file original="NoName" source-language="en" datatype="plaintext">
E         -     <body>
E         -       <trans-unit xml:space="preserve" id="1">
E         -         <source>Concept</source>
E         -         <target>tpecnoC</target>
E         -         <note>Please buy bread</note>
E         -       </trans-unit>
E         -     </body>
E         -   </file>
E         - </xliff>

@unho unho added the formats label Feb 7, 2017

@unho unho self-assigned this Feb 7, 2017

@unho unho added this to the 2.0.1 milestone Feb 7, 2017

@unho unho added the mozilla label Feb 7, 2017

nijel added a commit to nijel/translate that referenced this issue Feb 11, 2019

Xliff: Reindent when saving
Use generic XML indentation code to achieve consistent indentation after
changing content.

Fixes translate#3424

nijel added a commit to nijel/translate that referenced this issue Feb 11, 2019

Xliff: Reindent when saving
Use generic XML indentation code to achieve consistent indentation after
changing content.

Fixes translate#3424

nijel added a commit to nijel/translate that referenced this issue Feb 12, 2019

Xliff: Reindent when saving
Use generic XML indentation code to achieve consistent indentation after
changing content.

Fixes translate#3424

nijel added a commit to nijel/translate that referenced this issue Feb 12, 2019

Xliff: Reindent when saving
Use generic XML indentation code to achieve consistent indentation after
changing content.

Fixes translate#3424

nijel added a commit to nijel/translate that referenced this issue Feb 12, 2019

Xliff: Reindent when saving
Use generic XML indentation code to achieve consistent indentation after
changing content.

Fixes translate#3424

nijel added a commit to nijel/translate that referenced this issue Feb 12, 2019

Xliff: Reindent when saving
Use generic XML indentation code to achieve consistent indentation after
changing content.

Fixes translate#3424

nijel added a commit to nijel/translate that referenced this issue Feb 13, 2019

Xliff: Reindent when saving
Use generic XML indentation code to achieve consistent indentation after
changing content.

Fixes translate#3424

nijel added a commit to nijel/translate that referenced this issue Feb 14, 2019

Xliff: Reindent when saving
Use generic XML indentation code to achieve consistent indentation after
changing content.

Fixes translate#3424

nijel added a commit to nijel/translate that referenced this issue Feb 14, 2019

Xliff: Reindent when saving
Use generic XML indentation code to achieve consistent indentation after
changing content.

Fixes translate#3424

@nijel nijel closed this in #3871 Feb 15, 2019

nijel added a commit that referenced this issue Feb 15, 2019

Xliff: Reindent when saving
Use generic XML indentation code to achieve consistent indentation after
changing content.

Fixes #3424
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.