How to adapt xliff 1.1.-1-2 to lock Confluence "code" formatting

Hello,

I'm using Studio 2024 and I'm struggling with efficiently translating xliff files exported from Atlassian Confluence xliff version 1.1.-1.2). 

1. Exclude Code format from translation

There is a formatting option called "code" in Confluence, which leads to the following tags: Highlighted XML code showing 'x-code' tags with text formatted as code.

I want the xliff parser to lock these tags with "code" formatting. I tried with the following setting in the file type settings but there was no effect:

<[^>]*x-code[^>]*>

Trados Studio settings window with 'AddEdit Embedded Content Rule' dialog open, showing regex for 'x-code' tags.

Trados Studio editor view displaying segments with 'x-code' and 'x-vsn-link' tags highlighted.

I did not change anything for the tag segmentation:

Advanced Settings dialog in Trados Studio showing options for tag properties and segmentation hints.

Can you help with the regex? I tried to avoid using the whole phrase because I'm alway unsure about escaping the " "...

Or is this the wrong place to make these settings??

2. Exclude hyperlink texts from translation

I want to use the same approach to exclude link texts from translation, as Confluence (AFAIK) willl automatically use the page title as link text once translated. 

-> So I need to exclude these texts as well:

Highlighted XML code showing 'x-vsn-link' tag with attributes and text 'Translation tests'.

-> but not those links where a custom link title is used:

Highlighted XML code showing 'x-vsn-link' tag with attributes and text 'I am a link to another chapter'.

I'm not very good at these regular expression things and I've wasted some time now on that so I hope you can help :-) 

yve



added reg ex
[edited by: Yvonne Rezbach at 10:06 AM (GMT 1) on 3 Jun 2025]
emoji
Parents
  •  

    You cannot use embedded content for this.  In Trados Studio, <g> tags are not treated as embedded content by default when using the standard XLIFF filetype.  Unlike with custom XML filetypes where you can define embedded content rules, the XLIFF filetype does not allow you to configure specific inline elements like <g> as lockable or non-translatable.  While it is technically possible to process XLIFF files using the Monolingual XML or Multilingual XML filetypes (where embedded content rules could be defined to handle <g> tags accordingly), this may not be desirable if you want to retain the built-in behaviour and features associated with the native XLIFF filetype in Trados Studio.

    Since you are using the XLIFF filetype where you don't have this flexibility, you could pre/post-process the XLIFF files in some way.  A simple way to do this would be by using the mrk element with a protected attribute like this (image shows the original on the left and the changes on the right):

    So the pre-process would replace g elements that have the ctype="x-code" attribute with an mrk element that contains the mtype="protected" attribute.  So instead of this:

    You would see this:

    Then reverse the change in the translated files afterwards.  A pretty basic change that you could either encourage your client to do and send you files that are prepared this way, or you could do this with a simple search & replace.  Easily done both ways, and could be scripted to handle multiple files in one go if needed.

    Paul Filkin | RWS Group

    ________________________
    Design your own training!

    You've done the courses and still need to go a little further, or still not clear? 
    Tell us what you need in our Community Solutions Hub

    emoji


    Generated Image Alt-Text
    [edited by: RWS Community AI at 11:49 AM (GMT 1) on 3 Jun 2025]
  •  

    I forgot to clarify the second part...

    The exclude hyperlinks could also be handled in a similar way.  During XLIFF pre-processing you check like this in your search & replace:

    If a <g> element has the attribute ri:page-content-title, treat it as a system-generated link and mark the entire content as locked.

    So, some proper examples... before:

    <?xml version="1.0" encoding="UTF-8"?>
    <xliff version="1.2"
           xmlns:ri="www.atlassian.com/.../"
           xmlns:xsi="www.w3.org/.../XMLSchema-instance"
           xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
      <file source-language="en" target-language="de" datatype="plaintext" original="example.xml">
        <body>
    
          <!-- Code block: should be locked -->
          <trans-unit id="tu1">
            <source><g ctype="x-code" id="g1">I am a sentence formatted in code</g></source>
          </trans-unit>
    
          <!-- Code inline: should be locked -->
          <trans-unit id="tu2">
            <source>I am <g ctype="x-code" id="g2">code within a segment</g></source>
          </trans-unit>
    
          <!-- Auto-generated Confluence link: should be locked -->
          <trans-unit id="tu3">
            <source>
              <g ctype="x-vsn-link" id="g3" ri:page-content-title="Translation tests">Translation tests</g>
            </source>
          </trans-unit>
    
          <!-- Custom Confluence link: should be translated -->
          <trans-unit id="tu4">
            <source>
              <g ctype="x-vsn-link" id="g4">I am a link to another chapter</g>
            </source>
          </trans-unit>
    
        </body>
      </file>
    </xliff>

    After:

    <?xml version="1.0" encoding="UTF-8"?>
    <xliff version="1.2"
           xmlns:ri="www.atlassian.com/.../"
           xmlns:xsi="www.w3.org/.../XMLSchema-instance"
           xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
      <file source-language="en" target-language="de" datatype="plaintext" original="example.xml">
        <body>
    
          <!-- Code block: locked -->
          <trans-unit id="tu1">
            <source>
              <mrk mtype="protected" ctype="x-code" id="g1">I am a sentence formatted in code</mrk>
            </source>
          </trans-unit>
    
          <!-- Code inline: locked -->
          <trans-unit id="tu2">
            <source>
              I am <mrk mtype="protected" ctype="x-code" id="g2">code within a segment</mrk>
            </source>
          </trans-unit>
    
          <!-- Auto-generated Confluence link: locked -->
          <trans-unit id="tu3">
            <source>
              <mrk mtype="protected" ctype="x-vsn-link" id="g3" ri:page-content-title="Translation tests">Translation tests</mrk>
            </source>
          </trans-unit>
    
          <!-- Custom Confluence link: translatable -->
          <trans-unit id="tu4">
            <source>
              <g ctype="x-vsn-link" id="g4">I am a link to another chapter</g>
            </source>
          </trans-unit>
    
        </body>
      </file>
    </xliff>

    Then you get before:

    Screenshot of Trados Studio showing a preview of g_tags.xliff with four segments. Segment 1: 'I am a sentence formatted in code'. Segment 2: 'I am code within a segment'. Segment 3: 'Translation tests'. Segment 4: 'I am a link to another chapter'.

    After:

    Screenshot of Trados Studio showing a preview of g_tags-locked.xliff with two segments. Segment 1: 'I am code within a segment' with 'code' marked as locked. Segment 2: 'I am a link to another chapter'.

    Paul Filkin | RWS Group

    ________________________
    Design your own training!

    You've done the courses and still need to go a little further, or still not clear? 
    Tell us what you need in our Community Solutions Hub



    Generated Image Alt-Text
    [edited by: RWS Community AI at 12:08 PM (GMT 1) on 3 Jun 2025]
Reply
  •  

    I forgot to clarify the second part...

    The exclude hyperlinks could also be handled in a similar way.  During XLIFF pre-processing you check like this in your search & replace:

    If a <g> element has the attribute ri:page-content-title, treat it as a system-generated link and mark the entire content as locked.

    So, some proper examples... before:

    <?xml version="1.0" encoding="UTF-8"?>
    <xliff version="1.2"
           xmlns:ri="www.atlassian.com/.../"
           xmlns:xsi="www.w3.org/.../XMLSchema-instance"
           xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
      <file source-language="en" target-language="de" datatype="plaintext" original="example.xml">
        <body>
    
          <!-- Code block: should be locked -->
          <trans-unit id="tu1">
            <source><g ctype="x-code" id="g1">I am a sentence formatted in code</g></source>
          </trans-unit>
    
          <!-- Code inline: should be locked -->
          <trans-unit id="tu2">
            <source>I am <g ctype="x-code" id="g2">code within a segment</g></source>
          </trans-unit>
    
          <!-- Auto-generated Confluence link: should be locked -->
          <trans-unit id="tu3">
            <source>
              <g ctype="x-vsn-link" id="g3" ri:page-content-title="Translation tests">Translation tests</g>
            </source>
          </trans-unit>
    
          <!-- Custom Confluence link: should be translated -->
          <trans-unit id="tu4">
            <source>
              <g ctype="x-vsn-link" id="g4">I am a link to another chapter</g>
            </source>
          </trans-unit>
    
        </body>
      </file>
    </xliff>

    After:

    <?xml version="1.0" encoding="UTF-8"?>
    <xliff version="1.2"
           xmlns:ri="www.atlassian.com/.../"
           xmlns:xsi="www.w3.org/.../XMLSchema-instance"
           xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
      <file source-language="en" target-language="de" datatype="plaintext" original="example.xml">
        <body>
    
          <!-- Code block: locked -->
          <trans-unit id="tu1">
            <source>
              <mrk mtype="protected" ctype="x-code" id="g1">I am a sentence formatted in code</mrk>
            </source>
          </trans-unit>
    
          <!-- Code inline: locked -->
          <trans-unit id="tu2">
            <source>
              I am <mrk mtype="protected" ctype="x-code" id="g2">code within a segment</mrk>
            </source>
          </trans-unit>
    
          <!-- Auto-generated Confluence link: locked -->
          <trans-unit id="tu3">
            <source>
              <mrk mtype="protected" ctype="x-vsn-link" id="g3" ri:page-content-title="Translation tests">Translation tests</mrk>
            </source>
          </trans-unit>
    
          <!-- Custom Confluence link: translatable -->
          <trans-unit id="tu4">
            <source>
              <g ctype="x-vsn-link" id="g4">I am a link to another chapter</g>
            </source>
          </trans-unit>
    
        </body>
      </file>
    </xliff>

    Then you get before:

    Screenshot of Trados Studio showing a preview of g_tags.xliff with four segments. Segment 1: 'I am a sentence formatted in code'. Segment 2: 'I am code within a segment'. Segment 3: 'Translation tests'. Segment 4: 'I am a link to another chapter'.

    After:

    Screenshot of Trados Studio showing a preview of g_tags-locked.xliff with two segments. Segment 1: 'I am code within a segment' with 'code' marked as locked. Segment 2: 'I am a link to another chapter'.

    Paul Filkin | RWS Group

    ________________________
    Design your own training!

    You've done the courses and still need to go a little further, or still not clear? 
    Tell us what you need in our Community Solutions Hub



    Generated Image Alt-Text
    [edited by: RWS Community AI at 12:08 PM (GMT 1) on 3 Jun 2025]
Children
No Data