Excluding any text that isn't English from the source section in a bilingual XML

I have a bilingual XML file, is there a way of automatically excluding any text that isn't English from the source section when processing the file in Trados? It's currently a mix of Arabic and English in the source, and I only want to translate the English into Arabic. I could go through the file manually and lock all of the Arabic sections, but this is a really large file so would take too long, is there a way of doing this automatically/creating a setting that excludes the Arabic in the first place? Thank you!

I have SDL Trados Studio 2021 - 16.0.2.3343

emoji
Parents
  •  

    I have a bilingual XML file, is there a way of automatically excluding any text that isn't English from the source section when processing the file in Trados?

    Probably.

    Can you provide a sample of the XML as this is the only way you'll be able to get concrete answer to this question.

    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
  • Thank you Paul! Any chance I could send you an email with the file? Not sure I can share it publicly unfortunately as we have a few NDAs in place with the client. Thank you! 

    emoji
  •  

    You can see why this needs clearing up...

    Screenshot of Trados Studio showing XML code with a 'Description' element containing a 'Note' parent element with country rule applied, and child 'P' elements with individual country attributes overriding the parent rule.

    The translatable text is all in child elements of Note, and there is a country rule applied.  But then the individual child elements of Note seem to override it.  So this suggests  I should pay attention to child elements and apply the attribute from the parent... unless they are overridden.

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

    In the meantime I did try to solve this and couldn't!  But I did get a bit of help as it was an interesting one for my own learning journey so I created a small example and asked in stackoverflow:

    https://stackoverflow.com/questions/74386847/only-xpath-for-extracting-text-for-multiple-conditions-in-xml-no-code-possible

    Got the answer just now, which I would not have been able to do myself:

    //*[text()[normalize-space()]][not(ancestor-or-self::*/@countries) or contains(ancestor-or-self::*[@countries][1]/@countries, 'ME')]

    Like this in Studio:

    Trados Studio parser options window showing an XML XPath rule input for extracting text with multiple conditions.

    This seems to do the trick.  This is possibly the most complicated XML XPath I've tried to solve, mainly required because the source file itself isn't well thought out for localization purposes.  The simplest way, and potentially error free, would have been to add the supported countries for every element containing translatable text and then you could always and easily pull out the languages you need.

    However, this is pretty clever and you can easily adapt by changing the language code for the languages you need.

    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: Trados AI at 9:20 AM (GMT 0) on 29 Feb 2024]
  • Hi Paul,

    Thank you again for your patience regarding this reply and for your continued help in general! I've sent it onto the client to provide more insight and this is their response. Does this help at all? They've mentioned that they're happy to jump in on a call if that will help clarify anything, let me know if that's something you'd be interested in, no worries if not. Their reply is as follows, your original message is in red:

    Thanks for the update. So, there will be mixes of both depending on the context sometimes an entire section (parent) will be country applicable, others the parent is universally used but there will be a section (child) that’s only applicable to a certain country.

    • As an example for the latter would be say a full size spare wheel on DBX. Everywhere can have it, but certain countries it is an option (default being can of tyre foam), so there may be a P medium (essentially a line of text) which would have text saying Optional in the markets where it doesn’t come as standard, and would be country tagged.
    • An example of a parent being tagged could something like the tracker, as the whole feature is only available in certain markets. This could then get further filters within it by then having individual country tags on P or Description, again for certification text. For example same tracker functionality throughout Europe but different certification in Russia to German.

    Hopefully that makes sense?

    To try and answer the two examples given:

    First Example [your first screenshot]:

    You can see that only the parent elements contain the country.  In the first para it's in this:

    <Description medium="all" countries="TR,ME,IL,CN">

    In the next it's in this:

    <P medium="all" countries="TR,ME,IL,CN">

    Should I be extracting nothing at all since none of these child elements contain that attribute themselves, or should I simply be extracting them all because they don't have the country attribute as per your second rule above?

    Or should I be extracting only the child elements like this, so the last one doesn't get extracted?

    So here, the first bit would the entire description is included/excluded depending on country tag

    The second paragraph, the whole description would be included, but the <P medium="all" countries="TR,ME,IL,CN"> bit would be included/excluded.

    At a guess from the coding above (and because I’m sad and remember these things) that would be the steering column adjustment. The top Description would be describing manual column adjustment which only applies in those particularly regions. The second Description would be electric column adjustment, available on every variant of car, but as an optional feature for TR/ME/IL/CN, and the text that has the country tags would probably say optional. Hopefully giving an example of how that would be used in the book clears that one up.

    Second example [your third screenshot]:

    The translatable text is all in child elements of Note, and there is a country rule applied.  But then the individual child elements of Note seem to override it.  So this suggests  I should pay attention to child elements and apply the attribute from the parent... unless they are overridden.

    Ok so here, this might be more of a fringe case as I’d usually do a separate note for each entry rather than a single parent note and then separate text for each entry inside it with no single P entry to apply to all of them – for example there was another P medium in there with no country tag so would be in for all NR,KR,GB,TR, but essentially both tiers (Note and P) would be included for respective translation?

    emoji
  •  

    I think this is not needed now.  I gave you the solution in my last post.  Have you tried it?

    //*[text()[normalize-space()]][not(ancestor-or-self::*/@countries) or contains(ancestor-or-self::*[@countries][1]/@countries, 'ME')]

    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
  • Apologies Paul, I didn't see it! I will try it and get back to you!

    emoji
  • Hi Paul, 

    I've tried this solution (so has another of my colleagues), but we're getting the same word count that we do if there is no filter applied at all. I'm wondering if we're not doing it correctly. Just to check, do we need to create a new file type, or can I just add it to the pre-existing XML file type in Trados? There are other XPaths within that file type of course, but I added the new one and moved it to the top of the list so that Trados prioritises it. I've also created a new file type and added the XPath, but again nothing changed in the output. 

    The settings that I used are as follows, which seem to match yours, are they correct?

    Trados Studio Edit Rule dialog box showing XPath settings for XML file type filtering with no visible errors.

    If I create a new file type and try to match your view, this is what I've got, but it's still just importing everything and not filtering out the bits that we don't want.

    Trados Studio File Types view with a test file type selected, displaying XPath rules for translation filtering with no visible errors.

    Thanks Paul! 

    emoji


    Generated Image Alt-Text
    [edited by: Trados AI at 9:20 AM (GMT 0) on 29 Feb 2024]
  • Hi Paul,

    Just to check that you received my below message about the setting not working for us? I want to check that what we're doing is correct. The client is wanting to move from Across to Trados so we need to get the settings file in place before they make the move so they're currently chasing for an update.

    Thank you in advance for your continued help!

    emoji
  •  

    No, I didn't see it.  If you tag me it helps (type @ and select me from the list that appears) as I'll see the notification.

    do we need to create a new file type,

    Better to create a new one.  Then create your project again.  Also make sure that your project is actually using your new filetype.  Just check the file identifier column in the files view and make sure it' the one you expected to use.

    I can't check as I can't find the example you sent me (you used some other name I don't recall).

    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
  •  

    There are other XPaths within that file type of course, but I added the new one and moved it to the top of the list so that Trados prioritises it.

    Why?  Why are there other xpaths when you provided exactly what rules were required for this file?  I suggest you remove all the other parser rules you have and only use the ones I provided.  Then see if the expression works.

    But really... what are the other rules for and do you understand how they might influence the rules I gave you?

    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
Reply Children