XML file to be set in SDL Studio 2014

Hi,

I have a XML file in the following structure:

<GIS_HELLO_WORLD string="Hello World" maxlength="11" g="1" w="1" r="0" />
<GIS_PLEASE_WAIT string="Please wait" g="0" w="0" r="0" a="1" />
<GIS_NOTICE string="Notice" g="0" w="0" r="0" a="1" />

We need to translate only the text after "string=".

Studio can't handle this type of file and I want to know how can I add or edit a XML file type to be able to show only the relevant text for translation.

Thanks

Fouad

Parents
  • Hi Fouad

    Studio has no issues dealing with this type of file - all you need to add is either a rule for the 'string' attribute in the parser rules or an XPath rule to deal with all elements containing the 'string' attribute.  Sample file and filetype attached containing an XPath rule to deal with all instances of the attribute 'string'.  I added <test> as the root element to the sample file.

    I hope this helps.

    Forum.zip

    Thanks
    Fas

     

    Fas Aziz | Desktop Life Cycle Service Manager | SDL | Support Operations, Support Lifecycle

  • Something is still wrong and Studio doesn't recognize the XML type even if I import the settings you sent me to a new XML File type.
    Maybe I did something wrong? Can you please instruct me with detailed steps of how to set/import?

    Best Regards
    Fouad
  • Hi Yael,

    There two places you should read that will explain what Fas did.

    Why do we need custom xml filetypes

    More Regex? No it's time for something completely different.

    Both these articles will explain this and more. But in a nutshell Fas just used two simple xpath rules as he explained. First this one set as non translatable:

    //*

    This basically means don't translate anything. The star is a wildcard meaning select everything. So all he did was ensure that nothing is added for translation at all.

    Next he added a rule to extract exactly what you wanted:

    //*/@string

    This just means extract the text from all attributes named string. So in Studio you see this:


    The only other thing he did was to ensure the xml file was recognised by adding the root element of data into the detection box.


    Not too tricky!

    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

  • <?xml version="1.0" encoding="utf-16"?>
    <data version="1.0.1" encrypted="0" dataType="StringData">
      <dictionary language="enu">
        <GIS_HELLO_WORLD string="Hello World" maxlength="11" g="1" w="1" r="0" />
     <!-- ======================== GI Android Strings ================================ -->
        <GIS_M12A_ENTERPRISE string="M12A Enterprise Holter System" maxlength="40" g="0" w="0" r="0" a="1" />
        <GIS_CHOOSE_DEVICE string="Choose device" maxlength="15" g="0" w="0" r="0" a="1" />
        <GIS_RA string="RA" maxlength="5" g="1" w="1" r="1" a="1" />
        <GIS_LA string="LA" maxlength="5" g="1" w="1" r="0" a="1" />
        <GIS_LL string="LL" maxlength="5" g="0" w="0" r="0" a="1" />
        <GIS_NO_PAIRED_DEVICES string="There are no devices paired, or bluetooth is disabled. &#xA;	Would you like to pair a new device?" maxlength="150" g="0" w="0" r="0" a="1" />
        <GIS_NO_BLUETOOTH string="Unable to access bluetooth information. Please press OK to restart/enable bluetooth" maxlength="150" g="0" w="0" r="0" a="1" />
        <GIS_PLEASE_WAIT string="Please wait" maxlength="20" g="0" w="0" r="0" a="1" />
        <GIS_NOTICE string="Notice" maxlength="15" g="0" w="0" r="0" a="1" />
        <GIS_PINCH_ZOOM string="Use pinch zoom to zoom in and out of ECG presentation" maxlength="150" g="0" w="0" r="0" a="1" />
        <GIS_DONT_SHOW string="Don\'t show this hint again" maxlength="50" g="0" w="0" r="0" a="1" />
        <GIS_REQUIRES string="requires at least" maxlength="25" g="0" w="0" r="0" a="1" />
        <GIS_IS_REQUIRED string="is required" maxlength="15" g="0" w="0" r="0" a="1" />
        <GIS_CHARACTERS string="Characters" maxlength="15" g="0" w="0" r="0" a="1" />
        <GIS_ATTENTION string="Attention!" maxlength="15" g="0" w="0" r="0" a="1" />
        <GIS_CONFIRM_3_COLON_ string="Confirm 3: " maxlength="10" g="0" w="0" r="1" />
      </dictionary>
    </data>
    Thanks Paul,

    The problem now is that we have an updated file - but the settings do not work...
    It doesn't recognize the file type.

    See a sample attached...
    For me, it looks the same template.
    Can you please take a look at it and maybe you can tell me what to change?

    BR
    Fouad

  • Hello Yael,

    The problem is not the settings file it's your xml file itself.  The file should be encoded UTF16-LE and it should have a BOM (Byte Order Mark). This file you provided has no BOM and whilst the decl;aration says UTF16 a decent text editor will confirm it's actually UTF8.

    Try this one.  You also get a warning when you open the file in Studio that gives you a clue the file has ben corrupted somewhere... not a Studio problem:


     

    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

  • The file you sent me are recognized in SDL Studio - but the full file we have here still has Warning of "Pre-Scanning Error".
    What did you do in the Sample you sent me?

    BR
    Fouad
  • As I said, I added the BOM back and made sure the file was UTF16.  This is nothing to do with Studio at all. Many parsers will default to UTF8 if the BOM is missing and this is what happened here.  You need a decent text editor to be able to see this and correct it... I use EditPadPro which allows me to see the difference and correct it like this, but I believe NotePad++ can do this too and that one is free.

    Your new file:

    My corrected file (and your very first sample):

    If you are going to work with files like this then I'd recommend you get a decent editor, otherwise it's very easy to corrupt the files yourself, never mind any problems that can occur through doing things like copying files from a MAC to a Windows environment, or emailing them... could be many things that cause this.  The best solution is to always make sure the xml files are zipped before moving them around.

    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

  • Still getting warnings even after changing the encoding.

    Pre-Scanning Failed to identify the file type.. It is about the "Unexpected XML declaration must be the first node in the document, and no white space characters are allowed to appear before it. Line 1, position 4."

    The file looks OK - and no white spaces in it.

    Is this the XML corruption that you talked about?

    BR

    Fouad

  • It seems that the difference between the first version that we managed to work with and the current version is the additional "maxlength" option in the each string (I've run beyond compare between both files). This option was not in the first file and the settings that you sent me worked perfectly.

    <GIS_PLEASE_WAIT string="Please wait" maxlength="20" g="0" w="0" r="0" a="1" />
    <GIS_NOTICE string="Notice" maxlength="15" g="0" w="0" r="0" a="1" />

    Can you please advise?

    BR

    Fouad

  • Advise what? The additional attribute in the file makes no difference at all Fouad. The filetype settings have one rule and that is to extract the text from any string attribute found in the file. So in the two above it would extract "Please wait" and "Notice". That's it. It doesn't matter what else is added to the file.

    The problem with the second file you provided is 100% because the file was corrupted.

    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

  • OK then, we will inform our client...
    He sent me a new XML - and again it performs the same declaration errors...

    BR
    Fouad
  • Did you try zipping the xml before sending it? Sometimes transferring files without zipping them can cause a problem like this, especially between Windows and Unix machines; even more so if you open them without a proper editor and save the unwanted changes.

    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

Reply Children
No Data