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

    Thanks for the email... one more question.  When you have something like this:

    Screenshot of Trados Studio showing a poorly formatted XML file with a list entry tag containing multiple country codes and a paragraph tag for translation text.

    Where do you want the translation to go? Do you want to overwrite the English?  Do you want to create new elements, one for each language so you end up with a file containing all the languages mentioned under countries?

    This is really a brilliant example of how NOT to prepare files for localisation, but nonetheless I would be asking this question to know what the client needs to receive back.

    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]
  • Thanks Paul, so the client generates one file per language, so we'd be looking to overwrite the "some text for translation" with the translated text in just one language. These aren't multilingual files, so we'd get one source file per language and overwrite the English with the translation. I hope that made sense?! Sorry I know these are pretty confusing! 

    emoji
  •   

    ok -this actually makes it easier as your original question referred to a bilingual XML, but this isn't a bilingual or multilingual XML.  It's just a monolingual XML where we just need to extract the text for translation based on the rules you provided and overwrite it with the target translation.

    So... I now have another question... hopefully the last one.  In this example where I have highlighted all the possible text to be extracted for translation:

    Screenshot of Trados Studio XML code with highlighted text showing parent elements containing country attributes and child elements for extraction.

    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?

    Close-up of Trados Studio XML code with highlighted sections indicating text for translation extraction, including country attributes and emphasis tags.

    With this information I probably have enough to give you an idea and hopefully you'll be able to manage this on your own thereafter.

    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]
  •  

    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