+ Reply to Thread
Results 1 to 4 of 4

Thread: How to deal with Trados INI files with Linux tools

 
  1. #1
    Contributing User
    Join Date
    May 2011
    Posts
    166
    Rep Power
    192

    Default How to deal with Trados INI files with Linux tools

    Hi there

    A few comments on how I went about a task that promised to be highly boring.

    The problem: about 20 xml files, around 50 lines long each. Just a couple of tags, say "code" and "data". The "code" tag could be set as non-translatable straight away from the Tag editor.

    The thing is that among the "data" fields, there are also a few items which should not be translated. A way of distinguishing between them was by looking at an attribute which had lots of different values. I realised that if these numbers were within a particular range (say between 100 and 700) then the item was translatable, otherwise it wasn't .

    The way of getting this job done with Trados itself is, for each number outside the range, duplicate the element "data" adding a condition on the attribute, and again and again ... say 50 times (with this specification it could have been up to 400 times!! Luckily not all numbers outside the range were used).

    I'll leave this simmering and see if someone comes up with a way of doing it more efficiently.

    Cheers.
    P.

  2. #2
    Contributing User
    Join Date
    May 2011
    Posts
    166
    Rep Power
    192

    Default Re: How to deal with Trados INI files with Linux tools

    Sorry it took me so long to get back to this, completely overwhelmed by work.

    Here is a sample of the fields I was mentioning:

    Code:
    <data att="040">SpMaXX-spa-BN</data>
    <data att="082">900</data>
    <data att="100">La ventana abierta</data>
    [...]
    So first extract the attributes that had to be set as non-translatable. Actually, what I did was extract them all and cut out the unwanted part on a text editor, but it could have been done directly with a well crafted regular expression:

    Code:
     pabloa$ grep -ho 'att="[^123456][0-9][0-9]"' *.xml |sort -u
    att="001"
    att="005"
    att="007"
    att="008"
    att="010"
    att="015"
    att="016"
    att="034"
    att="035"
    att="040"
    att="041"
    att="080"
    att="082"
    att="700"
    att="730"
    att="740"
    att="752"
    att="856"
    att="899"
    Then a simple substitution would let us get the lines we would need to add to the INI file so everything would be nice. If only we knew how an INI file expects this kind of information!

    That will be the next chapter, because we are still a bit snowed under here.

    Cheers.
    P.
    Last edited by pabloa; 08-08-2011 at 08:05 AM.

  3. #3
    Contributing User
    Join Date
    May 2011
    Posts
    166
    Rep Power
    192

    Default Re: How to deal with Trados INI files with Linux tools

    Hi there

    When we look inside an INI file, there are some sections between square brackets with different settings. The relevant one for what we are trying to do is [Tags]. After modifying this INI via Trados, duplicating the "data" element with a conditional, we get the following:

    Code:
    [Tags]
    Tag1=data:External,Other Attributes:att
    Tag2=data[@att="015"]:External,Group,Other Attributes:att
    Tag3=control:External,Group,Other Attributes:att
    DefaultTagStyle=External
    Tag4=--end--
    Each line begins with "TagX" with X consecutive numbers. The last one is always "TagN=--end--", where N is the highest number. Experimenting a bit with the Tag Editor it looks as if the tags and conditional attributes are saved with no rhyme nor reason. And the "DefaultTagStyle" line is somewhere in the middle of them, also nowhere in particular. Maybe there is some kind of optimisation going on, but I couldn't figure out any pattern.

    Anyway, notice that the tags are marked as "External" (that is, they delimit segments), and the non-translatable ones say "Group" after "External". And the syntax for a tag with a conditional is

    Code:
    tagname[@attribute="attributevalue"]
    So the only thing left to achieve a nice INI file is to get the list of attributes as in my previous post and create the corresponding lines:

    TagX=data[@att="YYY"]:External,Group,Other Attributes:att

    ... with the X going up one by one, and the YYY going through the attributes we want to mark as non-translatable. Next time I'll post a script that does this.

    Cheers.
    P.

  4. #4
    Contributing User
    Join Date
    May 2011
    Posts
    166
    Rep Power
    192

    Default Re: How to deal with Trados INI files with Linux tools

    Hi there

    Finally, here is the script I've used to generate the lines to be added to the INI file:

    Code:
    #!/bin/bash
    n=5
    for x in $(grep -ho 'att="[^123456][0-9][0-9]"' *.xml|sort -u|grep -o "[0-9]*")
    do
        echo "Tag$n=data[@att="$x"]:External,Group,Other Attributes:att"
        n=$(( n+1 ))
    done
    We start the counter at 5, but this would depend on how many tags you've got already defined in that INI. There is no much to explain here. To the list of attributes we've got earlier, we use "grep -o" again to extract just the numbers. After pasting the list generated by this script into the INI file, right before the tag marking the end of the list of tags, we need to remember to change the number in this last tag to the proper one. And we are done!

    Cheers.
    P.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. UTF16 files (INI and TTX) in Linux
    By pabloa in forum Trados
    Replies: 0
    Last Post: 08-10-2011, 10:05 AM
  2. Manipulating Trados INI files in Linux
    By pabloa in forum Trados
    Replies: 0
    Last Post: 07-28-2011, 05:05 PM
  3. INI files and Trados 2009
    By mvictoria in forum Trados
    Replies: 1
    Last Post: 06-24-2011, 02:51 PM
  4. QA Tools - xBench and Trados 2009 files
    By gentle in forum Other Translation Forums
    Replies: 0
    Last Post: 02-09-2011, 03:35 PM
  5. too large files and Trados
    By andreap in forum Other CAT Tools
    Replies: 4
    Last Post: 04-30-2010, 04:43 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •