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

Support multiple source files in single XLIFF file #135

Open
carusology opened this issue Sep 9, 2021 · 1 comment
Open

Support multiple source files in single XLIFF file #135

carusology opened this issue Sep 9, 2021 · 1 comment

Comments

@carusology
Copy link

This is an enhancement.

The current implementation of the serialize_xliff.pm XLIFF serializer is built around the concept of one source file per XLIFF interchange file. You can see this assumption in the serialize subroutine where it creates a new <xliff> element every time it is ran (Source). However, the XLIFF Spec specifically states its support for multiple source <file> elements within an <xliff> element (Source):

<xliff>

XLIFF document - The <xliff> element encloses all the other elements of the document. The required version attribute specifies the version of XLIFF. The optional xml:lang attribute is used to specify the language of the content of the document.

Required attributes: version.
Optional attributes: xml:lang, non-XLIFF attributes
Contents: One or more <file> elements, followed by Zero, one or more non-XLIFF elements.

Therefore, it seems like we could update the serializer to support something like an upsert boolean to its schema. If true, this would fetch the existing file's contents and look for a matching <file> element. If found, it would update its contents instead of creating a new <xliff> file from scratch.

The deserialize subroutine actually already parses this information correctly across multiple <file> elements because it uses a //trans-unit XPATH query (Source), but I think we'd need to update the deserialize subroutine's API to take in additional and optional arguments in order to only extract the content associated with the appropriate original source file.

What do you think?

@brantonb
Copy link

As an additional vote for this, xcodebuild -exportLocalizations creates one .xliff file per language. It has a <file> node for each localizable file within the workspace.

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

No branches or pull requests

2 participants