How to set html parser rule to translate or NOT translate text in span elements based on the value of an attribute (data-condition)? The html code is generated by RoboHelp. [Conditional text]

<p class="Numbered" dir="ltr">Click to place the object in the drawing.<span data-condition="VW:Comment"> [Test of conditional text for translation.]</span></p>

Parents
  • Maybe something like this as your condition:

    span[@data-condition="VW:Comment"]

    Then set it as non-translatable:

    Trados Studio Edit Rule window showing a rule setup with condition span@data-condition='VW:Comment' and properties set to non-translatable.

    I created this file to test:

    <!DOCTYPE html>
    <html>
    <body>
    
    <p class="Numbered" dir="ltr">Click to place the object in the drawing.<span data-condition="VW:Comment">Don’t translate me</span></p>
    <p class="Numbered" dir="ltr">Click to place the object in the drawing.<span>Translate me</span></p>
    <p class="Numbered" dir="ltr">Click to place the object in the drawing.<span data-condition="VW:Comment">Don’t translate me either</span></p>
    <p class="Numbered" dir="ltr">Click to place the object in the drawing.<span>Do me too</span></p>
    
    </body>
    </html>

    And it extracts like this:

    Trados Studio preview pane displaying extracted text from an HTML file with specific spans marked as 'Don t translate me' set as non-translatable.

    So seems to work for me anyway.

    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: Trados AI at 9:41 AM (GMT 0) on 29 Feb 2024]
Reply
  • Maybe something like this as your condition:

    span[@data-condition="VW:Comment"]

    Then set it as non-translatable:

    Trados Studio Edit Rule window showing a rule setup with condition span@data-condition='VW:Comment' and properties set to non-translatable.

    I created this file to test:

    <!DOCTYPE html>
    <html>
    <body>
    
    <p class="Numbered" dir="ltr">Click to place the object in the drawing.<span data-condition="VW:Comment">Don’t translate me</span></p>
    <p class="Numbered" dir="ltr">Click to place the object in the drawing.<span>Translate me</span></p>
    <p class="Numbered" dir="ltr">Click to place the object in the drawing.<span data-condition="VW:Comment">Don’t translate me either</span></p>
    <p class="Numbered" dir="ltr">Click to place the object in the drawing.<span>Do me too</span></p>
    
    </body>
    </html>

    And it extracts like this:

    Trados Studio preview pane displaying extracted text from an HTML file with specific spans marked as 'Don t translate me' set as non-translatable.

    So seems to work for me anyway.

    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: Trados AI at 9:41 AM (GMT 0) on 29 Feb 2024]
Children