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

xliff #21

Closed
emilwojtaszek opened this issue Apr 25, 2018 · 13 comments
Closed

xliff #21

emilwojtaszek opened this issue Apr 25, 2018 · 13 comments
Labels
enhancement New feature or request

Comments

@emilwojtaszek
Copy link

what about xliff files, do you have in plan to support this?
https://en.wikipedia.org/wiki/XLIFF

@simonprev
Copy link
Member

Yes, this should be trivial to implement since it’s an XML format. I will add it to our backlog 😃

@emilwojtaszek
Copy link
Author

thanks

@simonprev simonprev added the enhancement New feature or request label Apr 27, 2018
@emilwojtaszek
Copy link
Author

any news here?

@simonprev
Copy link
Member

Sorry for the delay, i’ve not had the time to implement the feature yet. It is a bit more complicated that I thought 😕. Since the XLIFF format contains the target language and the master language it is a bit different than the other supported Accent formats.

Since you requested the feature I have a few questions:

  • Which version of XLIFF is the most commonly used?
  • Should all target languages be included in the file? (Is it 1 global file per project and not 1 per language)
  • My reference is: https://phraseapp.com/docs/guides/formats/xliff/ does it looks like your typical XLIFF file?

Thank you!

@emilwojtaszek
Copy link
Author

Thanks for your evolvement, this project is awesome!

My thoughts:

  • I've exported this file using newest Xcode10. Looks like Apple is supporting XLIFF v1.2.
  • Apple is generating one XLIFF file per language (source-language="en" target-language="pl-PL")
  • I have 2 targets: TestApp and TestAppTests. Apple is exporting all files from pl-PL.lproj folder for all targets https://cl.ly/120K2V1x033a

Hope this is helpful!

Here is example XLIFF file I've just exported:

<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 http://docs.oasis-open.org/xliff/v1.2/os/xliff-core-1.2-strict.xsd">
  <file original="TestApp/Base.lproj/LaunchScreen.storyboard" source-language="en" datatype="plaintext" target-language="pl-PL">
    <header>
      <tool tool-id="com.apple.dt.xcode" tool-name="Xcode" tool-version="10.0" build-num="10L201y"/>
    </header>
    <body>
      <trans-unit id="ULL-pi-uCz.text">
        <source>TestApp</source>
        <target>TestApp</target>
        <note>Class = "UILabel"; text = "TestApp"; ObjectID = "ULL-pi-uCz";</note>
      </trans-unit>
    </body>
  </file>
  <file original="TestApp/Base.lproj/Main.storyboard" source-language="en" datatype="plaintext" target-language="pl-PL">
    <header>
      <tool tool-id="com.apple.dt.xcode" tool-name="Xcode" tool-version="10.0" build-num="10L201y"/>
    </header>
    <body>
      <trans-unit id="00f-6P-Xg9.text">
        <source>Limit</source>
        <note>Class = "UILabel"; text = "Limit"; ObjectID = "00f-6P-Xg9";</note>
      </trans-unit>
      <trans-unit id="0no-oT-haJ.text">
        <source>Label</source>
        <note>Class = "UILabel"; text = "Label"; ObjectID = "0no-oT-haJ";</note>
      </trans-unit>
      <trans-unit id="1l3-3u-PCZ.title">
        <source>Item</source>
        <note>Class = "UIBarButtonItem"; title = "Item"; ObjectID = "1l3-3u-PCZ";</note>
      </trans-unit>
      <trans-unit id="3hg-K4-IdN.text">
        <source>Net price</source>
        <target>Cena netto</target>
        <note>Class = "UILabel"; text = "Net price"; ObjectID = "3hg-K4-IdN";</note>
      </trans-unit>
      <trans-unit id="4WP-Mk-N26.text">
        <source>Address</source>
        <target>Adres</target>
        <note>Class = "UILabel"; text = "Address"; ObjectID = "4WP-Mk-N26";</note>
      </trans-unit>
      <trans-unit id="xAS-qe-C2y.title">
        <source>Invoice</source>
        <target>Zamówienie</target>
        <note>Class = "UINavigationItem"; title = "Invoice"; ObjectID = "xAS-qe-C2y";</note>
      </trans-unit>
      <trans-unit id="xXD-Fj-vCm.title">
        <source>Customer</source>
        <target>Klient</target>
        <note>Class = "UITableViewController"; title = "Customer"; ObjectID = "xXD-Fj-vCm";</note>
      </trans-unit>
    </body>
  </file>
  <file original="TestApp/en.lproj/InfoPlist.strings" source-language="en" datatype="plaintext" target-language="pl-PL">
    <header>
      <tool tool-id="com.apple.dt.xcode" tool-name="Xcode" tool-version="10.0" build-num="10L201y"/>
    </header>
    <body>
      <trans-unit id="CFBundleName">
        <source>$(PRODUCT_NAME)</source>
        <target/>
        <note>Bundle name</note>
      </trans-unit>
    </body>
  </file>
  <file original="TestApp/en.lproj/Localizable.strings" source-language="en" datatype="plaintext" target-language="pl-PL">
    <header>
      <tool tool-id="com.apple.dt.xcode" tool-name="Xcode" tool-version="10.0" build-num="10L201y"/>
    </header>
    <body>
      <trans-unit id="All">
        <source>All</source>
        <target>Wszystkie</target>
        <note>No comment provided by engineer.</note>
      </trans-unit>
      <trans-unit id="Cash">
        <source>Cash</source>
        <target>Gotówka</target>
        <note>No comment provided by engineer.</note>
      </trans-unit>
      <trans-unit id="Yes">
        <source>Yes</source>
        <target>Tak</target>
        <note>No comment provided by engineer.</note>
      </trans-unit>
    </body>
  </file>
  <file original="TestAppTests/en.lproj/InfoPlist.strings" source-language="en" datatype="plaintext" target-language="pl-PL">
    <header>
      <tool tool-id="com.apple.dt.xcode" tool-name="Xcode" tool-version="10.0" build-num="10L201y"/>
    </header>
    <body>
      <trans-unit id="CFBundleName">
        <source>$(PRODUCT_NAME)</source>
        <target/>
        <note>Bundle name</note>
      </trans-unit>
    </body>
  </file>
</xliff>

@emilwojtaszek
Copy link
Author

hey @simonprev any news here?

@simonprev
Copy link
Member

Hey, I didn't have time lately to develop anything on Accent 😢 And since we do not use the xliff format at @mirego it is not a priority right now. But all the building blocks are there for anyone to implement the feature, and I'll be glad to merge it in master 😄

@emilwojtaszek
Copy link
Author

@hauleth can you help us with this?

@hauleth
Copy link
Contributor

hauleth commented Sep 10, 2018

@emilwojtaszek I will try to do so.

@andreymaznyak
Copy link

@hauleth Any updates?

@hauleth
Copy link
Contributor

hauleth commented Feb 25, 2019

@andreymaznyak unfortunately no as I have no time to spend on this, so far.

@simonprev
Copy link
Member

I’m working on aonther feature in my spare time, but xliff support is next on my todo list.

simonprev added a commit that referenced this issue Mar 31, 2019
![image](https://user-images.githubusercontent.com/464900/55203015-35c17980-51a0-11e9-8647-d91209c7b6de.png)

## Issue
📚 #21

## Feature
This is a basic implementation of the XLIFF 1.2 format. This format is used heavily in a lot of translations related tool (and in XCode) so I may have missed some of the implementation details. But it’s a good start for someone who want to contribute to Accent 😉 

## Refactor
This format is a bit trickier than other since it required the master language to export the targets. We needed to refactor some module to use the master language in the serialization process. Also, not needed but cleaner, we wrap the document’s key `top_of_the_file_comment` and `header` inside a new struct `Language.Document`. This will become handy if we ever need to add an attribute to the document OR if we add a different attribute to the serialization input.

## Next steps
This format includes 2 new dependencies to handle XML encode and decode. _Why not use the same XML library used for the XML Android format?_ Because… \*drum roll\* The `<source>` XML tag when encoded by the `mochiweb_html` module is a self closing tag (per the HTML spec) 🥇 

Since those 2 new deps are required for the XLIFF format and can pretty print XML, we should use them _instead of `mochiweb`_ 🎉
@simonprev
Copy link
Member

Basic support for XLIFF has been merged in master 🎉. Please open another issue to track adjustments and tweak to the serializing and parsing module 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants