locize/xliff

Support for `additionalAttributes` on target

Closed this issue ยท 7 comments

dbo commented

๐Ÿš€ Feature Proposal

There's a way to use define inline elements for target via the JS API, but I don't find a way to define additional attributes on such.

Motivation

For instance, defining the translation state on a target, http://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html#target

Example

AFAIS, source and target could be either a string or an array (inline elements). Allowing a structured object could define attributes e.g.

target: {
  content: "Hallo",
  additionalAttributes: {
    state: "new",
  }
}
adrai commented

Please check out this example: https://github.com/locize/xliff#additional-attributes-example

something like this:

import jsToXliff12 from 'xliff/jsToXliff12'

const js = {
  resources: {
    namespace1: {
      key1: {
        source: '',
        target: 'Hallo',
        additionalAttributes: {
          state: 'new'
        }
      }
    }
  }
}

jsToXliff12(js, (err, res) => {
  console.log(res)
  // <xliff xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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" xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
  //   <file original="namespace1" datatype="plaintext">
  //     <body>
  //       <trans-unit id="key1" state="new">
  //         <source></source>
  //         <target>Hallo</target>
  //       </trans-unit>
  //     </body>
  //   </file>
  // </xliff>
})
adrai commented

Or do you mean attributes on the <target> element? like this: <target some="attr"> ?
// cc: @probertson

dbo commented

yes, I mean attributes on <target>

I would even extend this need to all elements. I need to add custom attributes to almost everything and it is the only limitation of this library for me which prevents me from using it. And because I need it asap, I need to fork.

adrai commented

I would even extend this need to all elements. I need to add custom attributes to almost everything and it is the only limitation of this library for me which prevents me from using it. And because I need it asap, I need to fork.

If you like you can also contribute with a PR.

I would even extend this need to all elements. I need to add custom attributes to almost everything and it is the only limitation of this library for me which prevents me from using it. And because I need it asap, I need to fork.

If you like you can also contribute with a PR.

I might if I have some spare time. For now I forked and I am just implementing the part that I immediately need and want (jsToXliff12) and then I will have a look into how hard would it be to implement it for the rest.

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.