Microsoft Translator Provider - Pre/Post Lookup - "Proper" XML Format

I am trying to use the pre/post lookup feature in the Microsoft Translator Provider plugin for Trados Studio, and I consistently get his error:

Warning message indicating a problem with the file 'test_replacements.xml' and advising to ensure the contents are properly-formatted XML as per the plugin's documentation.

There is nothing in the documentation or elsewhere on the web regarding the proper formatting of the XML files. I tried many different things but nothing works. Does anyone know where I could find information on this or perhaps have a sample file that works? 



Generated Image Alt-Text
[edited by: RWS Community AI at 3:58 PM (GMT 0) on 18 Mar 2025]
emoji
  •  

    The instructions are as follows... taken from a web archive for the old MT Enhanced app:

    How to create the necessary xml structure in a text file for batch find/replace lists

    You can use a text editor (e.g. Notepad) to create files containing the necessary xml structure for use as batch find/replace lists.

    The plugin will apply these lists to the source text before sending to the machine translation service and/or to the returned translated text, depending on the options configured in the plugin settings form.

    The files can be saved with any file extension. They must have the following structure:

    <EditCollection>
    <Items>
    <EditItem Enabled={enabled value} EditItemType={type (plain text or regular expression)}>
    <FindText>{text to find}</FindText>
    <ReplaceText>{replacement text}</ReplaceText>
    </EditItem>
    ...
    </Items>
    </EditCollection>

    The first node is <EditCollection>. It contains a list of <Items>.

    The items list contains EditItem elements, each of which has two attributes Enabled and EditItemType.

    The acceptable values for Enabled are true or false. If Enabled is “false” the plugin will ignore the pair. This parameter allows you to temporarily disable a find/replace pair without having to delete it from the file.

    The acceptable values for EditItemType are plain_text and regular_expression. You can use regular expression matching/replacement by setting the EditItemType to regular_expression. For simple plain text replacements, it is best to set it to plain_text to avoid unexpected behavior or the need to insert any special regular expression escape characters. The plugin uses .NET regular expressions.

    Each EditItem has two elements: <FindText> and <ReplaceText>. They represent the text to find and the replacement text, respectively.

    Important: note that there are several special XML characters that will cause problems if you type them directly into the XML file as the values for FindText and ReplaceText. If you need to search and replace things like HTML tags, or any other text containing the < and/or > bracket character, the brackets must be ‘escaped’ with < for <, and > for >. Also, the ampersand character (&) must be escaped with & to avoid problems. Escaping single quotes (') and double quotes (") in the text values is not absolutely mandatory, but it is a good idea in order to avoid any unexpected errors. Some XML editor programs will automatically escape these characters for you when saving the file.

    After the list of EditItems nodes, the other nodes are closed with the corresponding closing tags: </Items> and </EditCollection>.

    Example

    The following is a complete example of the content for a find/replace list file:

    <EditCollection>
    <Items>
    <EditItem Enabled="true" EditItemType="plain_text">
    <FindText>Hello World</FindText>
    <ReplaceText>Hello world!</ReplaceText>
    </EditItem>
    <EditItem Enabled="true" EditItemType="regular_expression">
    <FindText>\bhello\b</FindText>
    <ReplaceText>Hello!</ReplaceText>
    </EditItem>
    </Items>
    </EditCollection>

    Here, there is one plain text pair specifying to find the string “Hello World” and replace it with “Hello world!”. There is also a regular expression pair specifying to find the regular expression “\bhello\b” (a whole-word match for “hello”) and replace it with “Hello!”.

    You can copy and paste the example xml into a text file and modify it as needed. Add EditItem blocks for additional pairs and set the attributes and elements accordingly.

    • The find/replace text specified is case sensitive, i.e., specifying “hello” will not find “Hello”. To find both, two separate EditItem elements are necessary.

    • The replacement is a direct string replacement and not a whole-word search. For example, specifying “no” / “not” as a find/replace pair will cause the word “none” to become “notne”. To use whole-word matching, regular expressions are necessary.

    • The replacements are performed incrementally in the order they appear in the file. Once a replacement is made, the next find/replace will be performed on the updated text. For that reason, with similar strings, it is better to place longer ones first. For example, if you have entries to replace “dogs” with “pets” and “dog” with “a pet”, place the entry for “dogs” first. Otherwise you may get unexpected behavior.

    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 so much, Paul. This is greatly appreciated, and it did work. Shouldn't this be part of the plugin documentation though?

    emoji
  •  

    Shouldn't this be part of the plugin documentation though?

    It will be, the team will update the documentation in due course.

    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
  • Probability score: 0.7  

    Question improvement suggestion: Provide the exact error message you are encountering, as well as the version of Trados Studio you are using. This will help in diagnosing the issue more effectively.  

    In the meantime, based on the information you have provided, here is a suggested answer to your question:  

    Hello Amr,  

    To resolve the issue with the pre/post lookup feature in the Microsoft Translator Provider plugin for Trados Studio, please follow these steps:  

    **Step 1:** Ensure that your XML file adheres to the correct structure. Based on the information you provided, the XML should look like this:  

    ```xml

    <EditCollection>

       <Items>

           <EditItem Enabled="true" EditItemType="plain_text">

               <FindText>Hello World</FindText>

               <ReplaceText>Hello world!</ReplaceText>

           </EditItem>

           <EditItem Enabled="true" EditItemType="regular_expression">

               <FindText>\bhello\b</FindText>

               <ReplaceText>Hello!</ReplaceText>

           </EditItem>

       </Items>

    </EditCollection>

    ```

    **Step 2:** Make sure to escape any special XML characters in your `FindText` and `ReplaceText` fields. For example, use `<` for `<` and `>` for `>`. This is crucial to avoid syntax errors.

    **Step 3:** Check the HTML code in the CDATA section of your source file for any doubled angled brackets or other issues that might cause the error.

    **Step 4:** If you are using the HTML embedded content processor, ensure that the content is valid HTML. Characters like `<` and `>` must be escaped as entities.

    **Step 5:** If the issue persists, consider using a different embedded content processor, such as the Plain text embedded content processor, or define regex rules to process the content.

    **Step 6:** If you continue to experience issues, please provide the exact error message you are receiving and the version of Trados Studio you are using. This information will help in diagnosing the problem more effectively.

    I hope this answer addressed your question. If not, please reject the answer, add the question improvement suggestion information, and click the RWS Community AI checkbox on the right to try again.  

    RWS Community AI

    emoji