Solution

Configuring Alchemy Catalyst to Parse CDATA sections within XML files will require setup of 2 parsers; an XML parser and a Text parser which will handle the CDATA section itself.

The sample file "elements_with_cdata.xml" contains 3 localisable elements with CDATA sections inside, like this:

<element><key>Error_PseudoGlobalException</key><value><![CDATA[<br><b>Details- </b> {0}]]></value></element>

 

It is necessary to setup the text parser first which will parse the contents of the CDATA section. This parser will handle the string contained between the [  ] brackets. We will configure the text parser to take all characters found in the CDATA section.

Configuring the Text parser

  1. Go to Tools > Options > ezParse
  2. Select "Text based files" in the file groups list > Select *.txt in the file extensions list
  3. Click Add and enter a new rule name. In this example we used "cdata_sections".
  4. Click Edit Methods... button
  5. Enter ^ for the Start tag and $ in the End tag


  6. Click OK and OK again in the User profile dialog.

The text parser is now created!
^ in the Start tag means start parsing from the start of the line.
$ in the End tag means stop parsing at the end of the line. There is no dependence on any end of line character.

Configuring the XML parser

  1. Go to Tools > Options > ezParse
  2. Select "XML based files" in the file groups list > Select *.xml in the file extensions list
  3. Click Add and enter a new rule name. In this example we used "XML_with_CDATA".
  4. Click Edit Methods... button
  5. Double click the elements to be localised. In this example, the "value" element is localisable.
  6. Double click the #cdata-section element
  7. Tick the Code  Segment tickbox, this will enable dropdowns under the Type and Parser columns
  8. Double click "No parse" in the Type column and select "txt"
  9. Double click "No parse" in the Parser column and select the rule created above: "cdata_sections"



    In the preview, you will now see Code segment. Catalyst will not display the string itself at this stage, only when you insert the file a TTK.


  10. Click OK and OK again in the User profile dialog.

Your parser is now ready to insert XML files with CDATA sections.

Inserting files and translating

When you insert the XML file in Alchemy Catalyst, you will be prompted to select the XML parsing rule. Select the newly created rule, in this example "XML_with_CDATA".

Once the file is inserted in Alchemy Catalyst, you will see that each CDATA section, treated as code segment, is listed under the XML file in the project navigator.
In the string list, you will see "Code segment:#" as seen below. You need to click on the code segment in the navigation to view and translate it.

In order to list out all the strings in the project, including the code segments, click on the Project title and click on the "Show all string" button:

 

Sample files

List of sample files for the Solution outlined above:

elements_with_cdata.xml - Sample XML file including CDATA sections used in the above example.

XML_with_cdata.ezp - ezParse rule built in the above Solution, exported from Alchemy Catalyst. You can import this rule in Tools > Options > ezParse. Click on the Import button.

 

Related topics

 

Products or Versions Affected

  • Alchemy CATALYST 8.0  and greater