Automattic / Automattic/xliff

Preserve unmodeled <file>/<trans-unit> (and inline) attributes on round-trip

Open
#28 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Ruby
Stars
3
Forks
2
Avg merge
2h 46m
Merged PRs (30d)
3

Description

`Xliff::File` models only `original`, `source-language`, `target-language`, and `datatype`; `Xliff::Entry` models only `id` and `xml:space`. Every *other* attribute — on ``, ``, ``, ``, and `` — is silently dropped on parse and never re-emitted.

Confirmed dropped from a fully standard-root document (all legal XLIFF 1.2 attributes):

- ``: `product-name`, `date`, `tool-id`, …
- ``: `approved`, `maxwidth`, … (`approved` marks a unit as reviewed — core translation-workflow state)
- ``: `state`, `xml:lang`; ``: `xml:lang`; ``: `from`, `priority`

So `Bundle.from_string(x).to_s != x` for any document carrying attributes beyond the modeled set, even when its root is fully standard. This is the same "fixed model drops the rest" family as #16 (root attributes), #17 (``/``), and #18 (header namespaces).

## Proposed fix

On parse, capture each element's unmodeled attributes (everything beyond the known set) and replay them on write — bounded: read `xml.attribute_nodes`, keep the ones the model doesn't already own, re-emit them in `to_xml`.

## Scope

Split out of the #15 review sweep. Xcode's own exports use only the modeled attributes, so this isn't required for that use case, but it's silent data loss for general XLIFF 1.2 and undercuts the byte-identical round-trip claim. The README documents the limitation until this lands.

Contributor guide

No contributing guide indexed for this repository

Research direction

Locate the parse and to_xml implementations for Xliff::File, Xliff::Entry, and the source, target, and note elements; start by tracing how xml.attribute_nodes are currently handled. Preserve attributes outside each model's known set and verify that standard XLIFF 1.2 documents with the listed attributes round-trip without losing them.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.